加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift - 网络请求报App Transport Security has blocked a clear

发布时间:2020-12-14 06:21:39 所属栏目:百科 来源:网络整理
导读:使用Xcode7编写iOS9应用时,如果获取http://数据时会报如下错误: 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. 原因:

使用Xcode7编写iOS9应用时,如果获取http://数据时会报如下错误:

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.

原因:
从iOS9起,新特性要求App访问网络请求,要采用 HTTPS 协议。

如果仍想要使用HTTP协议,解决办法如下:
1,在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ;
2,在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 类型Boolean,值设为 YES;


当然,也可以直接使用Source Code形式打开Info.plist,添加如下配置:
1
2
3
4
5
< key >NSAppTransportSecurity</ >
dict >
>NSAllowsArbitraryLoads</ >
true />
</ >


原文出自: www.hangge.com 转载请保留原文链接: http://www.hangge.com/blog/cache/detail_822.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读