Push notification show on background and foreground

I already receive notifications, but I noticed the message also notify even the app is open. How can I handle this properly? Thanks!

1 Like

Hi @trck,

You need to use activity lifecycle to handle the push notification in foreground.
You need to add the below methods on your application class

public void onMoveToForeground() { 
public void onMoveToBackground() {
    isBackground = true;

Then you need to use “isBackground” variable in OnMessageRecieved() of your MyfirebaseMessagingService.class to check if the app is in background or not.

Please check the below link

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.