Nilesh G
Nilesh G

Reputation: 36

Rnfirebase Notification not working when app is open react native

I have an app that shows notifications perfectly in the foreground and background but not working when the app is in front/open.

    messaging().onNotificationOpenedApp(remoteMessage => {
      console.log(
        'Notification caused app to open from background state: 1111111-22333  app open in background' ,
        remoteMessage.notification,
      );

and

  messaging().onMessage(async (remoteMessage) => {
      console.log('Push Notification: laveshmahajana1 ',remoteMessage)

      PushNotificationIos.addNotificationRequest({

        id: remoteMessage.messageId,
        body: remoteMessage.notification.body,
        title: remoteMessage.notification.title,
       userInfo: remoteMessage.data,
      });
    ```

Upvotes: 1

Views: 1209

Answers (1)

Jignesh Mayani
Jignesh Mayani

Reputation: 7193

Have a try by using https://github.com/zo0r/react-native-push-notification npm.

For Example:

import PushNotification from "react-native-push-notification";

messaging().onMessage(async (remoteMessage) => {

    PushNotification.localNotification({
        title: remoteMessage.data.title,
        message: remoteMessage.data.body,
    })
})

Upvotes: 2

Related Questions