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)

Pubnub.CleanUp()

Sample code

Reference code

This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.


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.

Disconnect<T>()

This method doesn't take any arguments.

Sample code


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:

List<string> GetSubscribedChannelGroups()

Sample code

Get subscribed channel groups


Response

List<String>

["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:

List<string> GetSubscribedChannels()

Sample code

Get subscribed channels


Response

List<String>

["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.

Reconnect<T>(bool resetSubscribeToken)
* required
ParameterDescription
resetSubscribeToken
Type: bool
Passing true will send zero timetoken upon reconnect.

Sample code


Create push payload

This method creates the push payload for use in the appropriate endpoint calls.

Method(s)

CreatePushPayloadHelper()
.SetAPNSPayload(PNAPSData, List<PNAPNS2Data>)
.SetFCMPayload(PNFCMData)
.SetCommonPayload(Dictionary<string, object>)
.BuildPayload()
* required
ParameterDescription
SetAPNSPayload
Type: 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.
SetFCMPayload
Type: PNFCMData
Set FCM Payload. Associated FCM devices will receive only the data within the pn_gcm key.
SetCommonPayload
Type: Dictionary<string, object>
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 Dictionary<string, object>

Sample code

Create push payload


Response

The CreatePushPayloadHelper() operation returns a Dictionary<string, object> which can be passed directly to the Publish Method's Message parameter.

Last updated on