Mobile Push Notifications API for Cocoa Objective-C 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
Requires Mobile Push Notifications add-on
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)
To run Adding Device to Channel you can use the following method(s) in the Cocoa SDK:
1- (void)addPushNotificationsOnChannels:(NSArray<NSString *> *)channels
2                   withDevicePushToken:(NSData *)pushToken
3                         andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
| Parameter | Description | 
|---|---|
| channels*Type: NSArray | Channels to enable for push notifications. | 
| pushToken*Type: NSData | Device push token. | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Completion block with request status. | 
1- (void)addPushNotificationsOnChannels:(NSArray<NSString *> *)channels
2                   withDevicePushToken:(id)pushToken
3                              pushType:(PNPushType)pushType
4                         andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
| Parameter | Description | 
|---|---|
| channels*Type: NSArray <NSString *>* | Channels to enable for push notifications. | 
| pushToken*Type: id | Device token ( NSDatafor APNS/APNS2,NSStringotherwise). | 
| pushType*Type: PNPushType | One of: PNAPNSPush,PNAPNS2Push,PNFCMPush,PNMPNSPush. | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Completion block. | 
1- (void)addPushNotificationsOnChannels:(NSArray<NSString *> *)channels
2                   withDevicePushToken:(id)pushToken
3                              pushType:(PNPushType)pushType
4                           environment:(PNAPNSEnvironment)environment
5                                 topic:(NSString *)topic
6                         andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
| Parameter | Description | 
|---|---|
| channels*Type: NSArray <NSString *> | Channels to enable for push notifications. | 
| pushToken*Type: id | Device token ( NSDatafor APNS/APNS2,NSStringotherwise). | 
| pushType*Type: PNPushType | One of: PNAPNSPush,PNAPNS2Push,PNFCMPush,PNMPNSPush. | 
| environment*Type: PNAPNSEnvironment | APNs environment. | 
| topic*Type: NSString | APNs topic (bundle identifier). | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Completion block. | 
Sample code
Add device to channel
1[self.client addPushNotificationsOnChannels:@[@"wwdc",@"google.io"]
2                        withDevicePushToken:self.devicePushToken
3                              andCompletion:^(PNAcknowledgmentStatus *status) {
4
5    if (!status.isError) {
6
7    // Handle successful push notification enabling on passed channels.
8    }
9    else {
10
11        /**
12         Handle modification error. Check 'category' property
13         to find out possible reason because of which request did fail.
14         Review 'errorData' property (which has PNErrorData data type) of status
15         object to get additional information about issue.
Response
Response objects which is returned by client when APNS Add Device API is used:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
Other examples
Example for method no. 2
1[self.client addPushNotificationsOnChannels:@[@"wwdc",@"google.io"]
2                        withDevicePushToken:self.devicePushToken
3                                    pushType:PNAPNSPush
4                                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 because
11            * of which request did fail.
12            *
13            * Request can be resent using: [status retry];
14            */
15    }
Example for method no. 3
1[self.client addPushNotificationsOnChannels:@[@"wwdc",@"google.io"]
2                        withDevicePushToken:self.devicePushToken
3                                    pushType:PNAPNS2Push
4                                environment:PNAPNSProduction
5                                        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 because
13            * of which request did fail.
14            *
15            * Request can be resent using: [status retry];
Add device to channel (builder pattern)
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. Read the support page on enabling add-on features on your keys.
Enable mobile push notifications on provided set of channels.
Method(s)
To run Adding Device to Channel you can use the following method(s) in the Cocoa SDK
APNS2 token
1push()
2    .enable()
3    .channels(NSArray<NSString *> *)
4    .token(id)
5    .pushType(PNPushType)
6    .environment(PNAPNSEnvironment)
7    .topic(NSString *)
8    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
| Parameter | Description | 
|---|---|
| channels*Type: NSArray <NSString *> | Channels to enable for push notifications. | 
| token*Type: id | Device token / identifier that you must set to NSData. | 
| pushType*Type: PNPushType | One of: PNAPNSPush,PNAPNS2Push,PNFCMPush,PNMPNSPush. | 
| environmentType: PNAPNSEnvironment | APNs environment. | 
| topicType: NSString | APNs topic (bundle identifier). | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Completion block. | 
Optional arguments
This method uses the builder pattern, you can remove the arguments which are optional.
FCM token
1push()
2    .enable()
3    .fcmToken(NSString *)
4    .channels(NSArray<NSString *> *)
5    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
| Parameter | Description | 
|---|---|
| channels*Type: NSArray <NSString *>* | Channels to enable for push notifications. | 
| fcmToken*Type: NSString * | FCM-provided device push token which should be used to enable mobile push notifications on a specified set of channels. | 
| completionType: PNPushNotificationsStateModificationCompletionBlock | Push notifications addition on channelsprocessingcompletion blockwhich pass only one argument - request processing status to report about how data pushing was successful or not. | 
Optional arguments
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
APNS2 token
1self.client.push().enable()
2    .token(self.devicePushToken)
3    .channels(@[@"wwdc",@"google.io"])
4    .pushType(PNAPNS2Push)
5    .environment(PNAPNSProduction)
6    .topic(@"com.my-application.bundle")
7    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
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 because
13             * of which request did fail.
14             *
15             * Request can be resent using: [status retry];
FCM token
1self.client.push().enable()
2    .token(self.devicePushToken)
3    .channels(@[@"wwdc",@"google.io"])
4    .pushType(PNFCMPush)
5    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
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 because
11             * of which request did fail.
12             *
13             * Request can be resent using: [status retry];
14             */
15        }
Response
Response objects which is returned by client when APNS Add Device API is used:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
List channels for device
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. Read the support page 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 Cocoa SDK:
1- (void)pushNotificationEnabledChannelsForDeviceWithPushToken:(NSData *)pushToken
2                                                andCompletion:(PNPushNotificationsStateAuditCompletionBlock)block;
| Parameter | Description | 
|---|---|
| pushToken*Type: NSData | Device push token against which search on PubNub service should be performed. | 
| block*Type: PNPushNotificationsStateAuditCompletionBlock | Push notificationsstatus processing completionblockwhich pass two arguments: result - in case of successful request processing data field will contain results of pushnotificationsaudit operation; status - in case if error occurred during request processing. | 
1- (void)pushNotificationEnabledChannelsForDeviceWithPushToken:(id)pushToken
2                                                     pushType:(PNPushType)pushType
3                                                andCompletion:(PNPushNotificationsStateAuditCompletionBlock)block;
| Parameter | Description | 
|---|---|
| pushToken*Type: id | Device token / identifier that you must set to NSString. | 
| pushType*Type: PNPushType | One of: PNFCMPush. | 
| block*Type: PNPushNotificationsStateAuditCompletionBlock | Audit notifications enabled channelsrequest completion block. | 
1- (void)pushNotificationEnabledChannelsForDeviceWithPushToken:(id)pushToken
2                                                     pushType:(PNPushType)pushType
3                                                  environment:(PNAPNSEnvironment)environment
4                                                        topic:(NSString *)topic
5                                                andCompletion:(PNPushNotificationsStateAuditCompletionBlock)block;
| Parameter | Description | 
|---|---|
| pushToken*Type: id | Device token / identifier that you must set to NSData. | 
| pushType*Type: PNPushType | One of: PNAPNS2Push. | 
| environment*Type: PNAPNSEnvironment | APNs environment. | 
| topic*Type: NSString | APNs topic (bundle identifier). | 
| block*Type: PNPushNotificationsStateAuditCompletionBlock | Audit notifications enabled channelsrequest completion block. | 
Sample code
List channels for device
1[self.client pushNotificationEnabledChannelsForDeviceWithPushToken:self.devicePushToken
2                                                      andCompletion:^(PNAPNSEnabledChannelsResult *result,
3                                                                      PNErrorStatus *status) {
4      if (!status) {
5
6        // Handle downloaded list of channels using: result.data.channels
7    }
8    else {
9
10        /**
11         Handle audition error. Check 'category' property
12         to find out possible reason because of which request did fail.
13         Review 'errorData' property (which has PNErrorData data type) of status
14         object to get additional information about issue.
15
Response
Response objects which is returned by clientAPNS List Devices API is used:
1@interface PNAPNSEnabledChannelsData : PNServiceData
2
3// Channels with active mobile push notifications.
4@property (nonatomic, readonly, strong) NSArray<NSString *> *channels;
5
6@end
7
8@interface PNAPNSEnabledChannelsResult : PNResult
9
10// APNS enabled channels audit request processed information.
11@property (nonatomic, readonly, strong) PNAPNSEnabledChannelsData *data;
12
13@end
Error response which is used in case of APNS List Devices API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
Other examples
Example for method no. 2
1[self.client pushNotificationEnabledChannelsForDeviceWithPushToken:self.devicePushToken
2                            pushType:PNFCMPush
3                    andCompletion:^(PNFCMEnabledChannelsResult *result, PNErrorStatus *status) {
4
5    if (!status.isError) {
6        // Handle downloaded list of channels using: result.data.channels
7    } else {
8        /**
9            * Handle audition error. Check 'category' property to find out possible issue because of
10            * which request did fail.
11            *
12            * Request can be resent using: [status retry];
13            */
14    }
15}];
Example for method no. 3
1[self.client pushNotificationEnabledChannelsForDeviceWithPushToken:self.devicePushToken
2                            pushType:PNAPNS2Push
3                        environment:PNAPNSDevelopment
4                            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.channels
9    } else {
10        /**
11            * Handle audition error. Check 'category' property to find out possible issue because of
12            * which request did fail.
13            *
14            * Request can be resent using: [status retry];
15            */
List channels for device (builder pattern)
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. Read the support page 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 Cocoa SDK
APNS2 token
1push()
2    .audit()
3    .token(id)
4    .pushType(PNPushType)
5    .environment(PNAPNSEnvironment)
6    .topic(NSString *)
7    .performWithCompletion(PNPushNotificationsStateAuditCompletionBlock);
| Parameter | Description | 
|---|---|
| token*Type: id | Device token / identifier that you must set to NSData. | 
| pushType*Type: PNPushType | One of: PNFCMPush. | 
| environmentType: PNAPNSEnvironment | APNs environment. | 
| topicType: NSString | APNs topic (bundle identifier). | 
| block*Type: PNPushNotificationsStateAuditCompletionBlock | Audit notifications enabled channelsrequest completion block. | 
Optional arguments
This method uses the builder pattern, you can remove the arguments which are optional.
FCM token
1push()
2    .audit()
3    .fcmToken(NSString *)
4    .performWithCompletion(PNPushNotificationsStateModificationCompletionBlock);
| Parameter | Description | 
|---|---|
| fcmToken*Type: NSString * | FCM-provided device push tokenagainst which search on PubNub service should be performed. | 
| completion*Type: PNPushNotificationsStateAuditCompletionBlock | Push notificationsstatus processing completionblockwhich pass two arguments:result- in case of successful request processingdatafield will contain results of pushnotificationsaudit operation;status- in case if error occurred during request processing. | 
Optional arguments
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
APNS2 token
1self.client.push()
2    .audit()
3    .token(self.devicePushToken)
4    .pushType(PNAPNS2Push)
5    .environment(PNAPNSProduction)
6    .topic(@"com.my-application.bundle")
7    .performWithCompletion(^(PNAPNSEnabledChannelsResult *result, PNErrorStatus *status) {
8        if (!status.isError) {
9            // Handle downloaded list of channels using: result.data.channels
10        } else {
11            /**
12                * Handle audition error. Check 'category' property to find out possible issue because of
13                * which request did fail.
14                *
15                * Request can be resent using: [status retry];
FCM token
1self.client.push().audit()
2    .fcmToken(self.pushToken)
3    .performWithCompletion(^(PNAPNSEnabledChannelsResult *result, PNErrorStatus *status) {
4        if (!status) {
5            // Handle downloaded list of channels using: result.data.channels
6        } else {
7            /**
8                Handle audition error. Check 'category' property
9                to find out possible reason because of which request did fail.
10                Review 'errorData' property (which has PNErrorData data type) of status
11                object to get additional information about issue.
12
13                Request can be resent using: [status retry];
14            */
15        }
Response
Response objects which is returned by client when APNS List Devices API is used:
1@interface PNAPNSEnabledChannelsData : PNServiceData
2
3// Channels with active mobile push notifications.
4@property (nonatomic, readonly, strong) NSArray<NSString *> *channels;
5
6@end
7
8@interface PNAPNSEnabledChannelsResult : PNResult
9
10// APNS enabled channels audit request processed information.
11@property (nonatomic, readonly, strong) PNAPNSEnabledChannelsData *data;
12
13@end
Error response which is used in case of APNS List Devices API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
Remove device from channel
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. Read the support page on enabling add-on features on your keys.
Disable mobile push notifications on provided set of channels.
Method(s)
To run Removing Device From Channel you can use the following method(s) in the Cocoa SDK:
1- (void)removePushNotificationsFromChannels:(NSArray<NSString *> *)channels
2                        withDevicePushToken:(NSData *)pushToken
3                              andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
| Parameter | Description | 
|---|---|
| channels*Type: NSArray | List of channel names for which mobile push notifications should be disabled. If passed list is empty all notifications will be disabled. | 
| pushToken*Type: NSData | Device push token which should be used to disable push notificationson specified set ofchannels. | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Push notificationsremoval fromchannelsprocessing completionblockwhich pass only one argument - request processingstatusto report about how data pushing was successful or not. | 
1- (void)removePushNotificationsFromChannels:(NSArray<NSString *> *)channels
2                        withDevicePushToken:(id)pushToken
3                                   pushType:(PNPushType)pushType
4                              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 NSString. | 
| pushType*Type: PNPushType | One of: PNAPNS2Push. | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Remove notifications from channelsrequest completion block. | 
1- (void)removePushNotificationsFromChannels:(NSArray<NSString *> *)channels
2                        withDevicePushToken:(id)pushToken
3                                   pushType:(PNPushType)pushType
4                                environment:(PNAPNSEnvironment)environment
5                                      topic:(NSString *)topic
6                              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: PNAPNS2Push,PNFCMPush. | 
| environment*Type: PNAPNSEnvironment | APNs environment. | 
| topic*Type: NSString | APNs topic (bundle identifier). | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Remove notifications from channelsrequest completion block. | 
Sample code
Remove device from channel
1[self.client removePushNotificationsFromChannels:@[@"wwdc",@"google.io"]
2                                withDevicePushToken:self.devicePushToken
3                                    andCompletion:^(PNAcknowledgmentStatus *status) {
4
5    if (!status.isError) {
6
7        // Handle successful push notification disabling on passed channels.
8    }
9    else {
10
11        /**
12            Handle modification error. Check 'category' property
13            to find out possible reason because of which request did fail.
14            Review 'errorData' property (which has PNErrorData data type) of status
15            object to get additional information about issue.
Response
Response objects which is returned by client when APNS Remove Device API is used:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
Other examples
Example for method no. 2
1[self.client removePushNotificationsFromChannels:@[@"wwdc",@"google.io"]
2                                withDevicePushToken:self.devicePushToken
3                                        pushType:PNFCMPush
4                                    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 because
11            * of which request did fail.
12            *
13            * Request can be resent using: [status retry];
14            */
15    }
Example for method no. 3
1[self.client removePushNotificationsFromChannels:@[@"wwdc",@"google.io"]
2                                withDevicePushToken:self.devicePushToken
3                                        pushType:PNAPNS2Push
4                                        environment:PNAPNSProduction
5                                            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 because
13            * of which request did fail.
14            *
15            * Request can be resent using: [status retry];
Remove device from channel (builder pattern)
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. Read the support page on enabling add-on features on your keys.
Disable mobile push notifications on provided set of channels.
Method(s)
To run Removing Device From Channel, you can use the following method(s) in the Cocoa SDK.
APNS2 token
1push()
2    .disable()
3    .token(id)
4    .pushType(PNPushType)
5    .channels(NSArray<NSString *> *)
6    .environment(PNAPNSEnvironment)
7    .topic(NSString *)
8    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
| Parameter | Description | 
|---|---|
| channels*Type: NSArray <NSString *>* | List of channel names for which mobile push notifications should be disabled. | 
| token*Type: id | Device token / identifier that you must set to NSData. | 
| pushType*Type: PNPushType | One of: PNFCMPush. | 
| environmentType: PNAPNSEnvironment | APNs environment. | 
| topicType: NSString | APNs topic (bundle identifier). | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Remove notifications from channelsrequest completion block. | 
Optional arguments
This method uses the builder pattern, you can remove the arguments which are optional.
FCM token
1push()
2    .disable()
3    .fcmToken(NSString *)
4    .channels(NSArray<NSString *> *)
5    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
| Parameter | Description | 
|---|---|
| channels*Type: NSArray <NSString *>* | List of channel names for which mobile push notifications should be disabled. If passed list is empty all notifications will be disabled. | 
| fcmToken*Type: NSString * | FCM-provided device push token which should be used to disable push notificationson specified set ofchannels. | 
| completionType: PNPushNotificationsStateAuditCompletionBlock | Push notificationsremoval fromchannelsprocessing completionblockwhich pass only one argument - request processingstatusto report about how data pushing was successful or not. | 
Optional arguments
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
APNS token
1self.client.push().disable()
2    .token(self.devicePushToken)
3    .channels(@[@"wwdc",@"google.io"])
4    .pushType(PNAPNS2Push)
5    .environment(PNAPNSProduction)
6    .topic(@"com.my-application.bundle")
7    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
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 because
13                * of which request did fail.
14                *
15                * Request can be resent using: [status retry];
FCM token
1self.client.push().disable()
2    .channels(@[@"channel1", @"channel2"])
3    .fcmToken(self.pushToken)
4    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
5        if (!status.isError) {
6            // Handle successful push notification enabling on passed channels.
7        } else {
8            /**
9            Handle modification error. Check 'category' property
10            to find out possible reason because of which request did fail.
11            Review 'errorData' property (which has PNErrorData data type) of status
12            object to get additional information about issue.
13
14            Request can be resent using: [status retry];
15            */
Response
Response objects which is returned by client when APNS Remove Device API is used:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
Remove all mobile push notifications
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. Read the support page 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 Cocoa SDK:
1- (void)removeAllPushNotificationsFromDeviceWithPushToken:(NSData *)pushToken
2                                            andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
| Parameter | Description | 
|---|---|
| pushToken*Type: NSData | Device push token which should be used to disable push notificationson specified set ofchannels. | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Push notificationsremoval from device processing completionblockwhich pass only one argument - request processingstatusto report about how data pushing was successful or not. | 
1- (void)removeAllPushNotificationsFromDeviceWithPushToken:(id)pushToken
2                                                 pushType:(PNPushType)pushType
3                                            andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
| Parameter | Description | 
|---|---|
| pushToken*Type: id | Device token / identifier that you must set to NSString. | 
| pushType*Type: PNPushType | One of: PNFCMPush. | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Remove all notificationsrequest completion block. | 
1- (void)removeAllPushNotificationsFromDeviceWithPushToken:(id)pushToken
2                                                 pushType:(PNPushType)pushType
3                                              environment:(PNAPNSEnvironment)environment
4                                                    topic:(NSString *)topic
5                                            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: PNAPNS2Push. | 
| environment*Type: PNAPNSEnvironment | APNs environment. | 
| topic*Type: NSString | APNs topic (bundle identifier). | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Remove all notificationsrequest completion block. | 
Sample code
Remove all mobile push notifications
1[self.client removeAllPushNotificationsFromDeviceWithPushToken:self.devicePushToken
2                                                 andCompletion:^(PNAcknowledgmentStatus *status) {
3
4    if (!status.isError) {
5
6        /**
7         Handle successful push notification disabling for all channels associated with
8         specified device push token.
9         */
10    }
11    else {
12
13        /**
14         Handle modification error. Check 'category' property
15         to find out possible reason because of which request did fail.
Response
Response objects which is returned by client when APNS Remove All Devices API is used:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
Other examples
- 
Example For Method no. 2 
 show all 18 lines1[self.client removeAllPushNotificationsFromDeviceWithPushToken:self.devicePushToken
 2 pushType:PNFCMPush
 3 andCompletion:^(PNAcknowledgmentStatus *status) {
 4
 5 if (!status.isError) {
 6 /**
 7 * Push notification successfully disabled for all channels associated with specified
 8 * device push token.
 9 */
 10 } else {
 11 /**
 12 * Handle modification error. Check 'category' property to find out possible issue because
 13 * of which request did fail.
 14 *
 15 * Request can be resent using: [status retry];
- 
Example For Method no. 3 
 show all 20 lines1[self.client removeAllPushNotificationsFromDeviceWithPushToken:self.devicePushToken
 2 pushType:PNAPNS2Push
 3 environment:PNAPNSProduction
 4 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 specified
 10 * device push token.
 11 */
 12 } else {
 13 /**
 14 * Handle modification error. Check 'category' property to find out possible issue because
 15 * of which request did fail.
Remove all mobile push notifications (builder pattern)
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. Read the support page on enabling add-on features on your keys.
Method(s)
1push()
2    .disableAll()
3    .token(id)
4    .pushType(PNPushType)
5    .environment(PNAPNSEnvironment)
6    .topic(NSString *)
7    .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
| Parameter | Description | 
|---|---|
| token*Type: id | Device token / identifier which depending from passed pushTypeshould beNSData(forPNAPNS2Push) orNSStringfor other. | 
| pushType*Type: PNPushType | One of: PNAPNS2Push,PNFCMPush. | 
| environmentType: PNAPNSEnvironment | APNs environment. | 
| topicType: NSString | APNs topic (bundle identifier). | 
| blockType: PNPushNotificationsStateModificationCompletionBlock | Remove all notificationsrequest completion block. | 
Optional arguments
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
Remove all mobile push notifications, using builder pattern
1self.client.push().disableAll()
2    .token(self.devicePushToken)
3    .pushType(PNAPNS2Push)
4    .environment(PNAPNSProduction)
5    .topic(@"com.my-application.bundle")
6    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
7        if (!status.isError) {
8            /**
9             * Push notification successfully disabled for all channels associated with specified
10             * device push token.
11             */
12        } else {
13            /**
14             * Handle modification error. Check 'category' property to find out possible issue because
15             * of which request did fail.
Response
Response object returned by the client when APNS Remove All Devices API is used:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15