位置服务在iPhone 5中处于“未激活”状态
甚至我的应用程序都在后台注册位置更新。
在我的代码中:
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers; self.locationManager.distanceFilter = 2500;
我没有搬到任何地方。 因此,在控制台日志中完成15分钟后,我收到此消息“位置图标现在应处于”非活动状态“ 。 从这一点开始,我的应用程序不在后台运行。
它仅在iPhone 5中发生。
@更新
这是我的代码
self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; [self.locationManager setPurpose:@"Enable Location service for \"My App\" to track your"]; self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers; /* Notify changes when device has moved x meters. * Default value is kCLDistanceFilterNone: all movements are reported. */ self.locationManager.distanceFilter = 2500; [self.locationManager startUpdatingLocation];
当位置服务变为非活动状态时,您的应用是否在后台?
如果您不想在后台暂停位置更新,则需要设置pausesLocationUpdatesAutomatically flag,
if ([self.locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) { self.locationManager.pausesLocationUpdatesAutomatically = NO; }
自从iOS 6 Apple已经将@property(assign, nonatomic) BOOL pausesLocationUpdatesAutomatically
到CLLocationManager
。 默认值为YES
。 将此属性的值更改为NO
,位置跟踪不会在后台停止。