自iOS 8起,SignificantLocationChanges不起作用 [英] SignificantLocationChanges doesn't work since iOS 8

查看:56
本文介绍了自iOS 8起,SignificantLocationChanges不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自iOS 8发行以来,我对SignificantLocationChanges有问题.方法

I have a problem with the SignificantLocationChanges since the release of iOS 8. The method

[locationManager startMonitoringSignificantLocationChanges]; 

在检查可用性后正确调用了

,委托也很好用(我使用didChangeAuthorizationStatus方法进行检查,该方法是同一委托和对象的一部分),并且编译器毫无疑问,但是绝对没有更新和didFailWithError方法没有错误.日志显示 authorizationStatus 为4,我认为可以.

is called correctly after checking for availability, the delegates also work nice (I check it with the didChangeAuthorizationStatus method, which is part of the same delegate and object) and compiler has no doubts, but there comes absolutely no updates and no errors from the didFailWithError method. The log says the authorizationStatus is 4, which is ok I think.

在iOS 8之前,一切正常.

Before iOS 8 this all works fine.

第一个测试设备(带有3G的iPad 2)运行iOS 7.1.2,第二个运行(iPhone 5)8.0.2,当我使用常规的startUpdatingLocation方法时,我会立即获得更新.但是SignificantLocationChanges对于我的工作来说会更好.有谁知道错误可能在哪里?

The first test-device (iPad 2 with 3G) runs iOS 7.1.2 the second (iPhone 5) 8.0.2, when I use the normal startUpdatingLocation method I get updates immediately. But SignificantLocationChanges would be much better for my work. Has anyone an idea where the error could be?

推荐答案

在iOS 8中,您必须请求类型为始终"的授权,以允许您的应用使用重要位置.

In iOS 8 You must request authorization with type "Always" to allow your app to use significant locations.

在-Info.plist文件中使用键NSLocationAlwaysUsageDescription添加新行

Add a new row in your -Info.plist file with key NSLocationAlwaysUsageDescription

然后请求授权(如果尚未请求).

Then request authorization if its not requested yet.

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
    if (status == kCLAuthorizationStatusNotDetermined && [manager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
        [manager requestAlwaysAuthorization];
    }
}

这篇关于自iOS 8起,SignificantLocationChanges不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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