当前位置:首页 > reactweb > 正文

react-native提示The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.的解决方案

从昨天开始,突然之前的xcode-beta 6.3不能启动了;于是在官网升级了xcode 7.2 beta版本;今天在运行一些程序的时候提示:
“Could not connect to development server. Ensure node server is running -run ‘npm start’ from ReactKit root

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.”
如下图:

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

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

碰到这个问题,总觉得很坑;于是在react项目的根目录,执行npm start命令,看起来react的node监控服务已经启动了。在网上搜索了一些帖子,都说iOS9引入了新特性App Transport Security (ATS);新特性要求App内访问的网络必须使用HTTPS协议。网上有解决方案;按照网上的方案,先找到info.plist,相当于是配置文件,增加如下信息:
在Info.plist中添加App Transport Security Settings类型Dictionary。
在NSAppTransportSecurity下添加Allow Arbitrary Loads类型Boolean,值设为YES

这样就OK了;

info.plist增加关于HTTPS的字段值

info.plist增加关于HTTPS的字段值

bingo

暂无评论

发表评论

您必须 [ 登录 ] 才能发表留言!