(ANDROID)Push notification on foreground

Hello currently I’m working on react native project and having a problem on firebase push notification

as for the background notification is working but on foreground not working

in the documentation did tell to use onMessage method, in the console I can see it trigger but the notification doesn’t appear at the top

can anybody guide me on how to do this

Thanks in advance

Author: Fantashit

1 thought on “(ANDROID)Push notification on foreground

  1. @irsyadmhdilham This is definitely something you’d have to build into your app then – there’s certainly no way for FCM to know what screen you’re on in your app and control whether to show it.

    react-native-firebase does currently have the ability to display a local notification, so you could listen for the onMessage() and then do the following:

    firebase.messaging().createLocalNotification({
      title: "My Notification Title",
      body: "My Notification Message",
      sound: "default",
      priority: "high",
      click_action: "ACTION",
      icon: "ic_launcher",
      show_in_foreground: true,
    });
    

    Just be aware, we are considering moving this out of the main react-native-firebase library into a standalone library in the future.

Comments are closed.

(ANDROID)Push notification on foreground

Hello currently I’m working on react native project and having a problem on firebase push notification

as for the background notification is working but on foreground not working

in the documentation did tell to use onMessage method, in the console I can see it trigger but the notification doesn’t appear at the top

can anybody guide me on how to do this

Thanks in advance

Author: Fantashit

2 thoughts on “(ANDROID)Push notification on foreground

  1. @irsyadmhdilham This is definitely something you’d have to build into your app then – there’s certainly no way for FCM to know what screen you’re on in your app and control whether to show it.

    react-native-firebase does currently have the ability to display a local notification, so you could listen for the onMessage() and then do the following:

    firebase.messaging().createLocalNotification({
      title: "My Notification Title",
      body: "My Notification Message",
      sound: "default",
      priority: "high",
      click_action: "ACTION",
      icon: "ic_launcher",
      show_in_foreground: true,
    });
    

    Just be aware, we are considering moving this out of the main react-native-firebase library into a standalone library in the future.

  2. Pingback: Regression Testing

Comments are closed.

(ANDROID)Push notification on foreground

Hello currently I’m working on react native project and having a problem on firebase push notification

as for the background notification is working but on foreground not working

in the documentation did tell to use onMessage method, in the console I can see it trigger but the notification doesn’t appear at the top

can anybody guide me on how to do this

Thanks in advance

Author: Fantashit

1 thought on “(ANDROID)Push notification on foreground

  1. @irsyadmhdilham This is definitely something you’d have to build into your app then – there’s certainly no way for FCM to know what screen you’re on in your app and control whether to show it.

    react-native-firebase does currently have the ability to display a local notification, so you could listen for the onMessage() and then do the following:

    firebase.messaging().createLocalNotification({
      title: "My Notification Title",
      body: "My Notification Message",
      sound: "default",
      priority: "high",
      click_action: "ACTION",
      icon: "ic_launcher",
      show_in_foreground: true,
    });
    

    Just be aware, we are considering moving this out of the main react-native-firebase library into a standalone library in the future.

Comments are closed.