React-native-onesignal: How to check if there are unread messages when the app starts?

Created on 22 Oct 2019  路  5Comments  路  Source: OneSignal/react-native-onesignal

Description:

I'm implementing push notification using OneSignal SDK. All notifications are received from OneSignal Dashboard on when it's in foreground, background, closed status.
The problem is - when the app is closed, then the new notification is received from Dashboard, the user clicks the app, it runs, but it doesn't return any unread messages.
How can the app checks if there are new messages?
If the user clicks the notification from the iOS notification center, the app runs and opened listener is fired with that notification info.

Environment

  • "react": "16.8.3",
  • "react-native": "0.59.9",
  • "react-native-onesignal": "^3.4.2",
  • npm
  • XCode 11.1(iOS - 13.1)
  • Steps to Reproduce Issue:

    1. install the sdk using https://documentation.onesignal.com/docs/react-native-sdk-setup
    2. Added OneSignalNotificationServiceExtension
    3. added listener on the App.js(root component)
       OneSignal.addEventListener('received', this.onReceivedOneSignal);
       OneSignal.addEventListener('opened', this.onOpenedOneSignal);
       OneSignal.addEventListener('ids', this.onOneSignalIds);
    
    Enhancement / Feature Question

    All 5 comments

    The problem is - when the app is closed, then the new notification is received from Dashboard, the user clicks the app, it runs, but it doesn't return any unread messages.

    What exactly do you mean "it" doesn't return any unread messages? Are you talking about in the callback to the opened event?

    @rgomezp , Yes, if the user clicks the app, the app is running, but opened event doesn't return any unread messages when the app starts.

    Same here. If I clear my notification, when I open the app I can't get the notification. Can I get all notification history?

    This is more of a feature request. Currently, you have to track this yourself. Perhaps in the future, we will add this to the callback or as a mailbox. Thanks for showing your interest in this feature. I will take a note of it and track internally

    Hi, any update on this one? Will it be implemented in the near future, or not? I would really appreciate this feature.

    Was this page helpful?
    0 / 5 - 0 ratings