关于iOS9+中的ATS(App Transport Security)

iOS9之后,为了更加安全,sdk中不再支持http协议,而要求全部使用https协议,使用 TLS1.2 SSL加密请求数据。

代码中使用到网络请求时,会出现如下数据请求错误:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app‘s Info.plist file.


解决方案:

在项目工程的info.plist文件中增加属性:

NSAppTransportSecurity->Dictionary

在该属性下增加key为NSAllowsArbitraryLoads,value为YES的键值对。

重新编译运行即可解决。


参考资料:

https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html#//apple_ref/doc/uid/TP40016198-DontLinkElementID_13

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容