专栏名称: Cocoa开发者社区
CocoaChina苹果开发中文社区官方微信,提供教程资源、app推广营销、招聘、外包及培训信息、各类沙龙交流活动以及更多开发者服务。
目录
相关文章推荐
51好读  ›  专栏  ›  Cocoa开发者社区

定位服务在iOS11系统上不能使用,求救!

Cocoa开发者社区  · 公众号  · ios  · 2017-06-09 12:00

正文

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







请到「今天看啥」查看全文


推荐文章
中央广电总台中国之声  ·  面对雾霾,你逃得开吗?
8 年前
水木文摘  ·  有人偷偷爱着你
7 年前
詹姆士的厨房  ·  有没有想过亲手为自己做一份便当?
7 年前
北京吃货小分队  ·  今天中午吃什么?-三里屯篇
7 年前