开发者

iPhone - deactivate CLLocationManager events when in background mode

开发者 https://www.devze.com 2023-04-06 02:52 出处:网络
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 whil

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号