PubNub's Mobile Push Gateway enables you to easily integrate with third-party push notification services including FCM (Firebase Cloud Messaging) and APNS (Apple Push Notification Service).
Ideally, mobile clients would always be connected to the PubNub network to receive messages in real time. However, there are situations where this isn't possible (for example, when an app is closed or running in the background). The Mobile Push Gateway makes it easy to fall back to push notifications when the client isn't connected to PubNub.
When you publish a message containing a specially formatted payload (a key-value pair) for the appropriate notification service, PubNub recognizes the published message as a push notification payload, and hands the contents to the notification service (APNS or FCM), along with all the device tokens registered to receive push notifications on that channel.
Retrieving mobile device tokens
Before you can use either service, you must be registered to use the Firebase Cloud Messaging (FCM) or the Apple Push Notification Service (APNS).
Each device that runs your app has a unique device token, which you need to register to be able to send push notifications. You can obtain the token from your user's device using either your native app, or Cordova/PhoneGap with the Cordova Push plugin.
To retrieve an iOS device token, follow this Apple guide.
To retrieve an Android registration token, follow this Google guide.
Adding a device token to spaces
This method allows you to associate a device token with one or more channels.
Removing a device token from spaces
This method allows you to disassociate a device token from one or more channels.
Removing all notifications for a device token
This method allows you to unsubscribe a device token from all push notifications.