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;
1- (void)addPushNotificationsOnChannels:(NSArray<NSString *> *)channels
2 withDevicePushToken:(id)pushToken
3 pushType:(PNPushType)pushType
4 andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)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;
channelsrequired#- Channels to enable for push notifications.
pushTokenrequired#- Device token (
NSDatafor APNS/APNS2,NSStringotherwise). pushTyperequired#- One of:
PNAPNSPush,PNAPNS2Push,PNFCMPush,PNMPNSPush. environmentrequired#- APNs environment.
topicrequired#- APNs topic (bundle identifier).
block#- 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.
show all 20 linesResponse
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
show all 16 linesOther 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 }
show all 16 linesExample 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];
show all 18 linesAdd 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. See Enable the features your app calls.
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);
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);
channelsrequired#- Channels to enable for push notifications.
fcmTokenrequired#- FCM-provided device push token which should be used to enable mobile push notifications on a specified set of
channels. completion#- 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];
show all 18 linesFCM 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 }
show all 16 linesResponse
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
show all 16 linesList 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. See Enable the features your app calls.
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;
pushTokenrequired#- Device push token against which search on PubNub service should be performed.
blockrequired#- 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;
1- (void)pushNotificationEnabledChannelsForDeviceWithPushToken:(id)pushToken
2 pushType:(PNPushType)pushType
3 environment:(PNAPNSEnvironment)environment
4 topic:(NSString *)topic
5 andCompletion:(PNPushNotificationsStateAuditCompletionBlock)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
show all 19 linesResponse
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
show all 16 linesOther 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 */
show all 17 linesList 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. See Enable the features your app calls.
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);
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);
fcmTokenrequired#- FCM-provided device
push tokenagainst which search on PubNub service should be performed. completionrequired#- 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];
show all 18 linesFCM 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 }
show all 16 linesResponse
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
show all 16 linesRemove 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. See Enable the features your app calls.
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;
channelsrequired#- List of channel names for which mobile push notifications should be disabled.
If passed list is empty all notifications will be disabled. pushTokenrequired#- Device push token which should be used to disable push
notificationson specified set ofchannels. block#- 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;
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;
channelsrequired#- List of channel names for which mobile push notifications should be disabled.
pushTokenrequired#- Device token / identifier that you must set to
NSData. pushTyperequired#- One of:
PNAPNS2Push,PNFCMPush. environmentrequired#- APNs environment.
topicrequired#- APNs topic (bundle identifier).
block#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.
show all 20 linesResponse
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
show all 16 linesOther 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 }
show all 16 linesExample 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];
show all 18 linesRemove 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. See Enable the features your app calls.
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);
channelsrequired#- List of channel names for which mobile push notifications should be disabled.
tokenrequired#- Device token / identifier that you must set to
NSData. pushTyperequired#- One of:
PNFCMPush. environment#- APNs environment.
topic#- APNs topic (bundle identifier).
block#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);
channelsrequired#- List of channel names for which mobile push notifications should be disabled.
If passed list is empty all notifications will be disabled. fcmTokenrequired#- FCM-provided device push token which should be used to disable push
notificationson specified set ofchannels. completion#- 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];
show all 18 linesFCM 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 */
show all 17 linesResponse
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
show all 16 linesRemove 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. See Enable the features your app calls.
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;
pushTokenrequired#- Device push token which should be used to disable push
notificationson specified set ofchannels. block#- 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;
1- (void)removeAllPushNotificationsFromDeviceWithPushToken:(id)pushToken
2 pushType:(PNPushType)pushType
3 environment:(PNAPNSEnvironment)environment
4 topic:(NSString *)topic
5 andCompletion:(nullable PNPushNotificationsStateModificationCompletionBlock)block;
channelsrequired#- List of channel names for which mobile push notifications should be disabled.
pushTokenrequired#- Device token / identifier that you must set to
NSData. pushTyperequired#- One of:
PNAPNS2Push. environmentrequired#- APNs environment.
topicrequired#- APNs topic (bundle identifier).
block#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.
show all 22 linesResponse
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
show all 16 linesOther 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. See Enable the features your app calls.
Method(s)
1push()
2 .disableAll()
3 .token(id)
4 .pushType(PNPushType)
5 .environment(PNAPNSEnvironment)
6 .topic(NSString *)
7 .performWithCompletion(nullable PNPushNotificationsStateModificationCompletionBlock);
tokenrequired#- Device token / identifier which depending from passed
pushTypeshould beNSData(forPNAPNS2Push) orNSStringfor other. pushTyperequired#- One of:
PNAPNS2Push,PNFCMPush. environment#- APNs environment.
topic#- APNs topic (bundle identifier).
block#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.
show all 20 linesResponse
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
show all 16 lines