iOS技术分享iOS

【翻译文章】定位服务在iOS11系统上不能使用,求救!

2017-06-08  本文已影响635人  大宇Raine

翻译:Rain

From stackoverflow

Q:我刚刚用iOS 11 SDK重新构建了应用程序,试图移除一直出现的蓝色横幅。我本以为成功了,结果发现定位服务现在根本不起作用。

之前这款应用在iOS10 上用的好好的——有人出现过这个问题吗?

A:因为苹果现在增加了一项新的隐私保护功能 NSLocationAlwaysAndWhenInUseUsageDescription,

并且原有的 NSLocationAlwaysUsageDescription 被降级为 NSLocationWhenInUseUsageDescription。

想要达到之前 NSLocationAlwaysUsageDescription 的定位效果,需要在info.plist文件中添加 NSLocationAlwaysAndWhenInUseUsageDescription 和 NSLocationWhenInUseUsageDescription 两个就可以了。否则,徒劳无功,你的App依旧不支持Always authorization。

/*

*      Either the NSLocationAlwaysAndWhenInUseUsageDescription key or both the

*      NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription

*      keys must be specified in your Info.plist; otherwise, this method will do

*      nothing, as your app will be assumed not to support Always authorization.

*/

你在使用这个新Key时,位置服务可能仍然不起作用,在我进一步的搜索之后,发现这个gem与所有其他的调试信息混杂在一起:

这个App在没有usage description的情况下能访问敏感隐私数据。App的info.plist必须包含NSLocationAlwaysAndWhenInUseUsageDescription 和 NSLocationWhenInUseUsageDescription keys中使用字符串值向用户解释该应用如何使用这些数据

This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain both NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription keys with string values explaining to the user how the app uses this data

这与更新CLLocationManager.h文件中的注释有很大矛盾。因此我创建了一个雷达。

很幸运的我成功了,通过调试控制台和IE, 然后添加新Key NSLocationAlwaysAndWhenInUseUsageDescription和旧Key NSLocationWhenInUseUsageDescription的时候,定位服务就能正常使用了。

翻译出处:https://stackoverflow.com/questions/44424092/location-services-not-working-in-ios-11

上一篇 下一篇

猜你喜欢

热点阅读