I am trying to show the remote notification for ios/iphone irrespective of app state running or killed. I've used react-native-firebase library for this.
Case 1: Key is "notification" and App is in Background (Killed)
So when app is in background and sending the following payload, it shows notification just fine. But does not show notification when app is in foreground (App is running).
"notification": {
"alert" : "Alert, You have a notification",
"title" : "Notification title",
"body" : "The body of the notification",
"sound" : "default"
}
Case 2: Key is "data" and App is in Foreground (App is Running)
So when app is in foreground and sending the following payload, it shows notification just fine. But does not show notification when app is in background (App is killed).
"data": {
"alert" : "Alert, You have a notification",
"title" : "Notification title",
"body" : "The body of the notification",
"sound" : "default"
}
Case 3: When Both keys set, "notification" and "data"
So when app is in the background (killed) and sending the following payload, it shows notification just fine. But does not show a notification when app is in foreground (App is running). Ideally, for the following payload, it should show notification in both case, but it does not.
"notification": {
"alert" : "Alert, You have a notification",
"title" : "Notification title",
"body" : "The body of the notification",
"sound" : "default"
},
"data": {
"alert" : "Alert, You have a notification",
"title" : "Notification title",
"body" : "The body of the notification",
"sound" : "default"
}
What i want to achieve is, irrespective of app is in either of foreground or background, notification must be displayed when sent.
Here is the link to the code: Please suggest.