Mobile Push Notifications API for PubNub Java SDK
Mobile Push Notifications feature enables developers to bridge native PubNub publishing with 3rd-party push notification services including Google Android FCM (Firebase Cloud Messaging) and Apple iOS APNs (Apple Push Notification service).
By using the Mobile Push Notifications feature, developers can eliminate the need for developing, configuring, and maintaining additional server-side components for third-party push notification providers.
To learn more, read about Mobile Push Notifications.
Adding Device to Channel
Requires Mobile Push Notifications add-on
This method requires that the Mobile Push Notifications add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
Description
Enable mobile push notifications on provided set of channels.
Method(s)
To run Adding Device to Channel
you can use the following method(s) in the Java V4 SDK:
pubnub.addPushNotificationsOnChannels()
.pushType(PNPushType)
.channels(List<String>)
.deviceId(String)
.topic(String)
.environment(PNPushEnvironment)
Parameter | Type | Required | Description |
---|---|---|---|
pushType | PNPushType | Yes | Accepted values: PNPushType.FCM , PNPushType.GCM , PNPushType.APNS , PNPushType.APNS2 |
channels | List<String> | Yes | Add mobile push notifications on the specified channels. |
deviceId | String | Yes | The device ID (token) to associate with mobile push notifications. |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2 . |
environment | PNPushEnvironment | Optional | Environment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2 ). |
async | PNCallback<PNPushAddChannelResult> | Optional | PNCallback of type PNPushAddChannelResult . |
Basic Usage
Adding Device to Channel
pubnub.addPushNotificationsOnChannels()
.pushType(PNPushType.FCM)
.channels(Arrays.asList("ch1", "ch2", "ch3"))
.deviceId("googleDevice")
.async(new PNCallback<PNPushAddChannelResult>() {
@Override
public void onResponse(PNPushAddChannelResult result, PNStatus status) {
// handle response.
}
});
Returns
The addPushNotificationsOnChannels()
does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError()
.
Listing Channels For Device
Requires Mobile Push Notifications add-on
This method requires that the Mobile Push Notifications add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
Description
Request for all channels on which push notification has been enabled using specified pushToken.
Method(s)
To run Listing Channels For Device
you can use the following method(s) in the Java V4 SDK:
pubnub.auditPushChannelProvisions()
.pushType(PNPushType)
.deviceId(String)
.topic(String)
.environment(PNPushEnvironment)
Parameter | Type | Required | Description |
---|---|---|---|
pushType | PNPushType | Yes | Accepted values: PNPushType.FCM , PNPushType.GCM , PNPushType.APNS , PNPushType.APNS2 |
deviceId | String | Yes | The device ID (token) to associate with mobile push notifications. |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2 . |
environment | PNPushEnvironment | Optional | Environment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2 ). |
async | PNCallback<PNPushListProvisionsResult> | Optional | PNCallback of type PNPushListProvisionsResult . |
Basic Usage
Listing Channels For Device
pubnub.auditPushChannelProvisions()
.deviceId("googleDevice")
.pushType(PNPushType.FCM)
.async(new PNCallback<PNPushListProvisionsResult>() {
@Override
public void onResponse(PNPushListProvisionsResult result, PNStatus status) {
}
});
Returns
The auditPushChannelProvisions()
operation returns a PNPushListProvisionsResult
which contains the following operations:
Method | Type | Description |
---|---|---|
getChannels() | List<String> | List of channels associated for mobile push notifications. |
Removing Device From Channel
Requires Mobile Push Notifications add-on
This method requires that the Mobile Push Notifications add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
Description
Disable mobile push notifications on provided set of channels.
Method(s)
To run Removing Device From Channel
you can use the following method(s) in the Java V4 SDK:
pubnub.removePushNotificationsFromChannels()
.pushType(PNPushType)
.deviceId(String)
.topic(String)
.environment(PNPushEnvironment)
Parameter | Type | Required | Description |
---|---|---|---|
pushType | PNPushType | Yes | Accepted values: PNPushType.FCM , PNPushType.GCM , PNPushType.APNS , PNPushType.APNS2 |
channels | List<String> | Yes | Add mobile push notifications on the specified channels. |
deviceId | String | Yes | The device ID (token) to associate with mobile push notifications. |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2 . |
environment | PNPushEnvironment | Optional | Environment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2 ). |
async | PNCallback<PNPushRemoveChannelResult> | Optional | PNCallback of type PNPushRemoveChannelResult . |
Basic Usage
Removing Device From Channel
pubnub.removePushNotificationsFromChannels()
.deviceId("googleDevice")
.channels(Arrays.asList("ch1", "ch2", "ch3"))
.pushType(PNPushType.FCM)
.async(new PNCallback<PNPushRemoveChannelResult>() {
@Override
public void onResponse(PNPushRemoveChannelResult result, PNStatus status) {
}
});
Returns
The removePushNotificationsFromChannels()
does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError()
.
Remove all mobile push notifications
Requires Mobile Push Notifications add-on
This method requires that the Mobile Push Notifications add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
Description
Disable mobile push notifications from all channels registered with the specified pushToken.
Method(s)
To run Remove all mobile push notifications
, you can use the following method(s) in the Java V4 SDK:
pubnub.removeAllPushNotificationsFromDeviceWithPushToken()
.pushType(PNPushType)
.deviceId(String)
.topic(String)
.environment(PNPushEnvironment)
Parameter | Type | Required | Description |
---|---|---|---|
pushType | PNPushType | Yes | Accepted values: PNPushType.FCM , PNPushType.GCM , PNPushType.APNS , PNPushType.APNS2 |
deviceId | String | Yes | The device ID (token) to associate with mobile push notifications. |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2 . |
environment | PNPushEnvironment | Optional | Environment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2 ). |
async | PNCallback<PNPushRemoveAllChannelsResult> | Optional | PNCallback of type PNPushRemoveAllChannelsResult . |
Basic Usage
Remove all mobile push notifications
pubnub.removeAllPushNotificationsFromDeviceWithPushToken()
.deviceId("googleDevice")
.pushType(PNPushType.FCM)
.async(new PNCallback<PNPushRemoveAllChannelsResult>() {
@Override
public void onResponse(PNPushRemoveAllChannelsResult result, PNStatus status) {
}
});
Returns
The removeAllPushNotificationsFromDeviceWithPushToken()
does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError()
.