相关疑难解决方法(0)

暂停后iPhone背景中的iPhone GPS永远不会恢复

我的应用程序需要在后台跟踪用户位置更改,并且只要用户移动就可以正常工作.当用户CLLocationManager在10-20分钟左右停止并暂停时.此通知表明:

-(void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager{}
Run Code Online (Sandbox Code Playgroud)

这对我也没关系.太棒了,我节省了一些电池等

问题是CLLocationManager当用户再次开始移动时永远不会醒来,并且在我将应用程序放到前台之前永远不会触发委托方法(获取活动):

//Never called back after CLLocationManager pauses:
-(void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager{}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{}
Run Code Online (Sandbox Code Playgroud)

为什么locationManagerDidResumeLocationUpdates在设备重新开始移动后从未调用过?GPS也不应自动恢复(因为自动暂停)? 有没有办法在没有用户互动的情况下恢复GPS?

应用程序在Info.plist文件中声明如下:

在此输入图像描述

我的CLLocationManager设置是:

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager setActivityType:CLActivityTypeFitness];
//I WANT pauses to save some battery, etc... That is why following line is commented out (default)
 //[locationManager setPausesLocationUpdatesAutomatically:NO];
 locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters;
 locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
 [locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)

objective-c core-location uiapplicationdelegate cllocationmanager ios

29
推荐指数
1
解决办法
9324
查看次数