Utility Methods API for Unity SDK
The methods on this page are utility methods that don't fit into other categories.
Cleanup
Cleanup frees up the threads and allows for clean exit.
Method(s)
1Pubnub.CleanUp()
Sample code
Reference code
1
Returns
None
Disconnect
Call the Disconnect method to force the SDK to stop all requests to PubNub server when there are active subscribe channels.
Method(s)
To disconnect the data transmission you can use the following method(s) in Unity SDK.
1Disconnect<T>()
This method doesn't take any arguments.
Sample code
1
Get subscribed channel groups
Returns all the subscribed channel groups in a List of type String.
Method(s)
To Get Subscribe Channel Groups you can use the following method(s) in the Unity SDK:
1List<string> GetSubscribedChannelGroups()
Sample code
Get subscribed channel groups
1
Response
List<String>
1["channelGroup1", "channelGroup2"]
Get subscribed channels
Returns all the subscribed channels in a List of type String.
Method(s)
To Get Subscribed Channels you can use the following method(s) in the Unity SDK:
1List<string> GetSubscribedChannels()
Sample code
Get subscribed channels
1
Response
List<String>
1["channel1", "channel2"]
Reconnect
Call the reconnect method to force the SDK to try and reach out PubNub.
Method(s)
To reconnect the data you can use the following method(s) in Unity SDK.
1Reconnect<T>(bool resetSubscribeToken)
| Parameter | Description |
|---|---|
resetSubscribeTokenType: bool | Passing true will send zero timetoken upon reconnect. |
Sample code
1
Create push payload
This method creates the push payload for use in the appropriate endpoint calls.
Method(s)
1CreatePushPayloadHelper()
2 .SetAPNSPayload(PNAPSData, List<PNAPNS2Data>)
3 .SetFCMPayload(PNFCMData)
4 .SetCommonPayload(Dictionary<string, object>)
5 .BuildPayload()
| Parameter | Description |
|---|---|
SetAPNSPayloadType: PNAPSData | Set APNS Payload. Associated APNS devices will receive only the data within the pn_apns key. |
Type: List<PNAPNS2Data> | Set APNS2 Payload. Associated APNS devices will receive only the data within the pn_push key. |
SetFCMPayloadType: PNFCMData | Set FCM Payload. Associated FCM devices will receive only the data within the pn_fcm key. |
SetCommonPayloadType: Dictionary<string, object> | Set Common Payload. Native PubNub subscribers will receive the entire object literal, including the pn_apns, pn_fcm, and common payload. |
BuildPayload *Type: | Builds the payload from the values set using the parameters. Returns a Dictionary<string, object> |
Sample code
Create push payload
1
Response
The CreatePushPayloadHelper() operation returns a Dictionary<string, object> which can be passed directly to the Publish Method's Message parameter.