Deleting a deleted notification in action center

We all know that this method [UIApplication sharedApplication].applicationIconBadgeNumber = 0;

could remove all of our app's remote notifications from the notification center. However, for some reason I want to delete the one that the user deletes in the action center and leave the rest.

Does he have any method?

+3


source to share


2 answers


If you just want to remove one number from the badge number:

[UIApplication sharedApplication].applicationIconBadgeNumber = MAX([UIApplication sharedApplication].applicationIconBadgeNumber - 1, 0);



If you are asking how to programmatically remove a single notification from the action center, it cannot be done in code. Obviously in iOS8 the OS removes one notification when the user taps on it. Otherwise, you will not be able to process you.

See: fooobar.com/questions/134683 / ...

+4


source


With the introduction UNUserNotificationCenter

for iOS 10 and up, it is now possible to remove some or all of your app's deleted notifications.

UNUserNotificationCenter Documentation



With a common singleton instance of this class, you can manage remote remote notifications on a device. In particular, the following methods can be used: func removeDeliveredNotifications(withIdentifiers: [String])

if you want to remove a specific notification about your application, OR func removeAllDeliveredNotifications()

to remove all notifications about your application.

0


source







All Articles