I am using Laravel Echo Ionic on the project. I get ERR_CLEARTEXT_NOT_PERMITTED error while running it on mobile devices but it is running fine on webview and emulator.
I have tried to add
<uses-permission android:name=“android.permission.INTERNET” />
<uses-permission android:name=“android.permission.ACCESS_NETWORK_STATE” />
<uses-permission android:name=“android.permission.ACCESS_WIFI_STATE” />
on AndroidManifest.xml
but, it doesn't work.
and i've tried to add
<access origin=“*”/>
<allow-intent href=“*” />
<allow-navigation href=“*” />
on config.xml.
and lastly i've tried to modify config.xml with
<edit-config file=“app/src/main/AndroidManifest.xml” mode=“merge” target=“/manifest/application”>
<application android:usesCleartextTraffic=“true” />
</edit-config>
but all doesn't work for me.
Any idea how to fix this problem?
It just happened to me recently and if you are trying to connect from your device to any external server (since you mention about laravel echo, then I assume that you are trying to connect to an IP), then maybe you can try this.
If you notice, the network_security_config.xml located in "resources" folder will be copied into your android "app" folder
...
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
<allow-intent href="market:*" />
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
...
</platform>
...
Maybe try to modify network_security_config.xml file located in resources/android/xml/network_security_config.xml into :
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain>localhost</domain>
<domain>your_external_ip_here</domain>
</domain-config>
</network-security-config>
Hope this help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With