为什么本地通知在重复间隔设置为1秒(NSSecCalendarUnit)1分钟后重复?
我试图安排一次当地的通知,一旦通知被解雇,将在每隔1秒后重复。 通知在应用程序启动10秒后触发。
UILocalNotification *notif = [[cls alloc] init]; notif.fireDate = [[NSDate alloc]initWithTimeInterval:10 sinceDate:[NSDate date]]; notif.timeZone = [NSTimeZone defaultTimeZone]; notif.alertBody = @"Did you forget something?"; notif.alertAction = @"Show me"; //notif.soundName = UILocalNotificationDefaultSoundName; notif.soundName = @"applause-light-01.wav"; notif.applicationIconBadgeNumber = 1; notif.repeatInterval = NSSecondCalendarUnit; [[UIApplication sharedApplication] scheduleLocalNotification:notif];
甚至认为我已经使用notif.repeatInterval = NSSecondCalendarUnit
,通知60秒后重复。 我做错了什么?
notif.fireDate = [[NSDate alloc]initWithTimeInterval:10 sinceDate:[NSDate date]];
在创build新date后,这行代码会使您的本地通知被触发。 如果你想立即通知你,那么你应该创build一个这样的简单date,
notif.fireDate = [NSDate date];
希望这可以帮助。