Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. void LocalNotification(NSString* body, int seconds, NSString* action)
  2. {
  3. UILocalNotification *localNotification = [ [UILocalNotification alloc] init ];
  4. if(localNotification == nil)
  5. {
  6. return;
  7. }
  8.  
  9. // Set the fire date/time
  10. [ localNotification setFireDate: [ [NSDate date] dateByAddingTimeInterval: seconds ] ];
  11. [ localNotification setTimeZone: [NSTimeZone defaultTimeZone] ];
  12.  
  13. localNotification.applicationIconBadgeNumber = 1;
  14.  
  15. [ localNotification setHasAction: ![action isEqual:@""] ];
  16. if( [localNotification hasAction] )
  17. {
  18. [localNotification setAlertAction: action];
  19. }
  20.  
  21. [localNotification setAlertBody: body];
  22.  
  23. localNotification.soundName=UILocalNotificationDefaultSoundName;
  24. [localNotification setHasAction: NO];
  25. UIApplication *app = [UIApplication sharedApplication];
  26. [app scheduleLocalNotification: localNotification];
  27.  
  28. NSLog(@"LocalNotification in %@ (%@)\nfor %@", localNotification.fireDate, localNotification.timeZone, localNotification.alertBody);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement