UnityUnity V4 Misc API Reference for Realtime Apps


These docs are for PubNub 4.x for Unity which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.x for Unity.

If you have questions about the PubNub for Unity SDK, please contact us at support@pubnub.com.

Destroy frees up the threads and allows for clean exit.
  1. CleanUp()
Call the reconnect method to force the SDK to try and reach out PubNub.
To reconnect the data you can use the following method(s) in Unity V4 SDK.
  1. Reconnect()
This function will return a 17 digit precision Unix epoch.
The timetoken is constructed using the following algorithm:
timetoken = (Unix epoch time in seconds) * 10000000
Example of creating a timetoken for a specific time & date
08/19/2013 @ 9:20pm in UTC = 1376961606
timetoken = 1376961606 * 10000000
timetoken = 13769616060000000
To fetch Time you can use the following method(s) in Unity V4 SDK
  1. ParameterTypeRequiredDescription
    AsyncPNCallbackYesPNCallback of type PNTimeResult
	.Async((result, status) => {              
		if (status.Error) {
			Debug.Log(string.Format("Time Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
		} else {
			Debug.Log(string.Format("DateTime {0}, In Example, result: {1}", DateTime.UtcNow ,result.TimeToken));
The Time() operation returns a PNTimeResult which contains the following operations:
TimetokenlongReturns a long representation of current time token.