App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.

折月煮酒 提交于 2019-12-02 22:49:25

问题


Supposedly temporary exceptions can be configured via your app's Info.plist file. Following other answers, I added this entry to the info.plist but it does not help (even worse, after I changed the xml file I get a permission error when I attempt to run the app on my iPhone but not on the simulator - but that is a different problem.)

 <key>NSAppTransportSecurity</key>
 <dict>
 <key>NSAllowsArbitraryLoads</key>
  <true/>
 </dict>

回答1:


From Project Navigator click your project's name.

Now, on the right side you' ll see the General Tab of your project. Select the Info and in the Customs iOS Target Properties add a new type.

Name it as NSAppTransportSecurity, type as Dictionary. Inside that add a new item and name it as NSAllowsArbitraryLoads, type as Boolean, value YES.

Hope that will solve your problems.




回答2:


@SamHeather I tried to post this in Comments, but apparently too long.. This is white listing Facebook domains which is mandatory for the Facebook SDK integration. You can change these of course to fit your needs.

Currently whitelisted are: akamaidhd.net, facebook.com, and fbcdn.net.

You could change these like such for example:

<key>(your domain name) </key>
                <dict>
                    <key>NSIncludesSubdomains</key>
                    <true/>
                    <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                    <false/>
                </dict>

Facebook white listing below:

<key>NSAppTransportSecurity</key>
<dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>akamaihd.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>facebook.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>fbcdn.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>


来源:https://stackoverflow.com/questions/32912061/app-transport-security-has-blocked-a-cleartext-http-http-resource-load-sinc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!