网络请求报错如下:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
原因是iOS9后引入了新特性App Transport Security (ATS)
新特性要求App内访问的网络必须使用HTTPS协议,但是现在大部分使用的是HTTP协议,使用私有加密方式保证数据安全,不改变HTTP协议的前提之下我们可以这样修改。
解决方案如下:
- 在Info.plist中添加
NSAppTransportSecurity类型Dictionary。 - 在
NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
本文介绍了如何解决iOS 9引入的App Transport Security (ATS) 特性导致的应用内HTTP请求失败的问题。通过在Info.plist文件中配置NSAppTransportSecurity字典并设置NSAllowsArbitraryLoads为YES来允许HTTP加载。

被折叠的 条评论
为什么被折叠?



