react-native-open-wifi
Connect to unsecured, open WiFi networks and get the status of the WiFi connection on the device.
Based on the work of skierkowski/react-native-open-wifi-manager
Android only. Programatically connecting to WiFi networks on iOS is not possible. You should show instructions telling your user to connect manually.
Installation
First you need to install react-native-open-wifi:
npm install react-native-open-wifi --save
- In
android/setting.gradle
...include ':OpenWifi', ':app'project(':OpenWifi').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-open-wifi/android')
- In
android/app/build.gradle
...dependencies { ... compile project(':OpenWifi')}
- register module (in MainActivity.java or MainApplication.java)
On newer versions of React Native (0.18+):
// <--- import
On older versions of React Native:
// <--- import
Example
Load module
var OpenWifi = ;
Connect to a new network (connect)
// Attempts to connect to the network specified.// The promise will be rejected if not connected after 20 seconds.OpenWifi // Timeout (optional) 10 seconds ;
TODO (by priority)
[x] Change connect result to polling the current SSID
[x] Make timeout configurable
[x] Resolve connect promise immediately if the currentSSID equals the wanted SSID
[ ] Expose more methods, such as getting current SSID