Hi
I got the following log by this method :
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log('Message handled in the background!', remoteMessage);
});
log :
Message handled in the background! {"data": {"com.urbanairship.metadata": "eyJ2ZXJzaW9uX2lkIjoxLCJ0aW1lIjoxNjM2NDcxNzk3MjgyLCJwdXNoX2lkIjoiZDczN2QxZWMtNTExNC00NWI3LThhNGYtYjI1NWNmYWZiZDcxIiwiY2FtcGFpZ25zIjp7ImNhdGVnb3JpZXMiOltdfX0=", "com.urbanairship.push.ALERT": "Congratulations! You've successfully configured Android Push.", "com.urbanairship.push.APID": "26e8cdec-3e61-437c-940d-cd9e75c3a7df", "com.urbanairship.push.CANONICAL_PUSH_ID": "d737d1ec-5114-45b7-8a4f-b255cfafbd71", "com.urbanairship.push.PUSH_ID": "e51fd020-4171-11ec-a035-02423b27e6fe"}, "from": "827761845713", "messageId": "0:1636471797306222%14a7377ff9fd7ecd", "sentTime": 1636471797292, "ttl": 2419200}
I believe the notification is received successfully but it's not displayed for some reason
** messaging is imported from @react-native-firebase/messaging
I did quick research and I found this in firebase docs :
Data-only messages
When an incoming message is "data-only" (contains no notification option), both Android & iOS regard it as low priority and will prevent the application from waking (ignoring the message). To allow data-only messages to trigger the background handler, you must set the "priority" to "high" on Android, and enable the content-available flag on iOS. For example, if using the Node.js firebase-admin package to send a message:
Notifications
The device state and message contents can also determine whether a Notification will be displayed:
| |
Foreground |
Background |
Quit |
| Notification |
Notification: ❌ |
Notification: ✅ |
Notification: ✅ |
| Notification + Data |
Notification: ❌ |
Notification: ✅ |
Notification: ✅ |
| Data |
Notification: ❌ |
Notification: ❌ |
Notification: ❌ |
Hope you can fix it or help me to understand what is wrong. thanks
react native - android
airship push notification (test send successfully it says when I try to send test message)
Comments
1 comment