How to remove specific remote notification in the notification center
If you're simply looking to remove one number from the badge number:
[UIApplication sharedApplication].applicationIconBadgeNumber = MAX([UIApplication sharedApplication].applicationIconBadgeNumber - 1, 0);
If you're asking how to programmatically remove a single notification from notification center, it can't be done in code. Apparently in iOS8 the OS will remove a single notification when a user taps on it. Otherwise it's not possible to be handled by you.
See: https://stackoverflow.com/a/10569847/620577
Programmatically delete Remote Notifications from Notification Centre
Finally...
This one works like charm!
[[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
Is it possible to delete specific push notifications from the Notification Center?
As per the documentation you can remove a specific notification from the notification center using removeDeliveredNotifications(withIdentifiers:) method.
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [yourNotificationIdentifier])
You can specify an identifier for the remote notification as well, as per the documentation of identifier:
For remote notifications, it is set to the value of the
apns-collapse-id key that you specified in the APNs request header
when generating the remote notification. If no value is set, the
system automatically assigns an identifier.
Remove single remote notification from Notification Center
There is no way to remove a specific notification as of iOS SDK 5.0. The way to remove all the notifications from your app so they don't show in the Notification Center when the user opens the app from one of them, is to set the app badge to 0, like this:
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
EDIT: on iOS 8, SpringBoard seems to be automatically dismissing a notification when you tap on it on the Notification Center to open the app.
Remove a particular push notification from notification center tray
Every notification has an identifier and after reading a notification you can simply do -
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [notification_identifier_here])
Related Topics
Gamecenter Authentication in Landscape-Only App Throws Uiapplicationinvalidinterfaceorientation
Is There an iPhone Se Simulator for Xcode 11, iOS 13
How to Create a New Swift Project Without Using Storyboards
How to Get Uiscrollview Vertical Direction in Swift
Crashlytics in iOS Won't Proceed Past "Build Your Project" in Fabric App
How to Hide Status Bar in Uiimagepickercontroller
Save Image Data to SQLite Database in Iphone
Write Extend File Attributes Swift Example
Xcode 10.2 with Swift 5.0 Compiler - Protocol Inheritance Issue
iOS 5 JSON Parsing Results in Cocoa Error 3840
How to Download a File and Save It to the Documents Directory with Afnetworking
What Is Prefix.Pch File in Xcode
Find the Tangent of a Point on a Cubic Bezier Curve
How to Use Addtarget Method in Swift 3
How to Disable Control Center in iOS 7 Programmatically and If Not, What Are Alternatives
Could Not Load the "" Image Referenced from a Nib in the Bundle with Identifier