Reputation: 103
What do I have to do that I can cancel a specific UILocalNotification?
Upvotes: 1
Views: 45
Reputation: 5695
I believe you are looking a way to cancel specific local notification. If that is what you are looking for, this might help you.
The following is the code for cancelling a local notification.
[[UIApplication sharedApplication] cancelLocalNotification:localNotification]
For identifying the specific UILocalNotification if your notification is not global.
for (UILocalNotification *localNotification in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
NSDictionary* userInfo = localNotification.userInfo;
if ([[userInfo objectForKey:@"name"] isEqualToString:@"NAME_OF_NOTIFICATION"]) {
[[UIApplication sharedApplication] cancelLocalNotification:localNotification];
break;
}
}
Here, I used UILocalNotifications userinfo to identify the specific UILocalNotification. You can use other things like alertTitle etc. to identify different UILocalNotifications
Hope it helps :)
Upvotes: 3