简体   繁体   中英

Ionic 3 app stopped making network request

I don't know why there is not possibility to make ajax call I have removed node_modules then made : npm i then I have deleted platforms/android

and made : ionic cordova run android the network is still not working (on device or simulator)

I have switched to the master branch which was untouched but still face the same problem

But it works fine on IOS and web

I upgraded the sdk for Android to 29, starting from sdk 28, you have to add the property to AndroidManifest.xml file in the node Application this attribute:

android:usesCleartextTraffic="true"

because I was making ajax calls to http and not https url.

Android needs the whitelist plugin (cordova-plugin-whitelist) to make requests outside the app (to the internet), are you sure you have included it? Also I used to have a similar problem, where the plugin was in my config.xml, however, it was not detected when I added the platform android using cordova@9.0.0. The solution for me was to move the plugin tag somewhere else in the config.

Refer to this https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/ , to know how to use the plugin if you have any doubts.

Here the config to whitelist navigation to somewhere: <allow-navigation href="mywebsite.com/coolpage.php" /> and here the config to whitelist requests to somewhere: <access origin="mywebsite.com/api.php" />

You can check if the whitelist plugin is installed by checking the logs, when you add a platform by making sure you see installing cordova-plugin-whitelist and that no errors comes up.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM