Guest User

Untitled

a guest
Jan 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. - (void)applicationDidEnterBackground:(UIApplication *)application
  2. {
  3. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  4. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  5. (UIApplication *)application;
  6. {
  7. NSDate *alertTime = [[NSDate date]
  8. dateByAddingTimeInterval:10];
  9. UIApplication* app = [UIApplication sharedApplication];
  10. UILocalNotification* notifyAlarm = [[UILocalNotification alloc]
  11. init];
  12. if (notifyAlarm)
  13. {
  14. notifyAlarm.fireDate = alertTime;
  15. notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
  16. notifyAlarm.repeatInterval = 0;
  17. notifyAlarm.soundName = @"Ping.aiff";
  18. notifyAlarm.alertBody = @"Message Test..";
  19. [app scheduleLocalNotification:notifyAlarm];
  20. }
  21. }
  22. }
  23.  
  24. NSDateComponents *comps = [[NSDateComponents alloc] init];
  25. [comps setDay:28];
  26. [comps setMonth:9];
  27. [comps setYear:2012];
  28. [comps setHour:17];
  29. [comps setMinute:30];
  30. NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  31. NSDate *fireDate = [gregorian dateFromComponents:comps];
  32.  
  33. // Setup local notification
  34. UILocalNotification *alarm = [[UILocalNotification alloc] init];
  35. //... set the message, repeat interval, sound etc.
  36. alarm.fireDate = fireDate;
  37. alarm.repeatInterval = NSWeekCalendarUnit;
  38.  
  39. // Schedule the notification
  40. [[UIApplication sharedApplication] scheduleLocalNotification:alarm];
Add Comment
Please, Sign In to add comment