设备重启时的本地通知

3

我有一个iOS应用程序,每隔4个小时左右触发本地通知。这似乎按预期成功运行。但是我的担忧是如果用户重新启动设备会怎样。是否仍然存在任何已有的本地通知?以下是我如何触发本地通知的方式:

    var localNotification:UILocalNotification = UILocalNotification()
    localNotification.alertAction = "report_alarm"
    localNotification.alertBody = "Please file report"
    localNotification.fireDate = NSDate(timeIntervalSinceNow: 4 * 60 * 60)
    localNotification.soundName = UILocalNotificationDefaultSoundName
    UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

如果用户在4小时内重新启动设备,本地通知是否仍会触发?如果不会,我的应用程序有没有办法在设备完成重启时得到通知并设置必要的本地通知?感谢您的帮助!


1
这些可能会有帮助:https://dev59.com/amDVa4cB1Zd3GeqPdW9Ihttps://dev59.com/n17Va4cB1Zd3GeqPKHkp - Paulius Dragunas
使用本地通知的最新版本0.9.0-beta.3时,遇到了相同的问题。 - Husain
1个回答

0

通知将在重新启动后消失。(顺便说一下,这很容易测试。)

您可以使用UIApplication API在应用程序启动时检查活动通知:

UIApplication.sharedApplication().scheduledLocalNotifications

如果需要,您可以使用通知的userInfo字典属性来识别它们。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接