【APNs】Scheduling the Delivery of Local Notifications

来源:互联网 发布:eclipse优化运行速度 编辑:程序博客网 时间:2024/06/05 09:23
- (void)scheduleAlarmForDate:(NSDate*)theDate  {      UIApplication* app = [UIApplication sharedApplication];      NSArray*    oldNotifications = [app scheduledLocalNotifications];      // Clear out the old notification before scheduling a new one.      if ([oldNotifications count] > 0)          [app cancelAllLocalNotifications];      // Create a new notification.      UILocalNotification* alarm = [[UILocalNotification alloc] init];      if (alarm)      {          alarm.fireDate = theDate;          alarm.timeZone = [NSTimeZone defaultTimeZone];          alarm.repeatInterval = 0;          alarm.soundName = @"alarmsound.caf";          alarm.alertBody = @"Time to wake up!";          [app scheduleLocalNotification:alarm];      }}


Schedule and Post Local Notification

0 0