Question

I am developing an iPhone app that delivers alerts at certain times using UILocalNotifications. Pressing the OK button on the alert launches the app so it can perform specific tasks.

So far, everything works beautifully in most cases: if the app is running and the alert fires, it works fine, and if the app is not running (but the phone is on), it works just as well.

However, if the alert fires when the screen is locked, one of two things happens.

  1. alert fires, and I "slide to unlock" immediately, then the app launches as expected.
  2. alert fires, but I wait to "slide to unlock" longer than 20 seconds (the time it takes the screen to lock (dim) again). When I finally unlock the screen, the alert shows, but does NOT launch the app.

I have looked throughout the Apple docs and this site, but cannot find an answer. I hope my explanation makes sense. Any thoughts?

Was it helpful?

Solution

I think that behaviour makes sense and shouldn't be circumvented (which I think is not possible). If the user slides to unlock just after a few seconds after the notification, the propability is high, that he slided to unlock just because of that notification and wants to get into the app. If a lot of time is passed, the notification is still shown, but the propability is low, that the user slides to unlock because of this notification. It is more likely that he just wants to write an email or do something completely different. So the app of the last notification shouldn't get started.

OTHER TIPS

Thanks for your quick and clear answer, Dominik. Quick follow-up: the purpose in relaunching the app is to schedule another alert. If I send several alerts at once (scheduled for different times), and the user does not unlock the phone for any of them, do they all appear at the same time the first time the user unlocks? (I would only want the last one to appear)

Thanks again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top