Closed jothikannan closed 5 years ago
Finally found the issue, if anyone uses localhost or http requests after forceWifiUsage, please keep in mind Starting with Android 9 (API level 28), cleartext support is disabled by default. So do following
Create file res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">Your URL(ex: 127.0.0.1)</domain>
</domain-config>
</network-security-config>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
Actually wifi.forceWifiUsage is working fine, but as i said Android 9 (API level 28) is refusing the calls from http protocols
@jothikannan thanks man you saved me! We should probably include this in the docs.
Platform : Android 9 "react-native": "0.60.0", "react-native-android-wifi":"0.0.41"
Can anyone help me to fix this? I am not a java guy so struggling with this issue for past one week.