我正在尝试安排一个本地通知,一旦通知被触发,该通知将每 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]];
这行代码使您的本地通知在创建新日期后触发。如果您想要立即收到通知,那么您应该创建一个像这样的简单日期,
notif.fireDate = [NSDate date];
希望这可以帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)