React-native-push-notification: Notification not showing while app is open

Created on 29 Dec 2015  路  9Comments  路  Source: zo0r/react-native-push-notification

I noticed that no notification is being shown when the app is open.
I'm working on Android so I don't know yet about iPhone.
How can I change this?
Thanks!

Most helpful comment

I'm following what @zo0r said, but nothing it's been shown.

All 9 comments

By default if the app is open no notification is shown.

You can use onNotification to get the received notification, check foreground for true (to prevent duplicated notifications) and show it using PushNotification.localNotification(details: Object).

Working, thanks.

I'm following what @zo0r said, but nothing it's been shown.

Yes, not working anymore. I do PushNotification.localNotification and it loops. Not sure how to send a parameter to avoid the eternal loop. But not showing either way, until I close the app I get one notification.

    onNotification: function(notification) {
        console.log('NOTIFICATION:', notification);
        if (notification.foreground) {
          //Diplay the remote notification 
           //This->do not work (loop and notification when app closes)
          //PushNotification.localNotification({message:notification.message,details:{repeted:true}})
         //Temporal solution
         Alert.alert('News from Team', notification.message);
        }
      },

It works for me. No eternal loop.

PushNotification.localNotification is not showing notification while in the app, like @rochapablo. This bug is present since at least year, based on the comments age, what could we do @zo0r ?

The bug is still present

Same for me, bug still happening

You must create a channel.
Regards

Was this page helpful?
0 / 5 - 0 ratings