Skip to content

Simple wifi configuration manager for IOT devices.

License

Notifications You must be signed in to change notification settings

doegel/react-native-iot-wifi

 
 

Repository files navigation

@doegel/react-native-iot-wifi

Connect to WiFi with React Native on Android and iOS. 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.

Changelog

⚠️ This is a complete rewrite from v1 based on the great work of (tadasr/react-native-iot-wifi)[https://github.com/tadasr/react-native-iot-wifi], if you are looking for the old version look here.

2.0.0

Installation

npm install react-native-iot-wifi

iOS

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

  1. Enable Hotspot Configuration
  2. For iOS 12 Enable Access WiFi Information

Usage

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

// On some platforms location permission is required to setup wifi.
await Wifi.requestPermission();
let allowed = await Wifi.hasPermission();

// You may check if the API is available.
let available = await Wifi.isApiAvailable();

let ssid = await Wifi.getSSID();

try {
  // without passphrase
  await Wifi.connect("wifi-ssid");

  // with passphrase (only WPA is supported)
  await Wifi.connect("wifi-ssid", "passphrase");
} catch (error) {
  console.log('error: ' + error);
}

try {
  await Wifi.disconnect("wifi-ssid");
} catch (error) {
  console.log('error: ' + error);
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

See the LICENSE file for license rights and limitations (MIT).

About

Simple wifi configuration manager for IOT devices.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 46.5%
  • Objective-C++ 20.9%
  • TypeScript 10.7%
  • Ruby 9.5%
  • Objective-C 7.4%
  • JavaScript 4.6%
  • Other 0.4%