Advertisement
luuksweb

Delete local notification

Sep 20th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // AppDelegate.m
  2.  
  3. - (void)deleteNotif:(id)sender{
  4.     NSCalendar *calendarDeleteNotif = [NSCalendar currentCalendar];
  5.     NSDateComponents *dateCompsDeleteNotif = [calendarDeleteNotif components:(NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:[NSDate date]];
  6.     [dateCompsDeleteNotif setSecond:0.5];
  7.    
  8.     if ([NSDate date] == dateCompsDeleteNotif) {
  9.         [[UIApplication sharedApplication] cancelAllLocalNotifications];
  10.         [self deleteNotif:(id)self];
  11.         NSLog(@"NSLog: cancelAllLocalNotifications done");
  12.     }
  13. }
  14.  
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
  16.     [self deleteNotif:(id)self];
  17. }
  18.  
  19. - (void)applicationDidEnterBackground:(UIApplication *)application{
  20.     [self deleteNotif:(id)self];
  21. }
  22.  
  23. - (void)applicationWillTerminate:(UIApplication *)application{
  24.     [self deleteNotif:(id)self];
  25. }
  26.  
  27. // End of code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement