Aditya Kaushik
Aditya Kaushik

Reputation: 261

sample code for canceling the local notification in iphone

Sample code for canceling the local notification.

I am having a application which sets a local notification and now i want to cancel one of the local notification set the by the application can someone provide the sample code for the same

Upvotes: 0

Views: 1351

Answers (1)

winsmith
winsmith

Reputation: 21612

Cancel all local notifications with this code:

[[UIApplication sharedApplication] cancelAllLocalNotifications];

(you actually just need the middle line.


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: http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html

Upvotes: 1

Related Questions