iOS--https 与 http 的问题

2017-07-27  本文已影响82人  追风筝的荧火虫

question :
sometimes it shows

 "<code class="hljs" livecodeserver="">The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.</code>"

don't worry,it is a problem about iOS $ https,because iOS thought that http is no a security transport. so how can we connect the http?

and how can we solve this problem? it seems easy to do it: close it or use it.
follow:

1:在Info.plist中添加NSAppTransportSecurity类型Dictionary。
2:在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
3:注意,单元测试下面也有一个Info.plist,修改那个文件是没有作用的!

otherwise:

add : 在 info右击=>openAs=>SourceCode 第24行加入

   <key>NSAppTransportSecurity</key>
          <dict>
                 <!--彻底倒退HTTP,允许不安全的信息传送-->
                 <key>NSAllowsArbitraryLoads</key>
                        <true/>
          </dict>

in the product's Info.plist

上一篇 下一篇

猜你喜欢

热点阅读