我需要在UILocalNotification
删除相同的cancelLocalNotification:
之后提交UILocalNotification cancelLocalNotification:
。问题是删除执行速度比启动新执行缓慢并删除刚添加的通知。
如何确定setup_module
已完成?
答案 0 :(得分:2)
您可以在致电UILocalNotification cancelLocalNotification:
后稍等一下
并再次注册新的UILocalNotification
像这样的东西
[[UIApplication sharedApplication] cancelLocalNotification:someNotification];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
/* register UILocalNotification again here after delay */
});
答案 1 :(得分:0)
如果您希望以特定的计时器间隔调用通知,或者在第一个计时器间隔结束后调用,则本地通知自身具有NSCalendarUnit
属性,值应为-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
// I recieved a notification
}
。并使用特定的计时器重复。
否则第二个选项在委托方法下面总是调用
localNotification.fireDate = [NSDate date];
当你在块中获得通知时
您可以删除所有本地通知并创建具有开火日期的新通知
{{1}}
答案 2 :(得分:0)
尝试检查,
[[UIApplication sharedApplication] scheduledLocalNotifications]
这将返回预定通知数组。
您可以检查数组或NSLog数组的数量,并在取消本地通知时获取详细信息。