App Transport Security policy error after setting Arbitrary Loads to YES

241 Views Asked by At

I'm getting this error in my project

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

this is a common problem I know but the answer is not

adding App Transport Security Settings in info.plist and setting the Allow Arbitrary Loads to YES

because I did that already and it works in every project I have, but for some reason the project I'm currently working on didn't work. am not sure what I did wrong?

this is the info.plist under App Transport Security Settings

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>The domain</key>
            <dict>
                <key>**my domain here**</key>
                <dict/>
            </dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsForMedia</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
    </dict>
</dict>
1

There are 1 best solutions below

0
matt On BEST ANSWER

This structure is wrong:

    <key>NSExceptionDomains</key>
    <dict>
        <key>The domain</key>
        <dict>
            <key>**my domain here**</key>
            <dict/>
        </dict>
        <key>NSIncludesSubdomains</key>
        <true/>
        <key>NSExceptionAllowsInsecureHTTPLoads</key>
        <true/>
    </dict>

It should be:

    <key>NSExceptionDomains</key>
    <dict>
        <key>The domain</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>