Mobile Push Notifications API for Unity SDK
The Mobile Push Notifications feature connects native PubNub publishing to third-party push services. Supported services include Google Android FCM (Firebase Cloud Messaging) and Apple iOS APNs (Apple Push Notification service).
To learn more, read about Mobile Push Notifications.
Add a device to a push notifications channel
note
Enable Mobile Push Notifications for your key in the Admin Portal. See how to enable add-on features.
Enable mobile push notifications on a set of channels.
Method(s)
Use the following method(s) in the Unity SDK:
1pubnub.AddPushNotificationsOnChannels()
2 .PushType(PNPushType)
3 .Channels(Array)
4 .DeviceId(string)
5 .Environment(PushEnvironment)
6 .Topic(string)
7 .QueryParam(Dictionary<string,object>)
8 .Execute(System.Action<PNPushAddChannelResult, PNStatus>)
| Parameter | Description |
|---|---|
PushType *Type: PNPushType | Accepted values: PNPushType.GCM, PNPushType.FCM, PNPushType.APNS2. |
Channels *Type: Array | Channels to enable for push notifications. |
DeviceId *Type: string | Device token. |
EnvironmentType: PushEnvironment | APNs environment (APNS2 only). |
TopicType: string | APNs topic (bundle identifier) (APNS2 only). |
QueryParamType: Dictionary <string, object> | Optional query parameters for debugging. |
AsyncType: | PNCallback of type PNPushAddChannelResult. |
Execute *Type: System.Action | System.Action of type PNPushAddChannelResult. |
ExecuteAsyncType: None | Returns Task<PNResult<PNPushAddChannelResult>>. |
Sample code
Add device to channel
Reference code
1
Returns
The AddPushNotificationsOnChannels() does not return actionable data. Check status.isError() on the status object.
List push notifications channels for a device
note
Enable Mobile Push Notifications for your key in the Admin Portal. See how to enable add-on features.
List channels that have push notifications enabled for the specified device token.
Method(s)
Use the following method(s) in the Unity SDK:
1pubnub.AuditPushChannelProvisions()
2 .DeviceId(string)
3 .PushType(PNPushType)
4 .Environment(PushEnvironment)
5 .Topic(string)
6 .QueryParam(Dictionary<string,object>)
7 .Execute(System.Action<PNPushListProvisionsResult, PNStatus>)
| Parameter | Description |
|---|---|
DeviceId *Type: string | Device token. |
PushType *Type: PNPushType | Accepted values: PNPushType.GCM, PNPushType.FCM, PNPushType.APNS2. |
EnvironmentType: PushEnvironment | APNs environment (APNS2 only). |
TopicType: string | APNs topic (bundle identifier) (APNS2 only). |
QueryParamType: Dictionary <string, object> | Optional query parameters for debugging. |
AsyncType: | PNCallback of type PNPushListProvisionsResult. |
Execute *Type: System.Action | System.Action of type PNPushListProvisionsResult. |
ExecuteAsyncType: None | Returns Task<PNResult<PNPushListProvisionsResult>>. |
Sample code
List channels for device
1
Returns
The AuditPushChannelProvisions() operation returns a PNPushListProvisionsResult which contains the following property:
| Property Name | Type | Description |
|---|---|---|
Channels | List<string> | Channels with push notifications enabled. |
Remove a device from push notifications channels
note
Enable Mobile Push Notifications for your key in the Admin Portal. See how to enable add-on features.
Disable mobile push notifications on a set of channels.
Method(s)
Use the following method(s) in the Unity SDK:
1pubnub.RemovePushNotificationsFromChannels()
2 .DeviceId(string)
3 .Channels(Array)
4 .PushType(PNPushType)
5 .Environment(PushEnvironment)
6 .Topic(string)
7 .QueryParam(Dictionary<string,object>)
| Parameter | Description |
|---|---|
DeviceId *Type: string | Device token. |
Channels *Type: Array | Channels to disable for push notifications. |
PushType *Type: PNPushType | Accepted values: PNPushType.GCM, PNPushType.FCM, PNPushType.APNS2. |
EnvironmentType: PushEnvironment | APNs environment (APNS2 only). |
TopicType: string | APNs topic (bundle identifier) (APNS2 only). |
QueryParamType: Dictionary <string, object> | Optional query parameters for debugging. |
Sample code
Remove device from channel
1
Returns
The RemovePushNotificationsFromChannels() does not return actionable data. Check status.isError() on the status object.
Remove a device from all push notifications channels
note
Enable Mobile Push Notifications for your key in the Admin Portal. See how to enable add-on features.
Disable mobile push notifications from all channels registered with the specified device token.
Method(s)
Use the following method(s) in the Unity SDK:
1pubnub.RemoveAllPushNotificationsFromDeviceWithPushToken()
2 .DeviceId(string)
3 .PushType(PNPushType)
4 .Environment(PushEnvironment)
5 .Topic(string)
6 .QueryParam(Dictionary<string,object>)
7 .Execute(System.Action<PNPushRemoveAllChannelsResult, PNStatus>)
| Parameter | Description |
|---|---|
DeviceId *Type: string | Device token. |
PushType *Type: PNPushType | Accepted values: PNPushType.GCM, PNPushType.FCM, PNPushType.APNS2. |
EnvironmentType: PushEnvironment | APNs environment (APNS2 only). |
TopicType: string | APNs topic (bundle identifier) (APNS2 only). |
QueryParamType: Dictionary <string, object> | Optional query parameters for debugging. |
Sample code
Remove all mobile push notifications
1
Returns
The RemoveAllPushNotificationsFromDeviceWithPushToken() operation returns a PNPushRemoveAllChannelsResult and PNStatus.