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.

Android: Handling received push notifications (in app's foreground/background state)

See original GitHub issue

According to docs, onNotification is “Called when a remote is received or opened”. I would like to ask, if its possible to somehow get the behaviour that onNotification would be on Android called once push notification is opened, not just once its received (when Android app is in foreground/background)?

When implemented on iOS, onNotification is always called just when I click on received push notification, not immediately once its received. I would like to get the same behaviour on Android as well but it behaves differently there. On Android, if the app is in the foreground/background onNotification is called immediately once the remote notification is received, not when user actually clicks on received notification.

Is it possible to get the same behaviour as described above on iOS also for Android, ie to be able to handle received push notification on Android while the app is in foreground/background just when user opens received push notification, not just when the notification is received?

Thanks for any suggestions!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

Dallas62commented, Jan 16, 2021

Hi @cayleyh @robertgreso

You can find the fix of #1819 inside the version 7.1.0


cayleyhcommented, Jan 26, 2021

Great thanks @Dallas62!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle the Firebase notification when app is in ...
When app is in foreground, notifications are not generated themselves. You need to write some additional code. When message is received onMessageReceived() ...
Read more >
Receive messages in an Android app - Firebase - Google
When your app is in the background, Android directs notification messages to the system tray. A user tap on the notification opens the...
Read more >
Firebase Notifications in Background & Foreground in Android
Handling Notifications in Foreground​​ Create a new class that extends it and implement the onMessageReceived method. Then get the Notification ...
Read more >
Notifications Overview | Android Developers
A notification is required when your app is running a "foreground service"—a Service running in the background that's long living and noticeable to...
Read more >
Part 12, Handling push notifications in foreground - YouTube
In this video we have a look at how to handle the incoming push notification in Android, when the application is in foreground....
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 Post

No results found

github_iconTop Related Hashnode Post

No results found