Mobile Push Notifications API for PubNub Vue 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.
Add Device to Channel
note
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.
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 Vue SDK:
pubnub.push.addChannels({Array channels, String device, String pushGateway, String environment, String topic},Function callback)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. | |
channels | Array | Yes | Specifies channel to associate with mobile push notifications. | |
device | String | Yes | The device ID to associate with mobile push notifications. | |
pushGateway | String | Yes | apns , apns2 or gcm . | |
environment | String | Optional | development | Environment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2 ). |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2 . | |
callback | Function | Optional | Executes on a successful/unsuccessful addChannels . |
Basic Usage
Add Device to Channel
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.push.addChannels(
{
channels: ['a', 'b'],
device: 'niceDevice',
pushGateway: 'apns' // apns, gcm,
},
function(status) {
if (status.error) {
console.log("operation failed w/ error:", status);
} else {
console.log("operation done!");
show all 18 linesResponse
{
error: false,
operation: 'PNPushNotificationEnabledChannelsOperation',
statusCode: 200
}
List Channels For Device
note
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.
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 Vue SDK:
pubnub.push.listChannels({String device, String pushGateway, String environment, String topic},Function callback)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. | |
device | String | Yes | The device ID to associate with mobile push notifications. | |
pushGateway | String | Yes | apns , apns2 or gcm . | |
environment | String | Optional | development | Environment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2 ). |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2 . | |
callback | Function | Optional | Executes on a successful/unsuccessful listChannels . |
Basic Usage
List Channels For Device
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.push.listChannels(
{
device: 'niceDevice',
pushGateway: 'apns' // apns, gcm
},
function(status, response) {
if (status.error) {
console.log("operation failed w/ error:", status);
return;
}
show all 21 linesResponse
// Example of status
{
error: false,
operation: 'PNPushNotificationEnabledChannelsOperation',
statusCode: 200
}
// Example of response
{
channels: [ 'a', 'b' ]
}
Remove Device From Channel
note
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 Vue SDK:
pubnub.push.removeChannels({Array channels, String device, String pushGateway, String environment, String topic},Function callback)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. | |
channels | Array | Yes | Specifies channel to associate with mobile push notifications. | |
device | String | Yes | The device ID to associate with mobile push notifications. | |
pushGateway | String | Yes | apns , apns2 or gcm . | |
environment | String | Optional | development | Environment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2 ). |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2 . | |
callback | Function | Optional | Executes on a successful/unsuccessful removeChannels . |
Basic Usage
Remove Device From Channel
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.push.removeChannels(
{
channels: ['a', 'b'],
device: 'niceDevice',
pushGateway: 'apns' // apns, gcm
},
function(status) {
if (status.error) {
console.log("operation failed w/ error:", status);
} else {
console.log("operation done!");
show all 18 linesResponse
{
error: false,
operation: 'PNPushNotificationEnabledChannelsOperation',
statusCode: 200
}
Remove all mobile push notifications
note
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.
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 Vue SDK:
pubnub.push.deleteDevice({String device, String pushGateway, String environment, String topic},Function callback)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. | |
device | String | Yes | The device ID to associate with mobile push notifications. | |
pushGateway | String | Yes | apns , apns2 or gcm . | |
environment | String | Optional | development | Environment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2 ). |
topic | String | Optional | Notifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2 . | |
callback | Function | Optional | Executes on a successful/unsuccessful deleteDevice . |
Basic Usage
Remove all mobile push notifications
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.push.deleteDevice(
{
device: 'niceDevice',
pushGateway: 'apns' // apns, gcm
},
function(status) {
if (status.error) {
console.log("operation failed w/ error:", status);
} else {
console.log("operation done!");
}
show all 17 linesResponse
{
error: false,
operation: 'PNPushNotificationEnabledChannelsOperation',
statusCode: 200
}