I am using beacons in my app (app set to background) and I am setting series of UILocalNotifications on beacon:DidExitRegion:
(kind of alarm when beacon is lost).
Edit: When app is in the background, user exits region, then the notifications are set properly. When user wants to close the app while it's still being in background with the notifications set, I want to disable them all. /edit
The problem is, that I want to disable all those notifications in AppWillTerminate
. According to documetation when app is in suspended state (waiting in background for getting signal from the beacon - CoreLocation), the appWillTerminate
is not called. Users will often close the app while it is in background and alarms-notifications will not be removed.
What is the possible way to get rid of those notifications?
I've got 1 suggestion:
perform "artificial" finite-length tasks in background (like here)
and actually run the app after receiving beacon:didExitRegion:
-> it doesn't get suspended, appWillTerminate
will be called.
It will, however work only for max 10 minutes and I don't think it's elegant thing to do.
Maybe other ways to do it? Thanks.