Reputation: 445
I entegrated my flutter app with onesignal, and it's working perfect when app is in background, but in foreground it's receiving notification but not showing it any idea why?
log
flutter: OSNotificationReceivedEvent complete with notification: Instance of 'OSNotification'
VERBOSE: finishProcessingNotification: Fired!
VERBOSE: Notification display type: 7
VERBOSE: notificationReceived called! opened: NO
VERBOSE: finishProcessingNotification: call completionHandler with options: 7
Foreground handler
OneSignal.shared.setNotificationWillShowInForegroundHandler(
(OSNotificationReceivedEvent event) {
event.complete(event.notification);
});
Upvotes: 6
Views: 3052
Reputation: 1607
By default foreground notifications are not displayed. If you want OneSignal to force display the notification you need to add a listener to foreground events and then call the display method.
You need SDK version 4 to do this.
I attached react-native typescript example below:
OneSignal.Notifications.addEventListener('foregroundWillDisplay',
(event: NotificationWillDisplayEvent) => {
event.notification.display()
})
Upvotes: 0