React-native-notifications: Display notification when app is in foreground

Created on 24 Apr 2020  路  9Comments  路  Source: wix/react-native-notifications

Is there a way how to display system notifications when app is in foreground?

Most helpful comment

On ios, set the { alert: true } when calling completion handler. Its all in the docs.

See here: https://wix.github.io/react-native-notifications/docs/getting-started#register-for-notification-events

Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion) => {
      console.log(`Notification received in foreground: ${notification.title} : ${notification.body}`);
      completion({alert: false, sound: false, badge: false});
    });

Where it says

completion({alert: false, sound: false, badge: false});

You need to set to:

completion({alert: true, sound: false, badge: false});

All 9 comments

@Daha62 please check this out.

Works in snapshot build

@harveyconnor, please could u provide some example?

Its actually in the docs

I got a notification icon and notification Notifications.postLocalNotification(...), but how can i create a notification popup like in reacte-native-firebase
firebase.notifications().displayNotification?

On ios, set the { alert: true } when calling completion handler. Its all in the docs.

See here: https://wix.github.io/react-native-notifications/docs/getting-started#register-for-notification-events

Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion) => {
      console.log(`Notification received in foreground: ${notification.title} : ${notification.body}`);
      completion({alert: false, sound: false, badge: false});
    });

Where it says

completion({alert: false, sound: false, badge: false});

You need to set to:

completion({alert: true, sound: false, badge: false});

alert:true still not working for me on 3.3.4
iOS 14.1

alert: true is not working for me neither

@harveyconnor any idea why this would be failing?

using 3.2.1 with iOS 13.6

no idea sorry

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daominhsangvn picture daominhsangvn  路  6Comments

veedeo picture veedeo  路  6Comments

ghost picture ghost  路  3Comments

puremana picture puremana  路  5Comments

codoffer picture codoffer  路  5Comments