iPhone - deactivate CLLocationManager events when in background mode
I have an app that uses the CLLocationManager to receive location and heading updates. When the app in sent to background mode, the CLLocationManager still receive events (catched in the debugger while the app is not onscreen).
Am I obliged to trap the "sent to background" event and use a BOOL to exit the event delegate method to forget those updates, or stop/restart the CLLocationManager ?
or is there another solution to stop receiving those events when in background ?
I'd like to prevent this not to do useless actions, and possibly reduce battery, as I don't need those events.
I know there is a project.plist param to set to force iOS to continue sending location events to the app even if it's in background. I didn't set that parameter. So I guess there is a way to tell iOS that I don't want those events when i开发者_如何转开发n background...
Use next methods of UIApplicationDelegate
:
-(void)applicationDidBecomeActive:(UIApplicetion*)application;
-(void)applicationWillResignActive:(UIApplicetion*)application;
-(void)applicationDidEnterBackground:(UIApplicetion*)application;
-(void)applicationWillEnterForeground:(UIApplicetion*)application;
精彩评论