Search code examples
iosswift2xcode7

connection failed error after disabling ATS


I've made a login page on my app and added my web service which is HTTP:// so i got this error : "App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file." Disabled ATS by adding:

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

Then got this error: Response code: 404

Screenshot from in-app error

What should I do? Sign-in web service works fine on Android app.


Solution

  • A 404 error means that the connection was made and the server indicated that the resource could not be found. This means your App Transport Security setup is not blocking the request (or any requests which isn't the ideal although is sometimes necessary).

    Check that the URL that you are accessing is correct and also check if any headers (e.g. content-type) need to be set.