Mobile Push Notifications API for PubNub Go 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 a provided set of channels.
Method(s)
To run Adding Device to Channel
you can use the following method(s) in the Go SDK:
pn.AddPushNotificationsOnChannels().
Channels([]string).
DeviceIDForPush(string).
PushType(PNPushTypeGCM|PNPushTypeAPNS2).
Topic(string).
Environment(PNPushEnvironment).
QueryParam(map[string]string).
Execute()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Channels | []string | Yes | channels to add to the channel group | |
DeviceIDForPush | string | Yes | Device ID. | |
PushType | PNPushTypeGCM PNPushTypeAPNS2 PNPushTypeFCM | Yes | Not set | Accepted values: PNPushTypeGCM , PNPushTypeAPNS2 , PNPushTypeFCM . |
Topic | string | Yes if PNPushType is PNPushTypeAPNS2 | Not set | Notifications topic name (usually it is application's bundle identifier). |
Environment | PNPushEnvironment | No | PNPushEnvironmentDevelopment | Works only if PNPushType set to PNPushTypeAPNS2 . Accepted values: PNPushEnvironmentDevelopment , PNPushEnvironmentProduction . |
QueryParam | map[string]string | Optional | QueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API. |
Basic Usage
Add Device to Channel
//GCM/FCM
pn.AddPushNotificationsOnChannels().
Channels([]string{"ch1"}).
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeGCM).
Execute()
//APNs2
pn.AddPushNotificationsOnChannels().
Channels([]string{"ch1"}).
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeAPNS2).
Topic("com.example.bundle_id").
Environment(pubnub.PNPushEnvironmentProduction).
Execute()
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.Error
.
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 Go SDK:
pn.ListPushProvisions().
DeviceIDForPush(string).
PushType(PNPushTypeGCM| PNPushTypeAPNS2).
Topic(string).
Environment(PNPushEnvironment).
QueryParam(map[string]string).
Execute()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
DeviceIDForPush | string | Yes | Device ID. | |
PushType | PNPushTypeGCM PNPushTypeAPNS2 PNPushTypeFCM | Yes | Not set | Accepted values: PNPushTypeGCM , PNPushTypeAPNS2 , PNPushTypeFCM . |
Topic | string | Yes if PNPushType is PNPushTypeAPNS2 | Not set | Notifications topic name (usually it is application's bundle identifier). |
Environment | PNPushEnvironment | No | PNPushEnvironmentDevelopment | Works only if PNPushType set to PNPushTypeAPNS2 . Accepted values: PNPushEnvironmentDevelopment , PNPushEnvironmentProduction . |
QueryParam | map[string]string | Optional | QueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API. |
Basic Usage
List Channels For Device
// GCM/FCM
pn.ListPushProvisions().
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeGCM).
Execute()
// APNS2
pn.ListPushProvisions().
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeAPNS2).
Topic("com.example.bundle_id").
Environment(pubnub.PNPushEnvironmentProduction).
Execute()
Returns
The ListPushProvisions()
operation returns a ListPushProvisionsRequestResponse
which contains the following operations:
Method | Type | Description |
---|---|---|
Channels | []string | List of channels associated for mobile push notifications. |
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 a provided set of channels.
Method(s)
To run Removing Device From Channel
you can use the following method(s) in the Go SDK:
pn.RemovePushNotificationsFromChannels().
Channels([]string).
DeviceIDForPush(string).
PushType(PNPushTypeGCM|PNPushTypeAPNS2).
Topic(string).
Environment(PNPushEnvironment).
QueryParam(map[string]string).
Execute()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Channels | []string | Yes | channels to add to the channel group | |
DeviceIDForPush | string | Yes | Device ID. | |
PushType | PNPushTypeGCM PNPushTypeAPNS PNPushTypeAPNS2 PNPushTypeFCM | Yes | Not set | Accepted values: PNPushTypeGCM , PNPushTypeAPNS2 , PNPushTypeFCM . |
Topic | string | Yes if PNPushType is PNPushTypeAPNS2 | Not set | Notifications topic name (usually it is application's bundle identifier). |
Environment | PNPushEnvironment | No | PNPushEnvironmentDevelopment | Works only if PNPushType set to PNPushTypeAPNS2 . Accepted values: PNPushEnvironmentDevelopment , PNPushEnvironmentProduction . |
QueryParam | map[string]string | Optional | QueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API. |
Basic Usage
Remove Device From Channel
// FCM/GCM
pn.RemovePushNotificationsFromChannels().
Channels([]string{"ch"}).
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeGCM).
Execute()
// APNS2
pn.RemovePushNotificationsFromChannels().
Channels([]string{"ch"}).
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeAPNS2).
Topic("com.example.bundle_id").
Environment(pubnub.PNPushEnvironmentProduction).
Execute()
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.Error
.
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 Go SDK:
pn.RemoveAllPushNotifications().
DeviceIDForPush(string).
PushType(PNPushTypeGCM| PNPushTypeAPNS2).
Topic(string).
Environment(PNPushEnvironment).
QueryParam(map[string]string).
Execute()
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
DeviceIDForPush | string | Yes | Device ID. | |
PushType | PNPushTypeGCM PNPushTypeAPNS PNPushTypeAPNS2 PNPushTypeFCM | Yes | Not set | Accepted values: PNPushTypeGCM , PNPushTypeAPNS2 , PNPushTypeFCM . |
Topic | string | Yes if PNPushType is PNPushTypeAPNS2 | Not set | Notifications topic name (usually it is application's bundle identifier). |
Environment | PNPushEnvironment | No | PNPushEnvironmentDevelopment | Works only if PNPushType set to PNPushTypeAPNS2 . Accepted values: PNPushEnvironmentDevelopment , PNPushEnvironmentProduction . |
QueryParam | map[string]string | Optional | QueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API. |
Basic Usage
Remove all mobile push notifications
// FCM/GCM
pn.RemoveAllPushNotifications().
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeGCM).
Execute()
// APNS2
pn.RemoveAllPushNotifications().
DeviceIDForPush("device_id").
PushType(pubnub.PNPushTypeAPNS2).
Topic("com.example.bundle_id").
Environment(pubnub.PNPushEnvironmentProduction).
Execute()
Returns
The RemoveAllPushNotifications()
does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.Error
.