I am making an application that sets a local notification.
Thankfully I was able to set the local notification but I don't know how to delete the notification which is set by my application.
The XCode does provide functionality of delete with removeAllNotifications
but you cannot remove specific notifications set by the application.
Thanks a lot.
Use local notifications to get the user's attention. You can display an alert, play a sound, or badge your app's icon. For example, a background app could ask the system to display an alert when your app finishes a particular task. Always use local notifications to convey important information that the user wants.
But in iOS we can't schedule more than 64 notifications at a time.
To remove all pending notification requests use the removeAllPendingNotificationRequests() method.
You asked this question twice, so I'm answering on both questions in the hopes of it reaching you:
Cancel all local notifications with this code:
[[UIApplication sharedApplication] cancelAllLocalNotifications];
Cancel one local notification with this line of code:
[[UIApplication sharedApplication] cancelLocalNotification:theNotification];
where theNotification
is a UILocalNotification
object, so in order to cancel a specific notification you need to hold on to it's UILocalNotification
.
You can find more stuff in apple's documentation.
[[UIApplication sharedApplication] cancelLocalNotification:notification]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With