在我打开应用程序之前,我的应用程序不会停止发送我在特定时间设置的通知。它会像我每2分钟那样发送给我一点提醒我......
(void)applicationDidEnterBackground:(UIApplication *)application {
NSCalendar * calendar3 = [NSCalendar currentCalendar]; NSDateComponents * components3 = [calendar3 components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit)fromDate:[NSDate date]]; [components3 setHour:21]; [components3 setMinute:30]; UIApplication * app3 = [UIApplication sharedApplication]; UILocalNotification * notifyAlarm3 = [[UILocalNotification alloc] init]; if(notifyAlarm3){ notifyAlarm3.fireDate = [calendar3 dateFromComponents:components3]; notifyAlarm3.timeZone = [NSTimeZone defaultTimeZone]; notifyAlarm3.repeatInterval = NSDayCalendarUnit; notifyAlarm3.soundName = @“not.wav”; notifyAlarm3.alertBody = @“你好”; [app3 scheduleLocalNotification:notifyAlarm3]; } }
期待回应!