JavaJava V4 Mobile Push API Reference for Realtime Apps

PubNub's Mobile Push Gateway feature enables developers to bridge native PubNub publishing with 3rd-party push notification services including Google Android GCM (Google Cloud Messaging)/FCM (Firebase Cloud Messaging), Apple iOS APNs (Apple Push Notification service), and Microsoft Windows Phone MPNS (Microsoft Push Notification Service).

By using the Mobile Push Gateway, developers can eliminate the need for developing, configuring, and maintaining additional server-side components for third-party push notification providers.

Learn more about our Mobile Push Gateway here.


Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Enable push notifications on provided set of channels.
To run Adding Device to Channel you can use the following method(s) in the Java V4 SDK
  1. ParameterTypeRequiredDescription
    pushTypePNPushTypeYesAccepted values: PNPushType.FCM, PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS, PNPushType.APNS2
    channelsList<String>YesAdd push notifications on the specified channels.
    deviceIdStringYesThe device ID (token) to associate with push notifications.
    topicStringOptionalNotifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2.
    environmentPNPushEnvironmentOptionalEnvironment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2).
    asyncPNCallback<PNPushAddChannelResult>OptionalPNCallback of type PNPushAddChannelResult.
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.
		}
	});
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().

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Request for all channels on which push notification has been enabled using specified pushToken.
To run Listing Channels For Device you can use the following method(s) in the Java V4 SDK
  1. ParameterTypeRequiredDescription
    pushTypePNPushTypeYesAccepted values: PNPushType.FCM, PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS, PNPushType.APNS2
    deviceIdStringYesThe device ID (token) to associate with push notifications.
    topicStringOptionalNotifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2.
    environmentPNPushEnvironmentOptionalEnvironment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2).
    asyncPNCallback<PNPushListProvisionsResult>OptionalPNCallback of type PNPushListProvisionsResult.
pubnub.auditPushChannelProvisions()
	.deviceId("googleDevice")
	.pushType(PNPushType.FCM)
	.async(new PNCallback<PNPushListProvisionsResult>() {
		@Override
		public void onResponse(PNPushListProvisionsResult result, PNStatus status) {
		
		}
	});
The auditPushChannelProvisions() operation returns a PNPushListProvisionsResult which contains the following operations:
MethodTypeDescription
getChannels() List<String>List of channels associated for push notifications.

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications on provided set of channels.
To run Removing Device From Channel you can use the following method(s) in the Java V4 SDK
  1. ParameterTypeRequiredDescription
    pushTypePNPushTypeYesAccepted values: PNPushType.FCM, PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS, PNPushType.APNS2
    channelsList<String>YesAdd push notifications on the specified channels.
    deviceIdStringYesThe device ID (token) to associate with push notifications.
    topicStringOptionalNotifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2.
    environmentPNPushEnvironmentOptionalEnvironment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2).
    asyncPNCallback<PNPushRemoveChannelResult>OptionalPNCallback of type PNPushRemoveChannelResult.
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) {
		
		}
	});
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().

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications from all channels registered with the specified pushToken.
To run Remove all push notifications you can use the following method(s) in the Java V4 SDK
  1. ParameterTypeRequiredDescription
    pushTypePNPushTypeYesAccepted values: PNPushType.FCM, PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS, PNPushType.APNS2
    deviceIdStringYesThe device ID (token) to associate with push notifications.
    topicStringOptionalNotifications topic name (usually it is bundle identifier of application for Apple platform). Required only if pushType set to APNS2.
    environmentPNPushEnvironmentOptionalEnvironment within which device should manage list of channels with enabled notifications (works only if pushType set to APNS2).
    asyncPNCallback<PNPushRemoveAllChannelsResult>OptionalPNCallback of type PNPushRemoveAllChannelsResult.
pubnub.removeAllPushNotificationsFromDeviceWithPushToken()
    .deviceId("googleDevice")
    .pushType(PNPushType.FCM)
    .async(new PNCallback<PNPushRemoveAllChannelsResult>() {
        @Override
        public void onResponse(PNPushRemoveAllChannelsResult result, PNStatus status) {
            
        }
    });
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().