---
source_url: https://www.pubnub.com/docs/sdks/swift/api-reference/mobile-push
title: Mobile Push Notifications API for Swift Native SDK
updated_at: 2026-06-18T11:28:48.507Z
sdk_name: PubNub Swift SDK
sdk_version: 10.1.7
---

> 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 Swift Native SDK

PubNub Swift SDK, use the latest version: 10.1.7

Install:

```bash
Add PubNub via Swift Package Manager or CocoaPods@10.1.7
```

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 APNs2 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-).
:::

Enable APNs2 mobile push notifications on a set of channels.

### Method(s)

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

```swift
func addAPNSDevicesOnChannels(
    _ additions: [String],
    device token: Data,
    on topic: String,
    environment: PubNub.PushEnvironment = .development,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: `((Result<[String], Error>) -> Void)?`
)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| _ | Data | Yes |  | Channels to add for the device. |
| device | Data | Yes |  | Device token. |
| on | String | Yes |  | APNs topic (bundle identifier). |
| environment | PubNub.PushEnvironment | Yes | `.development` | APNs environment. |
| custom | PubNub.RequestConfiguration | Optional | `PubNub.RequestConfiguration()` | Per-request configuration. |
| completion | ((Result<[String], | Optional | `nil` | Async result callback. |

#### Completion handler result

##### Success

An `Array` of channels added for notifications on a specific device token.

##### Failure

An `Error` describing the failure.

### Sample code

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

#### Adding device to channel

```swift
import PubNubSDK
import Foundation

// Initializes a PubNub object with the configuration
let pubnub = PubNub(
  configuration: PubNubConfiguration(
    publishKey: "demo",
    subscribeKey: "demo",
    userId: "myUniqueUserId"
  )
)

