---
source_url: https://www.pubnub.com/docs/sdks/unity/api-reference/mobile-push
title: Mobile Push Notifications API for Unity SDK
updated_at: 2026-05-29T11:12:30.195Z
sdk_name: PubNub Unity SDK
sdk_version: v9.3.0
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Mobile Push Notifications API for Unity SDK

PubNub Unity SDK, use the latest version: v9.3.0

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](https://www.pubnub.com/docs/general/push/send).

## Add a device to a push notifications channel

:::note Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

Enable mobile push notifications on a set of channels.

### Method(s)

Use the following method(s) in the Unity SDK:

```csharp
pubnub.AddPushNotificationsOnChannels()
    .PushType(PNPushType)
    .Channels(Array)
    .DeviceId(string)
    .Environment(PushEnvironment)
    .Topic(string)
    .QueryParam(Dictionary<string,object>)
    .Execute(System.Action<PNPushAddChannelResult, PNStatus>)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| PushType | PNPushType | Yes |  | Accepted values: `PNPushType.FCM`, `PNPushType.APNS2`. |
| Channels | Array | Yes |  | Channels to enable for push notifications. |
| DeviceId | string | Yes |  | Device token. |
| Environment | PushEnvironment | Optional |  | APNs environment (APNS2 only). |
| Topic | string | Optional |  | APNs topic (bundle identifier) (APNS2 only). |
| QueryParam | Dictionary<string, | Optional |  | Optional query parameters for debugging. |
| Async | PNCallback | Optional |  | PNCallback of type PNPushAddChannelResult. |
| Execute | System.Action | Yes |  | `System.Action` of type `PNPushAddChannelResult`. |
| ExecuteAsync | None | Optional |  | Returns `Task<PNResult<PNPushAddChannelResult>>`. |

### Sample code

#### Add device to channel

:::tip 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.
:::

```csharp
using PubnubApi;
using PubnubApi.Unity;
using UnityEngine;

public class AddPushNotificationsExample : MonoBehaviour {
    // Reference to a pubnub manager previously setup in Unity Editor
    // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
    [SerializeField] private PNManagerBehaviour pubnubManager;

    // An editor-serialized array for the channels to add notifications
    [SerializeField] private string[] channels = { "ch1", "ch2", "ch3" };

    // An editor-serialized string for the device IDs
    [SerializeField] private string fcmDeviceId = "googleDevice";
    [SerializeField] private string apnsDeviceId = "appleDevice";

    // An editor-serialized string for the APNS2 topic
    [SerializeField] private string apnsTopic = "myapptopic";

    private void Start() {
        // Getting a reference to the Pubnub instance
        var pubnub = pubnubManager.pubnub;

        // Note that you can also initialize Pubnub instance for Unity directly from code:
        /*
        PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
        {
	        SubscribeKey = "demo",
	        PublishKey = "demo",
        };
        Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
        */

        // Adding FCM/GCM push notifications
        pubnub.AddPushNotificationsOnChannels()
            .PushType(PNPushType.FCM)
            .Channels(channels)
            .DeviceId(fcmDeviceId)
            .Execute((result, status) => {
                if (status.Error) {
                    Debug.LogError($"Error adding FCM notifications: {status.ErrorData.Information}");
                } else {
                    Debug.Log("Successfully added FCM notifications.");
                }
            });

        // Adding APNS2 push notifications
        pubnub.AddPushNotificationsOnChannels()
            .PushType(PNPushType.APNS2)
            .Channels(channels)
            .DeviceId(apnsDeviceId)
            .Topic(apnsTopic)
            .Environment(PushEnvironment.Development)
            .Execute((result, status) => {
                if (status.Error) {
                    Debug.LogError($"Error adding APNS2 notifications: {status.ErrorData.Information}");
                } else {
                    Debug.Log("Successfully added APNS2 notifications.");
                }
            });
    }
}
```

### Returns

The `AddPushNotificationsOnChannels()` does not return actionable data. Check `status.isError()` on the status object.

## List push notifications channels for a device

:::note Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

List channels that have push notifications enabled for the specified device token.

### Method(s)

Use the following method(s) in the Unity SDK:

```csharp
pubnub.AuditPushChannelProvisions()
    .DeviceId(string)
    .PushType(PNPushType)
    .Environment(PushEnvironment)
    .Topic(string)
    .QueryParam(Dictionary<string,object>)
    .Execute(System.Action<PNPushListProvisionsResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `DeviceId` *Type: string | Device token. |
| `PushType` *Type: PNPushType | Accepted values: `PNPushType.FCM`, `PNPushType.APNS2`. |
| `Environment`Type: `PushEnvironment` | APNs environment (APNS2 only). |
| `Topic`Type: string | APNs topic (bundle identifier) (APNS2 only). |
| `QueryParam`Type: Dictionary`<string, object>` | Optional query parameters for debugging. |
| AsyncType: PNCallback | PNCallback of type PNPushListProvisionsResult. |
| `Execute` *Type: `System.Action` | `System.Action` of type `PNPushListProvisionsResult`. |
| `ExecuteAsync`Type: None | Returns `Task<PNResult<PNPushListProvisionsResult>>`. |

### Sample code

#### List channels for device

```csharp
// Configuration
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// for FCM/GCM
pubnub.AuditPushChannelProvisions()
    .DeviceId("googleDevice")
    .PushType(PNPushType.FCM)
    .Execute(new PNPushListProvisionsResultExt((r, s) =>
    {
        Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
    }));

// for APNS2
pubnub.AuditPushChannelProvisions()
    .DeviceId("appleDevice")
    .PushType(PNPushType.APNS2)
    .Topic("myapptopic")
    .Environment(PushEnvironment.Development)
    .Execute(new PNPushListProvisionsResultExt((r, s) =>
    {
        Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
    }));
```

### 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 Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

Disable mobile push notifications on a set of channels.

### Method(s)

Use the following method(s) in the Unity SDK:

```csharp
pubnub.RemovePushNotificationsFromChannels()
    .DeviceId(string)
    .Channels(Array)
    .PushType(PNPushType)
    .Environment(PushEnvironment)
    .Topic(string)
    .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.FCM`, `PNPushType.APNS2`. |
| `Environment`Type: `PushEnvironment` | APNs environment (APNS2 only). |
| `Topic`Type: string | APNs topic (bundle identifier) (APNS2 only). |
| `QueryParam`Type: Dictionary`<string, object>` | Optional query parameters for debugging. |

### Sample code

#### Remove device from channel

```csharp
// Configuration
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// for FCM/GCM
pubnub.RemovePushNotificationsFromChannels()
    .DeviceId("googleDevice")
    .Channels(new string[] {
        "ch1",
        "ch2",
        "ch3"
    })
    .PushType(PNPushType.FCM)
    .Execute(new PNPushRemoveChannelResultExt((r, s) =>
    {
        Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
    }));

// for APNS2
pubnub.RemovePushNotificationsFromChannels()
    .DeviceId("appleDevice")
    .Channels(new string[] {
        "ch1",
        "ch2",
        "ch3"
    })
    .PushType(PNPushType.APNS2)
    .Topic("myapptopic")
    .Environment(PushEnvironment.Development)
    .Execute(new PNPushRemoveChannelResultExt((r, s) =>
    {
        Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
    }));
```

### Returns

The `RemovePushNotificationsFromChannels()` does not return actionable data. Check `status.isError()` on the status object.

## Remove a device from all push notifications channels

:::note Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

Disable mobile push notifications from all channels registered with the specified device token.

### Method(s)

Use the following method(s) in the Unity SDK:

```csharp
pubnub.RemoveAllPushNotificationsFromDeviceWithPushToken()
    .DeviceId(string)
    .PushType(PNPushType)
    .Environment(PushEnvironment)
    .Topic(string)
    .QueryParam(Dictionary<string,object>)
    .Execute(System.Action<PNPushRemoveAllChannelsResult, PNStatus>)
```

| Parameter | Description |
| --- | --- |
| `DeviceId` *Type: string | Device token. |
| `PushType` *Type: PNPushType | Accepted values: `PNPushType.FCM`, `PNPushType.APNS2`. |
| `Environment`Type: `PushEnvironment` | APNs environment (APNS2 only). |
| `Topic`Type: string | APNs topic (bundle identifier) (APNS2 only). |
| `QueryParam`Type: Dictionary`<string, object>` | Optional query parameters for debugging. |

### Sample code

#### Remove all mobile push notifications

```csharp
// Configuration
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize PubNub
Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);

// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
// For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
/*
[SerializeField] private PNManagerBehaviour pubnubManager;
Pubnub pubnub = pubnubManager.pubnub;
*/

// for FCM/GCM
pubnub.RemoveAllPushNotificationsFromDeviceWithPushToken()
    .DeviceId("googleDevice")
    .PushType(PNPushType.FCM)
    .Execute(new PNPushRemoveAllChannelsResultExt((r, s) => {
        Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
    }));

// for APNS2
pubnub.RemoveAllPushNotificationsFromDeviceWithPushToken()
    .DeviceId("appleDevice")
    .PushType(PNPushType.APNS2)
    .Topic("myapptopic")
    .Environment(PushEnvironment.Development)
    .Execute(new PNPushRemoveAllChannelsResultExt((r, s) => {
        Debug.Log(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
    }));
```

### Returns

The `RemoveAllPushNotificationsFromDeviceWithPushToken()` operation returns a `PNPushRemoveAllChannelsResult` and `PNStatus`.

## Terms in this document

* **PubNub** - PubNub is a real-time messaging platform that provides APIs and SDKs for building scalable applications. It handles the complex infrastructure of real-time communication, including: Message delivery and persistence, Presence detection, Access control, Push notifications, File sharing, Serverless processing with Functions and Events & Actions, Analytics and monitoring with BizOps Workspace, AI-powered insights with Illuminate.