UnityUnity V4 Mobile Push API Reference for Realtime Apps

Go to Storage & Playback


 

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.

Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Enable push notifications on provided set of channels.
To run Adding Device to Channel you can use the following method(s) in the Unity V4 SDK
  1. ParameterTypeRequiredDefaultsDescription
    ChannelsList<string>YesAdd push notifications on the specified channels.
    DeviceIdstringYesDevice id.
    PushTypePNPushTypeYesNot setAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackYesPNCallback of type PNPushAddChannelResult.
pubnub.AddPushNotificationsOnChannels()
	.Channels(new List<string>{"channel2"})
	.DeviceID(<deviceId>)
	.PushType(PNPushType.GCM)
	.Async((result, status) => {
		Debug.Log ("in AddPushNotificationsOnChannels");
		if(status.Error){
			Debug.Log (string.Format(" AddPushNotificationsOnChannels Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
		} else {
			Debug.Log (string.Format("DateTime {0}, In AddPushNotificationsOnChannels, result: {1}", DateTime.UtcNow, result.Message));
		}
	});
The AddPushNotificationsOnChannels() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.IsError().
Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Request for all channels on which push notification has been enabled using specified pushToken.
To run Listing Channels For Device you can use the following method(s) in the Unity V4 SDK
  1. ParameterTypeRequiredDefaultsDescription
    DeviceIDstringYesDevice id.
    PushTypePNPushTypeYesNot setAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackYesPNCallback of type PNPushAddChannelResult..
pubnub.AuditPushChannelProvisions()
	.DeviceID(<deviceId>)
	.PushType(PNPushType.GCM)
	.Async((result, status) => {
		Debug.Log ("in AuditPushChannelProvisions");
		if(status.Error){
			Debug.Log (string.Format(" AuditPushChannelProvisions Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
		} else {
			Debug.Log (string.Format("DateTime {0}, In AuditPushChannelProvisions, result: {1}", DateTime.UtcNow, (result.Channels!=null)?string.Join(",", result.Channels.ToArray()):""));	   
		}
	});
The AuditPushChannelProvisions() operation returns a PNPushListProvisionsResult which contains the following operations:
MethodTypeDescription
ChannelsList<string>List of channels subscribed for push notifications.
Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications on provided set of channels.
To run Removing Device From Channel you can use the following method(s) in the Unity V4 SDK
  1. ParameterTypeRequiredDefaultsDescription
    ChannelsList<string>YesRemove push notifications on the specified channels.
    DeviceIDstringYesDevice id.
    PushTypePNPushTypeYesNot setAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackYesPNCallback of type PNPushAddChannelResult.
pubnub.RemovePushNotificationsFromChannels()
	.Channels(new List<string> {
		"channel2"
	})
	.DeviceID(<deviceId>)
	.PushType(PNPushType.GCM)
	.Async((result, status) => {
		Debug.Log ("in RemovePushNotificationsFromChannels");
		if( status.Error ){
			Debug.Log(string.Format(" RemovePushNotificationsFromChannels Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
		} else {
		}
	});
The RemovePushNotificationsFromChannels() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.IsError().
Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications from all channels which is registered with specified pushToken.
To run Remove all push notifications you can use the following method(s) in the Unity V4 SDK
  1. ParameterTypeRequiredDefaultsDescription
    DeviceIDstringYesDevice id.
    PushTypePNPushTypeYesNot setAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    QueryParamDictionary<string, string>OptionalQueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API.
    AsyncPNCallbackYesPNCallback of type PNPushRemoveAllChannelsResult.
pubnub.RemoveAllPushNotifications()
	.DeviceID(<deviceId>)
	.PushType(PNPushType.GCM)
	.Async((result, status) => {
		Debug.Log ("in RemoveAllPushNotificationsFromChannels");
		if(status.Error){
			Debug.Log (string.Format("In Example, RemoveAllPushNotificationsFromChannels Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
		} else {
			Debug.Log (string.Format("DateTime {0}, In RemoveAllPushNotificationsFromChannels, result: {1}", DateTime.UtcNow, result.Message));
		}
	});
The RemoveAllPushNotificationsFromDeviceWithPushToken() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError().

Go to MISCELLANEOUS