devstepbcn/react-native-android-wifi

Works in debug, but not in release for android

Opened this issue · 2 comments

I can connect to the wifi SSID when I am running in debug in react-native, but when I create an APK, the same phone does not ever notice when it is connected to the SSID. I see it connect, buy my code loops and checks the current wifi ssid to see if it is actually connected, and that code never is successful. Any Ideas?

I seem to be experiencing the same thing after upgrading to React-Native 0.59.1. @jnystrom What version of React Native are you on?

Update: For me the problem was that Android API 28 no longer allows unsecured requests and requires TLS/SSL/https. When building locally this is not enforced to allow connections to localhost, etc. If your build target is 27 or lower you can continue making http requests. However, if you need to make an unsecure(aka http) request to a local device over wifi, for example http://192.168.0.1/endpoint and you are targeting 28+, you can add a network_security_config.xml file to configure custom domains, etc. to continue being able to use it outside of debugging. Related information about certificate signing using a similar fix can be found in the Android documentation and in this RN issue.