iOS9 网络请求修改

升级为iOS9后,默认请求类型为https,如何使用http进行请求会报错

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协议,使用私有加密方式保证数据安全。现在也不能马上改成HTTPS协议传输。

最简单的解决方案: 
1,在info.plist文件中添加App Transport Security Settings 类型是一个Dictionary 
2,在App Transport Security Settings下添加Allow Arbitrary Loads 类型Boolean,值设为YES

posted @ 2017-07-03 11:29  浩渺  阅读(226)  评论(0编辑  收藏  举报