• React Native — Manage wifi on AndroidI am working on a React Native app and there was a need to manage a Wifi network on the device.
  • It needed to do the following,Verify if the mobile WIFI is enabled or notFetch the WIFI network listConnect with the selected WIFI from the listDisconnect the WIFIForget the WIFI network from the mobileApproach…So first I looked at the React Native docs and found the NetInfo class which allows to access the Wifi on the native OS.
  • Then I looked at what native Android integration bridges are available for wifi, and found the package `react-native-android-wifi`.
  • This module requires the following permission on the Android platform, which we can configure in the / uses-permission / uses-permission / uses-permission installation, I have used it as following,var wifi = the wifi is enabled or if (isEnabled){ console.log(“wifi service enabled”); }else{ console.log(“wifi service is disabled”); }});I also wanted to forget/remove the wifi network from my mobile’s wifi network list and forcefully re-scan the wifi network list from the app itself.
  • But, these were not implemented in the original sourcecode.So I have added these new APIs as following, in the forked repo.Remove/Forget the Wifi network from mobile by SSID, (isRemoved) = { console.log(“Forgetting the wifi device — “ + ssid);});Starts native Android wifi network scanning and = { var wifiArray = JSON.parse(wifiStringList); console.log(‘Detected wifi networks — ‘,wifiArray);});There are other APIs which you can check at

Read more


parthbarot

@parthbarot: “React Native — Manage wifi on Android — #ReactNative #Javascript #Android #ReactJS #BoTreeTechnologies” open tweet »