---
source_url: https://www.pubnub.com/docs/sdks/objective-c/api-reference/mobile-push
title: Mobile Push Notifications API for Objective-C SDK
updated_at: 2026-05-29T11:11:24.883Z
sdk_name: PubNub Objective-C SDK
sdk_version: 7.0.2
---

> 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 Objective-C SDK

PubNub Objective-C SDK, use the latest version: 7.0.2

Install:

```bash
pod install PubNub@7.0.2
```

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

:::note APNs version support
PubNub Objective-C SDK supports both the HTTP/2-based Apple Push Notification service (APNs) and the already deprecated legacy binary protocol for APNs Mobile Push Notifications. Depending on the APNs version you use in your SDK, set `pushType` in methods to either `PNAPNS2Push` or `PNAPNSPush`.
:::

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

To run `Adding Device to Channel`, you can use the following method(s) in the Objective-C SDK:

```objectivec
- (void)addPushNotificationsOnChannels:(NSArray<NSString *> *)channels 
                   withDevicePushToken:(NSData *)pushToken 
                         andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channels | NSArray | Yes |  | Channels to enable for push notifications. |
| pushToken | NSData | Yes |  | Device push token. |
| block | PNPushNotificationsStateModificationCompletionBlock | Optional |  | Completion block with request status. |

```objectivec
- (void)addPushNotificationsOnChannels:(NSArray<NSString *> *)channels 
                   withDevicePushToken:(id)pushToken 
                              pushType:(PNPushType)pushType 
                         andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | Channels to enable for push notifications. |
| `pushToken` *Type: id | Device token (`NSString`). |
| `pushType` *Type: PNPushType | Accepted values: PNFCMPush - Firebase Cloud Messaging (Google Cloud Messaging) |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block. |

```objectivec
- (void)addPushNotificationsOnChannels:(NSArray<NSString *> *)channels 
                   withDevicePushToken:(id)pushToken 
                              pushType:(PNPushType)pushType 
                           environment:(PNAPNSEnvironment)environment 
                                 topic:(NSString *)topic 
                         andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | Channels to enable for push notifications. |
| `pushToken` *Type: id | Device token (`NSData`). |
| `pushType` *Type: PNPushType | Accepted values: PNAPNS2Push - Apple Push Notification service over HTTP/2 |
| `environment` *Type: PNAPNSEnvironment | APNs environment (APNS2 only). |
| `topic` *Type: NSString | APNs topic (bundle identifier). |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block. |

### Sample code

#### Add device to channel

```objectivec
#import <Foundation/Foundation.h>
#import <PubNub/PubNub.h>

// Basic configuration
PNConfiguration *config = [PNConfiguration configurationWithPublishKey:@"demo"
                                                          subscribeKey:@"demo"
                                                                userID:@"pushUser"];

// Create a PubNub client instance
PubNub *client = [PubNub clientWithConfiguration:config];

// Simulating a device token for example purposes
// In a real app, you would get this from the system
NSData *devicePushToken = [@"sample-device-token-12345" dataUsingEncoding:NSUTF8StringEncoding];

// Example 1: Basic APNs integration - using legacy binary protocol
NSArray *channels = @[@"news", @"sports", @"finance"];

NSLog(@"Adding device to channels: %@ with legacy APNs", channels);

PNPushNotificationManageRequest *request = [PNPushNotificationManageRequest requestToAddChannels:channels
                                                                               toDeviceWithToken:devicePushToken
                                                                                        pushType:PNAPNSPush];

[client managePushNotificationWithRequest:request completion:^(PNAcknowledgmentStatus *status) {
    if (!status.isError) {
        NSLog(@"✅ Successfully enabled push notifications on channels!");
        NSLog(@"Device can now receive push notifications when messages are published to these channels");
    } else {
        NSLog(@"❌ Error enabling push notifications: %@", status.errorData.information);
        NSLog(@"Error category: %@", @(status.category));
    }
}];

// Example 2: Modern APNs integration using HTTP/2 protocol
NSArray *apns2Channels = @[@"news", @"sports", @"finance"];

NSLog(@"Adding device to channels: %@ with APNs2 (HTTP/2)", apns2Channels);

