翻译:Rain
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中使用字符串值向用户解释该应用如何使用这些数据