wix / react-native-notifications

React Native Notifications
MIT License
3.23k stars 763 forks source link

postLocalNotification in the foreground doesn't display notification banner on iOS and Android. #863

Closed 826505523 closed 2 years ago

826505523 commented 2 years ago
let localNotification = Notifications.postLocalNotification({
    identifier: "1",
    title: "Local Notification Title",
    body: "Local Notification Body",
    sound: "chime.aiff",
    bage: 1,
    type: "notice",
    thread: "1",
    payload: {},
});

When I send a local notification as shown above, the notification banner will not pop up when the app is in the foreground. iOS doesn't execute completion block, completion({ alert: true, sound: true, badge: true }) is not effective. Android also didn't pop up for unknown reasons!

let localNotification = Notifications.postLocalNotification({
    identifier: undefined,
    title: "Local Notification Title",
    body: "Local Notification Body",
    sound: "chime.aiff",
    bage: 1,
    type: "notice",
    thread: "1",
    payload: {},
});

But when I changed the identifier to undefined as shown above, something magical happened. Both iOS and Android can pop up notification banners in the foreground normally.

The identifier has no effect on controlling the application to display banners in the foreground, so I think it may be a bug. I hope developers can pay attention to it and fix it as soon as possible. God bless and thank you all so much!

DanielEliraz commented 2 years ago

Cannot reproduce. The important thing is the Pop on Screen option in android settings and the equivalent banner in iOS, check it: https://www.bestusefultips.com/wp-content/uploads/2021/04/How-to-Turn-Off-Pop-up-Notifications-on-Android-11.jpg