我的应用程序更新 (1.1) 因以下原因被拒绝:
我们发现您的应用使用后台模式,但不包含需要该模式持续运行的功能
。
但我的应用程序仍然使用 1.0 版中的相同功能。
我做什么: 在位置更新时,我检查新位置是否在特定区域(矩形)内:
- (BOOL)locationInRegion: (CLLocation *) lastLocation {
if ((lastLocation.coordinate.latitude < self.overlayTopLeftCoordinate.latitude && lastLocation.coordinate.latitude > self.overlayBottomLeftCoordinate.latitude) &&
(lastLocation.coordinate.longitude < self.overlayTopRightCoordinate.longitude && lastLocation.coordinate.longitude > self.overlayTopLeftCoordinate.longitude)) {
return YES;
}
return NO;
}
在前景和背景模式下,如果用户位于该区域,我会在 MKMapView 上绘制一条碎屑路径。如果没有,我什么都不做。
需要后台模式 -> 位置更新的应用注册在我的 .plist 中
我做错了什么?
我的描述中没有此信息:
Continued use of GPS running in the background can dramatically decrease battery life.
这会是(唯一的)原因吗?
最佳答案
您的应用被拒绝的可能原因有 2 种。
它是:-
a) 您的应用在后台时不需要位置更新。
b) 您的应用没有正确处理后台位置更新
如果是后者,您将需要处理位置更新以及当它处于后台时的后台任务。你将需要这样的东西
- (id)init {
if (self==[super init]) {
//Get the share model and also initialize myLocationArray
self.shareModel = [LocationShareModel sharedModel];
self.shareModel.myLocationArray = [[NSMutableArray alloc]init];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
}
return self;
}
-(void)applicationEnterBackground{
CLLocationManager *locationManager = [LocationTracker sharedLocationManager];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
//Use the BackgroundTaskManager to manage all the background Task
self.shareModel.bgTask = [BackgroundTaskManager sharedBackgroundTaskManager];
[self.shareModel.bgTask beginNewBackgroundTask];
}
以上只是完整解决方案的一小部分。我已经分享了一个完整的解决方案并上传到 Github,还有一篇关于如何在 iOS 7 后台持续更新位置的博文:Background Location Services not working in iOS 7 .
关于ios - 由于后台定位模式被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23884370/