// Your app's bundle identifier
NSString *topicName = @"com.example.myapp";

PNPushNotificationManageRequest *apns2Request = [PNPushNotificationManageRequest requestToAddChannels:apns2Channels
                                                                                    toDeviceWithToken:devicePushToken
                                                                                             pushType:PNAPNS2Push];
apns2Request.environment = PNAPNSDevelopment;
apns2Request.topic = topicName;

[client managePushNotificationWithRequest:apns2Request completion:^(PNAcknowledgmentStatus *status) {
    if (!status.isError) {
        NSLog(@"✅ Successfully enabled APNS2 push notifications on channels!");
        NSLog(@"Device can now receive push notifications when messages are published to these channels");
    } else {
        NSLog(@"❌ Error enabling APNS2 push notifications: %@", status.errorData.information);
        NSLog(@"Error category: %@", @(status.category));
    }
}];

// Example 3: FCM integration
NSArray *fcmChannels = @[@"news", @"sports", @"finance"];

NSLog(@"Adding device to channels: %@ with FCM", fcmChannels);

PNPushNotificationManageRequest *fcmRequest = [PNPushNotificationManageRequest requestToAddChannels:fcmChannels
                                                                                  toDeviceWithToken:devicePushToken
                                                                                           pushType:PNFCMPush];

[client managePushNotificationWithRequest:fcmRequest completion:^(PNAcknowledgmentStatus *status) {
    if (!status.isError) {
        NSLog(@"✅ Successfully enabled FCM push notifications on channels!");
        NSLog(@"Device can now receive push notifications when messages are published to these channels");
    } else {
        NSLog(@"❌ Error enabling FCM push notifications: %@", status.errorData.information);
        NSLog(@"Error category: %@", @(status.category));
    }
}];
```

### Response

Response objects returned by the client when the `APNS Add Device` API is used:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

### Other examples

1. Example for method no. 2 1[self.client addPushNotificationsOnChannels:@[@"wwdc",@"google.io"]2 withDevicePushToken:self.devicePushToken3 pushType:PNFCMPush4 andCompletion:^(PNAcknowledgmentStatus *status) {5 6 if (!status.isError) {7 // Push notifications successful enabled on passed channels.8 } else {9 /**10 * Handle modification error. Check 'category' property to find out possible issue because11 * of which request did fail.12 *13 * Request can be resent using: [status retry];14 */15 }16}];
2. Example for method no. 3 1[self.client addPushNotificationsOnChannels:@[@"wwdc",@"google.io"]2 withDevicePushToken:self.devicePushToken3 pushType:PNAPNS2Push4 environment:PNAPNSProduction5 topic:@"com.my-application.bundle"6 andCompletion:^(PNAcknowledgmentStatus *status) {7 8 if (!status.isError) {9 // Push notifications successful enabled on passed channels.10 } else {11 /**12 * Handle modification error. Check 'category' property to find out possible issue because13 * of which request did fail.14 *15 * Request can be resent using: [status retry];16 */17 }18}];

## Add a device to a push notifications channel (builder pattern)

:::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 builder methods:

#### APNS2 token

```objectivec
push()
    .enable()
    .token(id)
    .channels(NSArray<NSString *> *)
    .pushType(PNPushType)
    .environment(PNAPNSEnvironment)
    .topic(NSString *)
    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` | Channels to enable for push notifications. |
| `token` *Type: id | Device token (`NSData`). |
| `pushType` *Type: PNPushType | Accepted values: PNAPNS2Push - Apple Push Notification service over HTTP/2 |
| `environment`Type: PNAPNSEnvironment | APNs environment (APNS2 only). |
| `topic`Type: NSString | APNs topic (bundle identifier). |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block. |

:::note
This method uses the builder pattern. You can omit optional arguments.
:::

#### FCM token

```objectivec
push()
    .enable()
    .fcmToken(NSString *)
    .channels(NSArray<NSString *> *)
    .performWithCompletion(PNPushNotificationsStateModificationCompletionBlock);
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | Channels to enable for push notifications. |
| `fcmToken` *Type: NSString * | FCM device push token. |
| `completion`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block with request status. |

:::note
This method uses the builder pattern, you can remove the arguments which are optional.
:::

### Sample code

