位置服务转为“非活动”状态iPhone 5中的状态 [英] Location service going to "Inactive" state in iPhone 5

查看:126
本文介绍了位置服务转为“非活动”状态iPhone 5中的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

甚至我的应用程序都在后台注册位置更新。

Even my app is register for Location updates in background.

在我的代码中:

self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
self.locationManager.distanceFilter = 2500;

我没有搬到任何地方。因此,在控制台日志中完成15分钟后,我收到此消息位置图标现在应处于非活动状态状态。从这一点开始,我的应用程序不在后台运行。

And I not moved anywhere. So after exactly 15 minutes in console log I got this message "Location icon should now be in state 'Inactive'" . From this point onwards my app is not running in background.

仅在iPhone 5中发生。

@updated

这是我的代码

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


推荐答案

当位置服务变为非活动状态时,您的应用是否在后台?

Was your app in the background when location service become inactive?

如果您不想在后台暂停位置更新,则需要设置pausesLocationUpdatesAutomatically flag,

If you don't want to pause location update in background than you need to set pausesLocationUpdatesAutomatically flag,

if ([self.locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) {
    self.locationManager.pausesLocationUpdatesAutomatically = NO;
}

这篇关于位置服务转为“非活动”状态iPhone 5中的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