3

I have a iOS app which triggers a local notification every 4 hours or so. This seems to be working successfully as expected. My concern though is what to do if the user reboots the device. Will any existing local notifications still exist? Here's how I trigger a local notification:

    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)

If the user restarts the device within the 4 hours, will the local notification still be triggered? If not, is there any way my application can be informed when the device completes a reboot and I can setup the necessary local notification? Thanks for your help!

kevin.w.johnson
  • 1,684
  • 3
  • 18
  • 37
  • 1
    These may be helpful: http://stackoverflow.com/questions/9284740/local-notifications-that-expire-while-device-is-turned-off-are-lost http://stackoverflow.com/questions/8573013/uilocalnotification-when-iphone-switched-off – Paulius Dragunas Nov 30 '14 at 21:13
  • Had same issue using latest veriosn 0.9.0-beta.3 of local notification. – Husain Mar 07 '19 at 13:05

1 Answers1

0

The notifications will be gone after reboot. (This is easy to test, BTW.)

You can check active notifications when the app starts with the UIApplication API:

UIApplication.sharedApplication().scheduledLocalNotifications

You could use the notifications' userInfo dictionary attribute to identify them if you need to.

Mundi
  • 79,884
  • 17
  • 117
  • 140