Mobile Push Notifications API for PubNub Ruby 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 Ruby SDK:
pubnub.add_channels_to_push(
push_token: push_token,
push_gateway: push_gateway,
channel: channel,
topic: topic,
environment: environment,
auth_key: auth_key,
http_sync: http_sync,
callback: callback
)
Parameter | Type | Required | Description |
---|---|---|---|
push_token | String | Yes | Device ID. |
push_gateway | String | Yes | Back end to use. Accepted values are: gcm , and apns2 . |
channel | String | Yes | Comma-separated list of channels to add. |
topic | String | No | Bundle ID of the mobile application. Required only if push_gateway is set to apns2 . |
environment | String | No | Environment of the mobile application. Required only if push_gateway is set to apns2 .Defaults to development . Set it to either development or production . |
auth_key | String | No | Access Manager authorization key. Required only if Access Manager is enabled. |
http_sync | Boolean | No | If set to false , the method executes asynchronously and returns a Future . To get its value, use the value method. If set to true , the method returns an array of envelopes (even if there's only one). For synchronous methods, the envelope object is returned. Defaults to false . |
callback | Lambda accepting one parameter | No | Callback called for each envelope . For asynchronous methods, a Future is returned. To get its value, use the value method. The thread will be locked until value is returned. |
Basic Usage
Add Device to Channel
# for FCM/GCM
pubnub.add_channels_to_push(
push_token: 'push_token',
push_gateway: 'gcm',
channel: 'channel1,channel2'
) do |envelope|
puts envelope
end
# for APNS2
pubnub.add_channels_to_push(
push_token: 'push_token',
push_gateway: 'apns2',
channel: 'channel1,channel2',
topic: 'myapptopic',
show all 19 linesResponse
#<Pubnub::Envelope
@result = {
:code => 200,
:operation => :add_channels_to_push,
:data => [1, "Modified Channels"]
},
@status = {
:code => 200,
:category => :ack,
:error => false,
}
>
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 Ruby SDK:
pubnub.list_push_provisions(
push_token: push_token,
push_gateway: push_gateway,
topic: topic,
environment: environment,
auth_key: auth_key,
http_sync: http_sync,
callback: callback
)
Parameter | Type | Required | Description |
---|---|---|---|
push_token | String | Yes | Device ID. |
push_gateway | String | Yes | Back end to use. Accepted values are: gcm , and apns2 . |
topic | String | No | Bundle ID of the mobile application. Required only if push_gateway is set to apns2 . |
environment | String | No | Environment of the mobile application. Required only if push_gateway is set to apns2 .Defaults to development . Set it to either development or production . |
auth_key | String | No | Access Manager authorization key. Required only if Access Manager is enabled. |
http_sync | Boolean | No | If set to false , the method executes asynchronously and returns a Future . To get its value, use the value method. If set to true , the method returns an array of envelopes (even if there's only one). For synchronous methods, the envelope object is returned. Defaults to false . |
callback | Lambda accepting one parameter | No | Callback called for each envelope . For asynchronous methods, a Future is returned. To get its value, use the value method. The thread will be locked until value is returned. |
Basic Usage
List Channels For Device
# for FCM/GCM
pubnub.list_push_provisions(
push_token: 'push_token',
type: 'gcm'
) do |envelope|
puts envelope
end
# for APNS2
pubnub.list_push_provisions(
push_token: 'push_token',
type: 'apns2',
topic: 'myapptopic'
environment: 'development'
) do |envelope|
show all 17 linesResponse
#<Pubnub::Envelope
@result = {
:code => 200,
:operation => :list_push_provisions,
:data => ["channel1", "channel2"]
},
@status = {
:code => 200,
:category => :ack,
:error => false,
}
>
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.
Disable mobile push notifications on provided set of channels. If nil
will be passed as channels then client will remove mobile push notifications from all channels which associated with pushToken
.
Method(s)
To run Removing Device From Channel
you can use the following method(s) in the Ruby SDK:
pubnub.remove_channels_from_push(push_token: push_token, push_gateway: push_gateway, channel: channel, topic: topic, environment: environment, auth_key: auth_key, http_sync: http_sync, callback: callback)
Parameter | Type | Required | Description |
---|---|---|---|
push_token | String | Yes | Device ID. |
push_gateway | String | Yes | Back end to use. Accepted values are: gcm , and apns2 . |
channel | String | Yes | Comma-separated list of channels to add. |
topic | String | No | Bundle ID of the mobile application. Required only if push_gateway is set to apns2 . |
environment | String | No | Environment of the mobile application. Required only if push_gateway is set to apns2 .Defaults to development . Set it to either development or production . |
auth_key | String | No | Access Manager authorization key. Required only if Access Manager is enabled. |
http_sync | Boolean | No | If set to false , the method executes asynchronously and returns a Future . To get its value, use the value method. If set to true , the method returns an array of envelopes (even if there's only one). For synchronous methods, the envelope object is returned. Defaults to false . |
callback | Lambda accepting one parameter | No | Callback called for each envelope . For asynchronous methods, a Future is returned. To get its value, use the value method. The thread will be locked until value is returned. |
Basic Usage
Remove Device From Channel
# for FCM/GCM
pubnub.remove_channels_from_push(
push_token: 'push_token',
remove: 'channel1,channel2',
type: 'gcm'
) do |envelope|
puts envelope
end
# for APNS2
pubnub.remove_channels_from_push(
push_token: 'push_token',
remove: 'channel1,channel2',
type: 'apns2',
topic: 'myapptopic',
show all 19 linesResponse
#<Pubnub::Envelope
@result = {
:code => 200,
:operation => :remove_channels_from_push,
:data => [1, "Modified Channels"]
},
@status = {
:code => 200,
:category => :ack,
:error => false,
}
>
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 Ruby SDK:
pubnub.remove_device_from_push(
push_token: push_token,
push_gateway: push_gateway,
topic: topic,
environment: environment,
auth_key: auth_key,
http_sync: http_sync,
callback: callback
)
Parameter | Type | Required | Description |
---|---|---|---|
push_token | String | Yes | Device ID. |
push_gateway | String | Yes | Back end to use. Accepted values are: gcm , and apns2 . |
topic | String | No | Bundle ID of the mobile application. Required only if push_gateway is set to apns2 . |
environment | String | No | Environment of the mobile application. Required only if push_gateway is set to apns2 .Defaults to development . Set it to either development or production . |
auth_key | String | No | Access Manager authorization key. Required only if Access Manager is enabled. |
http_sync | Boolean | No | If set to false , the method executes asynchronously and returns a Future . To get its value, use the value method. If set to true , the method returns an array of envelopes (even if there's only one). For synchronous methods, the envelope object is returned. Defaults to false . |
callback | Lambda accepting one parameter | No | Callback called for each envelope . For asynchronous methods, a Future is returned. To get its value, use the value method. The thread will be locked until value is returned. |
Basic Usage
Remove all mobile push notifications
# for FCM/GCM
pubnub.remove_device_from_push(
push_token: 'push_token',
type: 'gcm'
) do |envelope|
puts envelope
end
# for APNS2
pubnub.remove_device_from_push(
push_token: 'push_token',
type: 'apns2',
topic: 'myapptopic'
environment: 'development'
) do |envelope|
show all 17 linesResponse
#<Pubnub::Envelope
@result = {
:code => 200,
:operation => :remove_device_from_push,
:data => [1, "Modified Channels"]
},
@status = {
:code => 200,
:category => :ack,
:error => false,
}
>