To use push notifications on PubNub, you first need to register and configure your account with the push notification provider, either FCM or APNs.
Configure Account for Mobile Push Notifications
Mobile Push Gateway provides a method to send messages quickly and reliably via PubNub whether or not the application is in the foreground or background.
How It Works
When the Mobile Push Gateway is enabled, you can associate unique mobile devices (via their device push tokens) with PubNub channel names. Then, when a message is published to a channel that has been associated with an FCM or APNs device, all associated FCM and APNs devices will receive that message via their associated (FCM or APNs) native service.
Behind the scenes, the PubNub Mobile Push Gateway establishes an authenticated connection to FCM or APNs service providers based on your registered configuration.
Enabling Mobile Push Notifications
First step is to enable Mobile Push Notifications for your API keys in your PubNub Dashboard account.
- Login to the Admin Portal
- Select the PubNub API Key (or create a new Key)
- Enable the Mobile Push Notifications add-on
Google (FCM) Push Notification Configuration
Before you can use PubNub Mobile Push Gateway with FCM, you must first setup your FCM configuration.
Google Firebase/Android Configuration Steps
- Create a Firebase Project on the Firebase console.
- Click Add Firebase to your Android app and follow the steps there.
- Go to Project settings (Click the gear icon at the top left, next to Project overview).
- Click the Cloud messaging tab and find the Server key there.
PubNub Dashboard FCM Configuration Steps
Once you've obtained the API Key, you're ready to configure your PubNub API keys. In the Mobile Push Notifications add-on of your PubNub API keys:
- Scroll to the Firebase Cloud Messaging section.
- Add FCM API Key.
- Click Save Changes.
Apple (APNs) Push Notification Configuration
Please refer to the formal Apple iOS documentation on how to configure your iOS app for push notifications, in your Apple Developer account, to get the required artifacts needed to configure your PubNub API keys for APNs.
Apple iOS Developer App Configuration Steps
To use the Mobile Push Gateway and Apple's APNs, using tokens, you need:
- A valid Auth Key file for an iOS app which the Apple Push Notification Service is enabled
- The Key ID of the Auth Key
- Your Team ID associated with the Apple Developer Account which owns the Auth Key
- All the Bundle IDs associated with the Applications to which you'll send Push notifications (often you'll only be using a single Bundle ID)
- The environments associated with the Applications to which you'll send Push notifications
PubNub Dashboard Steps - APNs
Once you have the required artifacts from above, you're ready to configure your PubNub API keys. In the Mobile Push Notifications add-on of your PubNub API keys:
- Click Upload token file.
- Navigate the file system to locate the Key file. This is the Auth Key file you downloaded through the Apple Developer Program site. Click Choose.
- Enter Team ID and Auth Key ID for the Key and Apple Developer account.
- Click Save Changes.
Now your PubNub keys are configured so that your app can send and receive Apple push notifications.