我的应用程序需要在后台跟踪用户位置的变化,只要用户四处走动就可以正常工作。CLLocationManager
当用户在 10-20 分钟左右后停止并暂停时。此通知表明:
-(void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager{}
这对我来说也很好。太好了,我节省了一些电池等。
问题是CLLocationManager
当用户再次开始移动时永远不会醒来,并且在我将应用程序置于前台(激活)之前,永远不会触发以下委托方法:
//Never called back after CLLocationManager pauses:
-(void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager{}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{}
为什么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];