Notification isn't shown in notification centre when the app is in background or closed on android
See original GitHub issueI cannot tell for sure which version this started with. But apparently this started when Firebase became mandatory for receiving remote notifications.
Currently, we are using 3.5.2. This is happening on android devices with custom launchers that allow showing badge count on the app’s icon.
So if we send such structure from our server:
{
"notification": {
"title": "Title of Your Notification",
"body": "Body of Your Notification"
},
"data": {
"badge": 35,
"payload": ""
}
}
we will see a notification in background or closed states, but the badge number will not be updated.
But if we send that structure from our server:
{
"data": {
"title": "Title of Your Notification",
"message": "Body of Your Notification"
"badge": 35,
"payload": ""
}
}
we will get badge number updated, but we will not see a notification. That worked before!
The problem here is when we send both data
and notification
fields overridden FirebaseMessagingService.onMessageReceived
is not getting fired and we don’t set badge count, but notification
field is handled by the OS and we see a notification.
When just a data
field is sent onMessageReceived
is fired and we get updated badge count, but not visible notification in the notification centre.
You can find more information here - https://stackoverflow.com/a/56660363/8457882
How can it be solved? As I can understand there is no way if notification
is provided. Are we able to add logic for showing notification in handleReceivedMessage
method or any other place?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:19
Top GitHub Comments
@webraptor yes, it works. @Dallas62 is right. I called
.configure()
inside a component. Also, I noticed that.localNotification()
should be called outside a component.All are working fine now except one thing. If the app was closed and I received a push notification, then tapped on it the app launched without having been called with this notification.
Hi @timetarget In closed state, this should work too.