// Enable APNS push notifications for a device on a provided channel
pubnub.addAPNSDevicesOnChannels(
  ["channelSwift"],
  device: Data([0x01, 0x02, 0x03, 0x04]), // Replace with actual device token
  on: "com.app.bundle",
  environment: .production
) { result in
  switch result {
  case let .success(channels):
    print("The list of channels added for push: \(channels)")
  case let .failure(error):
    print("Failed Push List Response: \(error.localizedDescription)")
  }
}
```

## List APNs2 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 with APNs2 push notifications for the specified device token and topic.

### Method(s)

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

```swift
func listAPNSPushChannelRegistrations(
    for deviceToken: Data,
    on topic: String,
    environment: PushEnvironment = .development,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: `((Result<[String], Error>) -> Void)?`
)
```

| Parameter | Description |
| --- | --- |
| `for` *Type: DataDefault: n/a | Device token. |
| `on` *Type: StringDefault: n/a | APNs topic (bundle identifier). |
| `environment` *Type: PubNub.PushEnvironmentDefault: `.development` | APNs environment. |
| `custom`Type: [PubNub.RequestConfiguration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration)Default: `PubNub.RequestConfiguration()` | Per-request configuration. |
| `completion`Type: `((Result<[String], Error>) -> Void)?`Default: `nil` | Async result callback. |

#### Completion handler result

##### Success

An `Array` of channels added for notifications on a specific device token.

##### Failure

An `Error` describing the failure.

### Sample code

#### List APNs2 channels for device

```swift
// Retrieve all channels on which APNS push notification has been enabled using specified device token and topic
pubnub.listAPNSPushChannelRegistrations(
  for: Data([0x01, 0x02, 0x03, 0x04]), // Replace with actual device token
  on: "com.app.bundle",
  environment: .production
) { result in
  switch result {
  case let .success(channels):
    print("The list of channels enabled for push: \(channels)")
  case let .failure(error):
    print("Failed Push List Response: \(error.localizedDescription)")
  }
}
```

## Remove a device from APNs2 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 APNs2 mobile push notifications on a set of channels.

### Method(s)

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

```swift
func removeAPNSDevicesOnChannels(
    _ removals: [String],
    device token: Data,
    on topic: String,
    environment: PushEnvironment = .development,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: `((Result<[String], Error>) -> Void)?`
)
```

| Parameter | Description |
| --- | --- |
| `_` *Type: DataDefault: n/a | Channels to remove for the device. |
| `device` *Type: DataDefault: n/a | Device token. |
| `on` *Type: StringDefault: n/a | APNs topic (bundle identifier). |
| `environment` *Type: PubNub.PushEnvironmentDefault: `.development` | APNs environment. |
| `custom`Type: [PubNub.RequestConfiguration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration)Default: `PubNub.RequestConfiguration()` | Per-request configuration. |
| `completion`Type: `((Result<[String], Error>) -> Void)?`Default: `nil` | Async result callback. |

#### Completion handler result

##### Success

An `Array` of channels disabled from notifications on a specific device token.

##### Failure

An `Error` describing the failure.

### Sample code

#### Remove device from channel

```swift
// Disable APNS push notifications for a device on a provided channel
pubnub.removeAPNSDevicesOnChannels(
  ["channelSwift"],
  device: Data([0x01, 0x02, 0x03, 0x04]), // Replace with actual device token
  on: "com.app.bundle",
  environment: .production
) { result in
  switch result {
  case let .success(channels):
    print("The list of channels disabled for push: \(channels)")
  case let .failure(error):
    print("Failed Push List Response: \(error.localizedDescription)")
  }
}
```

## Remove a device from all APNs2 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 APNs2 mobile push notifications from all channels registered for the specified device token.

### Method(s)

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

```swift
func removeAllAPNSPushDevice(
    for deviceToken: Data,
    on topic: String,
    environment: PushEnvironment = .development,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: ((Result<Void, Error>) -> Void)?
)
```

| Parameter | Description |
| --- | --- |
| `for` *Type: DataDefault: n/a | The device token used during registration. |
| `on` *Type: StringDefault: n/a | The topic of the remote notification (which is typically the bundle ID for your app). |
| `environment` *Type: PubNub.PushEnvironmentDefault: `.development` | The APS environment to register the device. |
| `custom`Type: [PubNub.RequestConfiguration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration)Default: `PubNub.RequestConfiguration()` | An object that allows for per-request customization of PubNub configuration or network session. For more information, refer to the [Request Configuration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration) section. |
| `completion`Type: `((Result<[String], Error>) -> Void)?`Default: `nil` | The async `Result` of the method call. |

#### Completion handler result

##### Success

A `Void`indicating a success.

##### Failure

An `Error` describing the failure.

### Sample code

#### Remove all mobile push notifications

```swift
// Disable APNS push notifications for a device on all channels
pubnub.removeAllAPNSPushDevice(
  for: Data([0x01, 0x02, 0x03, 0x04]), // Replace with actual device token
  on: "com.app.bundle",
  environment: .production
) { result in
  switch result {
  case .success:
    print("All channels have been removed for the device token.")
  case let .failure(error):
    print("Failed Push List Response: \(error.localizedDescription)")
  }
}
```

## Add device to channel (deprecated)

:::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 provided set of channels. This method is deprecated in favor of the corresponding HTTP/2-based APNs method above. Use only for legacy binary APNs interface publishing.

#### Method(s)

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

```swift
func addPushChannelRegistrations(
    _ additions: [String],
    for deviceToken: Data,
    of pushType: PubNub.PushService = .apns,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: `((Result<[String], Error>) -> Void)?`
)
```

| Parameter | Description |
| --- | --- |
| `_` *Type: [String]Default: n/a | The list of channels to add the device registration to. |
| `for` *Type: DataDefault: n/a | A device token to identify the device for registration changes. |
| `of` *Type: PubNub.PushServiceDefault: `.apns` | The type of Remote Notification service used to send the notifications. |
| `custom`Type: [PubNub.RequestConfiguration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration)Default: `PubNub.RequestConfiguration()` | An object that allows for per-request customization of PubNub configuration or network session. For more information, refer to the [Request Configuration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration) section. |
| `completion`Type: `((Result<[String], Error>) -> Void)?`Default: `nil` | The async `Result` of the method call. |

##### Completion handler result

###### Success

An `Array` of channels added for notifications on a specific device token.

###### Failure

An `Error` describing the failure.

#### Sample code

##### Add device to channel

```swift
// Add push notification functionality on provided set of channels
pubnub.addPushChannelRegistrations(
  ["channelSwift"],
  for: Data([0x01, 0x02, 0x03, 0x04]) // Replace with actual device token
) { result in
  switch result {
  case let .success(channels):
    print("The list of channels added for push: \(channels)")
  case let .failure(error):
    print("Failed Push Modification Response: \(error.localizedDescription)")
  }
}
```

## List channels for device (deprecated)

:::note Requires Mobile Push Notifications add-on
This method requires that the Mobile Push Notifications add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

Request for all channels on which push notification has been enabled using specified `pushToken`. This method is deprecated in favor of the corresponding HTTP/2-based APNs method above. Use only for legacy binary APNs interface publishing.

#### Method(s)

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

```swift
func listPushChannelRegistrations(
    for deviceToken: Data,
    of pushType: PubNub.PushService = .apns,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: `((Result<[String], Error>) -> Void)?`
)
```

| Parameter | Description |
| --- | --- |
| `for` *Type: DataDefault: n/a | Device token. |
| `of` *Type: PubNub.PushServiceDefault: `.apns` | Remote Notification service type. |
| `custom`Type: [PubNub.RequestConfiguration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration)Default: `PubNub.RequestConfiguration()` | Per-request configuration. |
| `completion`Type: `((Result<[String], Error>) -> Void)?`Default: `nil` | Async result callback. |

##### Completion handler result

###### Success

An `Array` of channels added for notifications on a specific device token.

###### Failure

An `Error` describing the failure.

#### Sample code

##### Listing channels for device

```swift
// Retrieve all channels on which push notification has been enabled using specified device token
pubnub.listPushChannelRegistrations(
  for: Data([0x01, 0x02, 0x03, 0x04]) // Replace with actual device token
) { result in
  switch result {
  case let .success(channels):
    print("The list of channels enabled for push: \(channels)")
  case let .failure(error):
    print("Failed Push List Response: \(error.localizedDescription)")
  }
}
```

## Remove device from channel (deprecated)

:::note Requires Mobile Push Notifications add-on
This method requires that the Mobile Push Notifications add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

Disable mobile push notifications on provided set of channels. This method is deprecated in favor of the corresponding HTTP/2-based APNs method above. Use only for legacy binary APNs interface publishing.

#### Method(s)

To run `Removing Device From Channel` you can use the following method(s) in the Swift SDK:

```swift
removePushChannelRegistrations(
    _ removals: [String],
    for deviceToken: Data,
    of pushType: PubNub.PushService = .apns,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: `((Result<[String], Error>) -> Void)?`
)
```

| Parameter | Description |
| --- | --- |
| `_` *Type: [String]Default: n/a | The list of channels to remove the device registration from. |
| `for` *Type: DataDefault: n/a | A device token to identify the device for registration changes. |
| `of` *Type: PubNub.PushServiceDefault: `.apns` | The type of Remote Notification service used to send the notifications. |
| `custom`Type: [PubNub.RequestConfiguration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration)Default: `PubNub.RequestConfiguration()` | An object that allows for per-request customization of PubNub configuration or network session. For more information, refer to the [Request Configuration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration) section. |
| `completion`Type: `((Result<[String], Error>) -> Void)?`Default: `nil` | The async `Result` of the method call. |

##### Completion handler result

###### Success

An `Array` of channels added for notifications on a specific device token.

###### Failure

An `Error` describing the failure.

#### Sample code

##### Remove device from channel

```swift
// Remove push notification functionality on provided set of channels
pubnub.removePushChannelRegistrations(
  ["channelSwift"],
  for: Data([0x01, 0x02, 0x03, 0x04]) // Replace with actual device token
) { result in
  switch result {
  case let .success(channels):
    print("The list of channels disabled for push: \(channels)")
  case let .failure(error):
    print("Failed Push Modification Response: \(error.localizedDescription)")
  }
}
```

## Remove all mobile push notifications (deprecated)

:::note Requires Mobile Push Notifications add-on
This method requires that the Mobile Push Notifications add-on is enabled for your key in the [Admin Portal](https://admin.pubnub.com/). Read the [support page](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) on enabling add-on features on your keys.
:::

Disable mobile push notifications from all channels registered with the specified `pushToken`. This method is deprecated in favor of the corresponding HTTP/2-based APNs method above. Use only for legacy binary APNs interface publishing.

#### Method(s)

To run `Remove all mobile push notifications`, you can use the following method(s) in the Swift SDK:

```swift
func removeAllPushChannelRegistrations(
    for deviceToken: Data,
    of pushType: PubNub.PushService = .apns,
    custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
    completion: ((Result<Void, Error>) -> Void)?
)
```

| Parameter | Description |
| --- | --- |
| `for` *Type: DataDefault: n/a | A device token to identify the device for registration changes. |
| `of` *Type: PubNub.PushServiceDefault: `.apns` | The type of Remote Notification service used to send the notifications. |
| `custom`Type: [PubNub.RequestConfiguration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration)Default: `PubNub.RequestConfiguration()` | An object that allows for per-request customization of PubNub configuration or network session. For more information, refer to the [Request Configuration](https://www.pubnub.com/docs/sdks/swift/api-reference/configuration#request-configuration) section. |
| `completion`Type: `((Result<Void, Error>) -> Void)?`Default: `nil` | The async `Result` of the method call. |

##### Completion handler result

###### Success

A `Void` indicating a success.

###### Failure

An `Error` describing the failure.

#### Sample code

##### Remove all mobile push notifications

```swift
// Remove push notification functionality on all channels
pubnub.removeAllPushChannelRegistrations(
  for: Data([0x01, 0x02, 0x03, 0x04]) // Replace with actual device token
) { result in
  switch result {
  case .success:
    print("All channels have been removed for the device token.")
  case let .failure(error):
    print("Failed Push Deletion Response: \(error.localizedDescription)")
  }
}
```

## 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.