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

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

问题描述

自iOS 8发布以来,我遇到了 SignificantLocationChanges 的问题。方法

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

[locationManager startMonitoringSignificantLocationChanges]; 

在检查可用性后是否正确调用,代表也很好用(我用<$检查它) c $ c> 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天全站免登陆