美文网首页
关于iOS9+中的ATS(App Transport Secur

关于iOS9+中的ATS(App Transport Secur

作者: 寻雨的人 | 来源:发表于2016-06-12 11:13 被阅读56次

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

相关文章

网友评论

      本文标题:关于iOS9+中的ATS(App Transport Secur

      本文链接:https://www.haomeiwen.com/subject/xtpedttx.html