When a push notification is received by the device, the application can be in one of the following states:
- Foreground: When the app is running and is used by the user right now; in this case, a
notificationReceivedForegroundevent will be fired, do not forget to invoke
notificationReceivedBackgroundevent will be fired, do not forget to invoke
completion()callback. To receive background notifications on iOS follow this guide
Finally, when a notification is opened by the device user (i.e. tapped-on), a
notificationOpened event is fired, here as well you need to remember invoking
When you receive a push notification, you'll get an instance of Notification object, contains the following methods:
Querying initial notification
PushNotificationsIOS.getInitialNotification() allows for the async retrieval of the original notification used to open the App on iOS, but it has no equivalent implementation for Android.
Notifications are considered 'initial' under the following terms:
- User tapped on a notification, AND -
- App was either not running at all ("dead" state), OR it existed in the background with no running activities associated with it.