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()