#### APNS2 token

```objectivec
self.client.push().enable()
    .token(self.devicePushToken)
    .channels(@[@"wwdc",@"google.io"])
    .pushType(PNAPNS2Push)
    .environment(PNAPNSProduction)
    .topic(@"com.my-application.bundle")
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
            // Push notifications successful enabled on passed channels.
        } else {
            /**
             * Handle modification error. Check 'category' property to find out possible issue because
             * of which request did fail.
             *
             * Request can be resent using: [status retry];
             */
        }
    });
```

#### FCM token

```objectivec
self.client.push().enable()
    .token(self.devicePushToken)
    .channels(@[@"wwdc",@"google.io"])
    .pushType(PNFCMPush)
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
            // Push notifications successful enabled on passed channels.
        } else {
            /**
             * Handle modification error. Check 'category' property to find out possible issue because
             * of which request did fail.
             *
             * Request can be resent using: [status retry];
             */
        }
    });
```

### Response

Response objects returned by the client when the `APNS Add Device` API is used:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

## List push notifications channels for a device (builder pattern)

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

To run `Listing Channels For Device`, you can use the following method(s) in the Objective-C SDK:

```objectivec
- (void)pushNotificationEnabledChannelsForDeviceWithPushToken:(NSData *)pushToken 
                                                andCompletion:(PNPushNotificationsStateAuditCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `pushToken` *Type: NSData | Device push token against which search on PubNub service should be performed. |
| `block` *Type: PNPushNotificationsStateAuditCompletionBlock | Push `notifications` status processing completion `block` which pass two arguments: result - in case of successful request processing data field will contain results of push `notifications` audit operation; status - in case if an error occurred during request processing. |

```objectivec
- (void)pushNotificationEnabledChannelsForDeviceWithPushToken:(id)pushToken 
                                                     pushType:(PNPushType)pushType 
                                                andCompletion:(PNPushNotificationsStateAuditCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `pushToken` *Type: id | Device token / identifier that you must set to `NSString` |
| `pushType` *Type: PNPushType | One of `PNPushType` fields which specify service to manage notifications for device specified with `pushToken`. Available push types: PNFCMPush - Firebase Cloud Messaging (Google Cloud Messaging) |
| `block` *Type: PNPushNotificationsStateAuditCompletionBlock | `Audit notifications enabled channels` request completion block. |

```objectivec
- (void)pushNotificationEnabledChannelsForDeviceWithPushToken:(id)pushToken 
                                                     pushType:(PNPushType)pushType 
                                                  environment:(PNAPNSEnvironment)environment 
                                                        topic:(NSString *)topic 
                                                andCompletion:(PNPushNotificationsStateAuditCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `pushToken` *Type: id | Device token / identifier that you must set to either `NSData` (for `PNAPNS2Push` and `PNAPNSPush`) or `NSString` for other, depending on the `pushType` passed. |
| `pushType` *Type: PNPushType | One of `PNPushType` fields which specify service to manage notifications for device specified with `pushToken`. Available push types: PNAPNS2Push - Apple Push Notification service over HTTP/2 |
| `environment` *Type: PNAPNSEnvironment | One of `PNAPNSEnvironment` fields which specify environment within which device should manage list of channels with enabled notifications (works only if `pushType` set to `PNAPNS2Push`). |
| `topic` *Type: NSString | Notifications topic name (usually it is application's bundle identifier). |
| `block` *Type: PNPushNotificationsStateAuditCompletionBlock | `Audit notifications enabled channels` request completion block. |

### Sample code

#### List channels for device

```objectivec
[self.client pushNotificationEnabledChannelsForDeviceWithPushToken:self.devicePushToken
                                                      andCompletion:^(PNAPNSEnabledChannelsResult *result,
                                                                      PNErrorStatus *status) {
      if (!status) {

        // Handle downloaded list of channels using: result.data.channels
    }
    else {

        /**
         Handle audition error. Check 'category' property
         to find out possible reason because of which request did fail.
         Review 'errorData' property (which has PNErrorData data type) of status
         object to get additional information about issue.

         Request can be resent using: [status retry];
         */
    }
 }];
```

### Response

Response objects returned by the client when the `APNS List Devices` API is used:

```objectivec
@interface PNAPNSEnabledChannelsData : PNServiceData

// Channels with active mobile push notifications.
@property (nonatomic, readonly, strong) NSArray<NSString *> *channels;

@end

@interface PNAPNSEnabledChannelsResult : PNResult

// APNS enabled channels audit request processed information.
@property (nonatomic, readonly, strong) PNAPNSEnabledChannelsData *data;

@end
```

Error response which is used in case of `APNS List Devices` API call failure:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

### Other examples

1. Example for method no. 2 1[self.client pushNotificationEnabledChannelsForDeviceWithPushToken:self.devicePushToken2 pushType:PNFCMPush3 andCompletion:^(PNFCMEnabledChannelsResult *result, PNErrorStatus *status) {4 5 if (!status.isError) {6 // Handle downloaded list of channels using: result.data.channels7 } else {8 /**9 * Handle audition error. Check 'category' property to find out possible issue because of10 * which request did fail.11 *12 * Request can be resent using: [status retry];13 */14 }15}];
2. Example for method no. 3 1[self.client pushNotificationEnabledChannelsForDeviceWithPushToken:self.devicePushToken2 pushType:PNAPNS2Push3 environment:PNAPNSDevelopment4 topic:@"com.my-application.bundle"5 andCompletion:^(PNAPNSEnabledChannelsResult *result, PNErrorStatus *status) {6 7 if (!status.isError) {8 // Handle downloaded list of channels using: result.data.channels9 } else {10 /**11 * Handle audition error. Check 'category' property to find out possible issue because of12 * which request did fail.13 *14 * Request can be resent using: [status retry];15 */16 }17}];

## List channels for device (builder pattern)

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

### Method(s)

To run `Listing Channels For Device`, you can use the following method(s) in the Objective-C SDK

#### APNS2 token

```objectivec
push()
    .audit()
    .token(id)
    .pushType(PNPushType)
    .environment(PNAPNSEnvironment)
    .topic(NSString *)
    .performWithCompletion(PNPushNotificationsStateAuditCompletionBlock);
```

| Parameter | Description |
| --- | --- |
| `token` *Type: id | Device token (`NSData`). |
| `pushType` *Type: PNPushType | Accepted values: PNAPNS2Push - Apple Push Notification service over HTTP/2 |
| `environment`Type: PNAPNSEnvironment | APNs environment (APNS2 only). |
| `topic`Type: NSString | APNs topic (bundle identifier). |
| `block` *Type: PNPushNotificationsStateAuditCompletionBlock | Completion block. |

:::note
This method uses the builder pattern. You can omit optional arguments.
:::

#### FCM token

```objectivec
push()
    .audit()
    .fcmToken(NSString *)
    .performWithCompletion(PNPushNotificationsStateModificationCompletionBlock);
```

| Parameter | Description |
| --- | --- |
| `fcmToken` *Type: NSString * | FCM device push token. |
| `completion` *Type: PNPushNotificationsStateAuditCompletionBlock | Completion block with `result` and `status`. |

:::note
This method uses the builder pattern. You can omit optional arguments.
:::

### Sample code

#### APNS2 token

```objectivec
self.client.push().audit()
    .token(self.devicePushToken)
    .pushType(PNAPNS2Push)
    .environment(PNAPNSProduction)
    .topic(@"com.my-application.bundle")
    .performWithCompletion(^(PNAPNSEnabledChannelsResult *result, PNErrorStatus *status) {
        if (!status.isError) {
            // Handle downloaded list of channels using: result.data.channels
        } else {
            /**
             * Handle audition error. Check 'category' property to find out possible issue because of
             * which request did fail.
             *
             * Request can be resent using: [status retry];
             */
        }
    });
```

#### FCM token

```objectivec
self.client.push().audit()
    .fcmToken(self.pushToken)
    .performWithCompletion(^(PNAPNSEnabledChannelsResult *result, PNErrorStatus *status) {
        if (!status) {
            // Handle downloaded list of channels using: result.data.channels
        } else {
           /**
            Handle audition error. Check 'category' property
            to find out possible reason because of which request did fail.
            Review 'errorData' property (which has PNErrorData data type) of status
            object to get additional information about issue.

            Request can be resent using: [status retry];
            */
        }
    });
```

### Response

Response objects returned by the client when the `APNS List Devices` API is used:

```objectivec
@interface PNAPNSEnabledChannelsData : PNServiceData

// Channels with active mobile push notifications.
@property (nonatomic, readonly, strong) NSArray<NSString *> *channels;

@end

@interface PNAPNSEnabledChannelsResult : PNResult

// APNS enabled channels audit request processed information.
@property (nonatomic, readonly, strong) PNAPNSEnabledChannelsData *data;

@end
```

Error response which is used in case of `APNS List Devices` API call failure:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

## Remove device from channel

:::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 a provided set of channels.

### Method(s)

To run `Removing Device From Channel`, you can use the following method(s) in the Objective-C SDK:

```objectivec
- (void)removePushNotificationsFromChannels:(NSArray<NSString *> *)channels 
                        withDevicePushToken:(NSData *)pushToken 
                              andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray | Channels to disable for push notifications. If empty, disables all. |
| `pushToken` *Type: NSData | Device push token. |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block with request status. |

```objectivec
- (void)removePushNotificationsFromChannels:(NSArray<NSString *> *)channels 
                        withDevicePushToken:(id)pushToken 
                                   pushType:(PNPushType)pushType 
                              andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | Channels to disable for push notifications. |
| `pushToken` *Type: id | Device token (`NSString`). |
| `pushType` *Type: PNPushType | Accepted values: PNFCMPush - Firebase Cloud Messaging (Google Cloud Messaging) |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block. |

```objectivec
- (void)removePushNotificationsFromChannels:(NSArray<NSString *> *)channels 
                        withDevicePushToken:(id)pushToken 
                                   pushType:(PNPushType)pushType 
                                environment:(PNAPNSEnvironment)environment 
                                      topic:(NSString *)topic 
                              andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | Channels to disable for push notifications. |
| `pushToken` *Type: id | Device token (`NSData`). |
| `pushType` *Type: PNPushType | Accepted values: PNAPNS2Push - Apple Push Notification service over HTTP/2 |
| `environment` *Type: PNAPNSEnvironment | APNs environment (APNS2 only). |
| `topic` *Type: NSString | APNs topic (bundle identifier). |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block. |

### Sample code

#### Remove device from channel

```objectivec
[self.client removePushNotificationsFromChannels:@[@"wwdc",@"google.io"]
                             withDevicePushToken:self.devicePushToken
                                   andCompletion:^(PNAcknowledgmentStatus *status) {

    if (!status.isError) {

        // Handle successful push notification disabling on passed channels.
    }
    else {

        /**
         Handle modification error. Check 'category' property
         to find out possible reason because of which request did fail.
         Review 'errorData' property (which has PNErrorData data type) of status
         object to get additional information about issue.

         Request can be resent using: [status retry];
         */
    }
}];
```

### Response

Response objects returned by the client when the `APNS Remove Device` API is used:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

### Other examples

1. Example for method no. 2 1[self.client removePushNotificationsFromChannels:@[@"wwdc",@"google.io"]2 withDevicePushToken:self.devicePushToken3 pushType:PNFCMPush4 andCompletion:^(PNAcknowledgmentStatus *status) {5 6 if (!status.isError) {7 // Push notification successfully disabled on passed channels.8 } else {9 /**10 * Handle modification error. Check 'category' property to find out possible issue because11 * of which request did fail.12 *13 * Request can be resent using: [status retry];14 */15 }16}];
2. Example for method no. 3 1[self.client removePushNotificationsFromChannels:@[@"wwdc",@"google.io"]2 withDevicePushToken:self.devicePushToken3 pushType:PNAPNS2Push4 environment:PNAPNSProduction5 topic:@"com.my-application.bundle"6 andCompletion:^(PNAcknowledgmentStatus *status) {7 8 if (!status.isError) {9 // Push notification successfully disabled on passed channels.10 } else {11 /**12 * Handle modification error. Check 'category' property to find out possible issue because13 * of which request did fail.14 *15 * Request can be resent using: [status retry];16 */17 }18}];

## Remove a device from push notifications channels (builder pattern)

:::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 builder methods:

#### APNS2 token

```objectivec
push()
    .disable()
    .channels(NSArray<NSString *> *)
    .token(id)
    .pushType(PNPushType)
    .environment(PNAPNSEnvironment)
    .topic(NSString *)
    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | Channels to disable for push notifications. |
| `token` *Type: id | Device token (`NSData`). |
| `pushType` *Type: PNPushType | Accepted values: PNAPNS2Push - Apple Push Notification service over HTTP/2 |
| `environment`Type: PNAPNSEnvironment | APNs environment (APNS2 only). |
| `topic`Type: NSString | APNs topic (bundle identifier). |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block. |

:::note
This method uses the builder pattern. You can omit optional arguments.
:::

#### FCM token

```objectivec
push()
    .disable()
    .fcmToken(NSString *)
    .channels(NSArray<NSString *> *)
    .performWithCompletion(PNPushNotificationsStateModificationCompletionBlock);
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | Channels to disable for push notifications. If empty, disables all. |
| `fcmToken` *Type: NSString * | FCM device push token. |
| `completion`Type: PNPushNotificationsStateAuditCompletionBlock | Completion block with request status. |

:::note
This method uses the builder pattern. You can omit optional arguments.
:::

### Sample code

#### APNS2 token

```objectivec
self.client.push().disable()
    .token(self.devicePushToken)
    .channels(@[@"wwdc",@"google.io"])
    .pushType(PNAPNS2Push)
    .environment(PNAPNSProduction)
    .topic(@"com.my-application.bundle")
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
            // Push notification successfully disabled on passed channels.
        } else {
            /**
             * Handle modification error. Check 'category' property to find out possible issue because
             * of which request did fail.
             *
             * Request can be resent using: [status retry];
             */
        }
    });
```

#### FCM token

```objectivec
self.client.push().disable()
    .channels(@[@"channel1", @"channel2"])
    .fcmToken(self.pushToken)
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
           // Handle successful push notification enabling on passed channels.
        } else {
           /**
            Handle modification error. Check 'category' property
            to find out possible reason because of which request did fail.
            Review 'errorData' property (which has PNErrorData data type) of status
            object to get additional information about issue.

            Request can be resent using: [status retry];
            */
        }
    });
```

### Response

Response objects returned by the client when the `APNS Remove Device` API is used:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

## Remove a device from all push notifications channels (builder pattern)

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

### Method(s)

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

```objectivec
- (void)removeAllPushNotificationsFromDeviceWithPushToken:(NSData *)pushToken 
                                            andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block
```

| Parameter | Description |
| --- | --- |
| `pushToken` *Type: NSData | Device push token which should be used to disable push `notifications` on a specified set of `channels`. |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Push `notifications` removal from device processing completion `block` which pass only one argument - request processing `status` to report about how data pushing was successful or not. |

```objectivec
- (void)removeAllPushNotificationsFromDeviceWithPushToken:(id)pushToken 
                                                 pushType:(PNPushType)pushType 
                                            andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `pushToken` *Type: id | Device token / identifier that you must set to `NSString`. |
| `pushType` *Type: PNPushType | One of `PNPushType` fields which specify service to manage notifications for device specified with `pushToken`. Available push types: PNFCMPush - Firebase Cloud Messaging (Google Cloud Messaging) |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | `Remove all notifications` request completion block. |

```objectivec
- (void)removeAllPushNotificationsFromDeviceWithPushToken:(id)pushToken 
                                                 pushType:(PNPushType)pushType 
                                              environment:(PNAPNSEnvironment)environment 
                                                    topic:(NSString *)topic 
                                            andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
```

| Parameter | Description |
| --- | --- |
| `channels` *Type: NSArray`<NSString *>` * | List of channel names for which mobile push notifications should be disabled. |
| `pushToken` *Type: id | Device token / identifier that you must set to `NSData`. |
| `pushType` *Type: PNPushType | One of `PNPushType` fields which specify service to manage notifications for device specified with `pushToken`. Available push types: PNAPNS2Push - Apple Push Notification service over HTTP/2 |
| `environment` *Type: PNAPNSEnvironment | One of `PNAPNSEnvironment` fields which specify environment within which device should manage list of channels with enabled notifications (works only if `pushType` set to `PNAPNS2Push`). |
| `topic` *Type: NSString | Notifications topic name (usually it is application's bundle identifier). |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | `Remove all notifications` request completion block. |

### Sample code

#### Remove all mobile push notifications

```objectivec
[self.client removeAllPushNotificationsFromDeviceWithPushToken:self.devicePushToken
                                                 andCompletion:^(PNAcknowledgmentStatus *status) {

    if (!status.isError) {

        /**
         Handle successful push notification disabling for all channels associated with
         specified device push token.
         */
    }
    else {

        /**
         Handle modification error. Check 'category' property
         to find out possible reason because of which request did fail.
         Review 'errorData' property (which has PNErrorData data type) of status
         object to get additional information about issue.

         Request can be resent using: [status retry];
         */
    }
}];
```

### Response

Response objects returned by the client when the `APNS Remove All Devices` API is used:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

### Other examples

1. Example for method no. 2. 1[self.client removeAllPushNotificationsFromDeviceWithPushToken:self.devicePushToken2 pushType:PNFCMPush3 andCompletion:^(PNAcknowledgmentStatus *status) {4 5 if (!status.isError) {6 /**7 * Push notification successfully disabled for all channels associated with specified8 * device push token.9 */10 } else {11 /**12 * Handle modification error. Check 'category' property to find out possible issue because13 * of which request did fail.14 *15 * Request can be resent using: [status retry];16 */17 }18}];
2. Example for method no. 3 1[self.client removeAllPushNotificationsFromDeviceWithPushToken:self.devicePushToken2 pushType:PNAPNS2Push3 environment:PNAPNSProduction4 topic:@"com.my-application.bundle"5 andCompletion:^(PNAcknowledgmentStatus *status) {6 7 if (!status.isError) {8 /**9 * Push notification successfully disabled for all channels associated with specified10 * device push token.11 */12 } else {13 /**14 * Handle modification error. Check 'category' property to find out possible issue because15 * of which request did fail.16 *17 * Request can be resent using: [status retry];18 */19 }20}];

## Remove all mobile push notifications (builder pattern)

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

### Method(s)

```objectivec
push()
    .disableAll()
    .token(id)
    .pushType(PNPushType)
    .environment(PNAPNSEnvironment)
    .topic(NSString *)
    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
```

| Parameter | Description |
| --- | --- |
| `token` *Type: id | Device token (`NSData` for `PNAPNS2Push`, otherwise `NSString`). |
| `pushType` *Type: PNPushType | Accepted values: PNAPNS2Push - Apple Push Notification service over HTTP/2, PNFCMPush - Firebase Cloud Messaging (Google Cloud Messaging) |
| `environment`Type: PNAPNSEnvironment | APNs environment (APNS2 only). |
| `topic`Type: NSString | APNs topic (bundle identifier). |
| `block`Type: PNPushNotificationsStateModificationCompletionBlock | Completion block. |

:::note
This method uses the builder pattern. You can omit optional arguments.
:::

### Sample code

#### Remove all mobile push notifications, using builder pattern (APNS2)

```objectivec
self.client.push().disableAll()
    .token(self.devicePushToken)
    .pushType(PNAPNS2Push)
    .environment(PNAPNSProduction)
    .topic(@"com.my-application.bundle")
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
            /**
             * Push notification successfully disabled for all channels associated with specified
             * device push token.
             */
        } else {
            /**
             * Handle modification error. Check 'category' property to find out possible issue because
             * of which request did fail.
             *
             * Request can be resent using: [status retry];
             */
        }
    });
```

#### Remove all mobile push notifications, using builder pattern (FCM)

```objectivec
self.client.push().disableAll()
    .token(self.devicePushToken)
    .pushType(PNFCMPush)
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
            /**
             * Push notification successfully disabled for all channels associated with specified
             * device push token.
             */
        } else {
            /**
             * Handle modification error. Check 'category' property to find out possible issue because
             * of which request did fail.
             *
             * Request can be resent using: [status retry];
             */
        }
    });
```

### Response

Response object returned by the client when the `APNS Remove All Devices` API is used:

```objectivec
@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
```

## Terms in this document

* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
* **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.