编程那点事编程那点事

专注编程入门及提高
探究程序员职业规划之道!

The resource could not be loaded because the App Transport Security policy requires the use of a sec

用AFNetworking请求时,报错,具体如下:

Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." 

意思是:资源不能被加载,因为该应用程序传输的安全策略要求使用安全连接

新特性要求App内访问的网络必须使用HTTPS协议。意思是Api接口以后必须是HTTPS
但是我以前的项目使用的是HTTP协议,使用私有加密方式保证数据安全。现在也不能马上改成HTTPS协议传输。

解决办法:

在Info.plist中添加App Transport Security Settings类型Dictionary。

在App Transport Security Settings下添加Allow Arbitrary Loads类型Boolean,值设为YES

未经允许不得转载: 技术文章 » 移动开发 » iOS开发 » The resource could not be loaded because the App Transport Security policy requires the use of a sec