|Mobile development type||Hybrid (Apache Cordova app)|
|Mobile OS||iOS, Android|
|Apache Cordova framework version||4.0.0 and higher|
You have set the target Apache Cordova version of your app to 4.0.0 or higher. After deploying the app on an actual device the HTTP requests to a web service don't work. The web service is functioning as expected and the app runs correctly in the developer tools.
The web service is returning error code
404 Not Found.
The HTTP transport security policy for the app (either OS-configured or developer-set) does not allow to connect to the remote service.
Rule out the server and client-side configuration and what may be the configuration that makes the request to fail. Check the following:
- If your app is pointing to a TLS-secured endpoint check the certificate validity. More information in App Cannot Connect to a Remote Service over HTTPS When Running on Device.
- Check if you have enabled the Apache Cordova Whitelist plugin in the Properties → Plugins → Core Plugins. More on whitelist policy in Apache Cordova-based apps here (for version 6.x.x of Cordova).
- You have correctly set the whitelist policy of the app to allow navigation to the required protocols and URIs. More on whitelist policy in Apache Cordova-based apps here (for version 6.x.x of Cordova). More information about this in AJAX jQuery Requests Do Not Work on Android.
If you are using a web service over HTTP (not secured with TLS) you may add an exception in the iOS
info.plistfile of your app for the
NSAppTransportSecuritykey. You can edit the
info.plistfile as explained here. An example transport security exception for the server
Communication over TLS is recommended. Consider setting the exception below only for testing and development purposes.
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>example.com</key> <dict> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict>