我正在用以下代码调度一个UILocalNotification:
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [[NSDate date] dateByAddingTimeInterval:60];
notification.repeatInterval = NSMinuteCalendarUnit;
notification.alertBody = [NSString stringWithFormat:@"Wurmprophylaxe für Lassy”];
notification.alertAction = @"Wurmprophylaxe";
//notification.userInfo = userInfo;
notification.timeZone = [NSTimeZone localTimeZone];
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];在我终止应用程序、重新启动应用程序或重新运行xcode之前,notofication都会触发。简单地说,它不会持续下去。而且,即使应用程序再次运行,它也不会再次启动。应用程序是否在前台并不重要。一旦终止,通知就停止运行,如果我列出本地通知,它将不再存在。UILocalNotification似乎没有被存储。如果应用程序处于前台、背景或运行状态,则不会传递通知。
为什么它在应用程序启动之间被删除?
注意:如果我安排了一个新的通知,之前的通知也会被删除。这太奇怪了。
发布于 2015-02-03 17:40:39
这是正常的行为。用户“终止”应用程序将积极清除系统为该应用程序管理的任何进程。(编辑:对于许多后台进程,这是正确的,但对于本地通知可能不是这样。)通过Xcode重新加载一个新应用程序肯定会。
该应用程序的正常过程是先进入后台状态,然后在后台由系统终止。系统管理的任务将继续进行,如果有必要,应用程序将被重新唤醒。
https://stackoverflow.com/questions/28304411
复制相似问题