Squirrel

iOS9常见错误https问题解决

关于如何由https请求返回到http请求

解决

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

其他

如果想让有的域名支持https的话也可以这么配置:
补充了配置的方法
对于实在不支持HTTPS的应该首先考虑添加例外

添加例外的方式也很简单:
左键Info.plist选择open with source code
然后添加类似如下的配置:

<code class="hljs"xml="">    <key>NSAppTransportSecurity</key>

    <dict>

        <key>NSExceptionDomains</key>

        <dict>

            <key>qq.com</key>

            <dict>

                <key>NSIncludesSubdomains</key>

                <true>

            </true></dict>

            <key>sina.com.cn</key>

            <dict>

                <key>NSIncludesSubdomains</key>

                <true>

            </true></dict>

           </dict>

   </dict></code>


根据自己需要的域名修改, NSIncludeSubdomains 是包括子域的意思。


评论
热度(1)
© Squirrel | Powered by LOFTER