Reputation: 12499
I've enabled the background mode for location updates. I create an scheduled local notification, and I'd like to be able to stop the location services when it is fired and the app is running in background.
It seems that the didReceiveLocalNotification
method is only called when the app is in foreground, or it is in background and the user taps it, is there any way to notice that it is fired while the app is in background, but the user doesn't tap it?
Upvotes: 4
Views: 590
Reputation: 291
I hope this might help
When the system delivers a local notification, several things can happen, depending on the app state and the type of notification. If the app is not frontmost and visible, the system displays the alert message, badges the app, and plays a sound—whatever is specified in the notification. If the notification is an alert and the user taps the action button (or, if the device is locked, drags open the action slider), the app is woken up or launched. (If the user taps one of the custom actions you specify using the additionalActions property, the app is woken up or launched into the background.) In its application:didFinishLaunchingWithOptions: method, the app delegate can obtain the UILocalNotification object from the launch options dictionary using the UIApplicationLaunchOptionsLocalNotificationKey key. The delegate can inspect the properties of the notification and, if the notification includes custom data in its userInfo dictionary, it can access that data and process it accordingly. On the other hand, if the local notification only badges the app icon, and the user in response launches the app, the application:didFinishLaunchingWithOptions: method is called, but no UILocalNotification object is included in the options dictionary. When the user selects a custom action, the app delegate’s application:handleActionWithIdentifier:forLocalNotification:completionHandler: method is called to handle the action.
This from Apple documentation.
Upvotes: 1