Utility Methods API for Go SDK
The methods on this page are utility methods that don't fit into other categories.
Create push payload
This method creates the push payload for use in the appropriate endpoint calls.
Method(s)
1CreatePushPayload().
2 SetAPNSPayload(pubnub.PNAPNSData,[]pubnub.PNAPNS2Data).
3 SetCommonPayload(map[string]interface{}).
4 SetFCMPayload(pubnub.PNFCMData).
5 BuildPayload()
* required
| Parameter | Description |
|---|---|
SetAPNSPayloadType: pubnub.PNAPNSData | Set APNS Payload. Associated APNS devices will receive only the data within the pn_apns key. |
SetAPNSPayloadType: []pubnub.PNAPNS2Data | Set APNS2 Payload. Associated APNS devices will receive only the data within the pn_push key. |
SetFCMPayloadType: pubnub.PNFCMData | Set FCM Payload. Associated FCM devices will receive only the data within the pn_gcm key. |
SetCommonPayloadType: map[string]interface | Set Common Payload. Native PubNub subscribers will receive the entire object literal, including the pn_apns, pn_gcm, and common payload. |
BuildPayload *Type: | Builds the payload from the values set using the parameters. Returns a map[string]interface{} |
Sample code
Create push payload
1
Response
The CreatePushPayload() operation returns a map[string]interface{} which can be passed directly to the Publish Method's Message parameter.