react-native-iot-wifi

Connect to WiFi with React Native on Android and iOS.


Keywords
react-native, android, wifi, iot, cross-platform, ios, mobile, wifi-manager
License
MIT
Install
npm install react-native-iot-wifi@1.0.0

Documentation

react-native-iot-wifi

Wifi configuration. This library was written to config iot devices. With iOS 11 Apple introduced NEHotspotConfiguration class for wifi configuration. Library supports same functionality on ios and android.

0.4.5

Android:

  • Makes the connect call asynchronous on Android
  • Fails for Android Q as the API is deprecated

iOS:

  • Fixes APIs on Simulator as it was behind a compile time macro
  • Exposed and returns defaults for Simulator targets

0.3.0

  • connectSecure() now works
  • getSSID() should work on android

iOS

Important IOTWifi uses NEHotspotConfigurationManager. To use the NEHotspotConfigurationManager class, you must enable the Hotspot Configuration capability in Xcode.

  1. Drang an drop IOTWifi.xcodeproj to your workspace
  2. Link target to libIOTWifi.a library
  3. Link target to NetworkExtension.framework framework
  4. Enable Hotspot Configuration
  5. For iOS 12 Enable Access WiFi Information

android

Usage

import Wifi from "react-native-iot-wifi";

Wifi.isApiAvailable((available) => {
  console.log(available ? 'available' : 'failed');
});

Wifi.getSSID((SSID) => {
  console.log(SSID);
});

Wifi.connect("wifi-name", (error) => {
  console.log(error ? 'error: ' + error : 'connected to wifi-name');
});

Wifi.removeSSID("wifi-name", (error)=>{
  console.log(error ? 'error: ' + error : 'removed wifi-name');
});