question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Notification isn't shown in notification centre when the app is in background or closed on android

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:19

github_iconTop GitHub Comments

2reactions
timetargetcommented, Jul 16, 2020

@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.

2reactions
Dallas62commented, Jul 13, 2020

Hi @timetarget In closed state, this should work too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Notifications Not Showing Up? 10 Fixes You Can Try
Not seeing notifications show up on your Android phone? Try these fixes to get Android notifications working again.
Read more >
How to Fix Notifications Not Showing up on Android - Lifewire
Almost any app with a notifications feature has to run in the background for notifications to work. Clear your Android cache partition.
Read more >
Notification not showing when the app is closed - Stack Overflow
In Xiaomi - security-->permissions-->autostart then check mark your app. Enable this means app's any service always run in background. Then you ...
Read more >
Control notifications on Android - Google Support
Open your phone's Settings app. · Tap Apps & notifications and then Notifications. · Under “Recently Sent,” tap an app. · Tap a...
Read more >
Notifications Not Shown - Mobile Push
Android Settings App > Notifications > Your App you should see "Show notifications" enable and all categories underneath enabled.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found