aboozaid / react-native-wifi-hotspot

A react-native implementation for handling hotspot requests and make it easier to communicate with peers!
ISC License
40 stars 21 forks source link


React Native Hotspot [Android]

NPM Version NPM Version PRs Welcome

DEPRECATED

Please use react-native-tethering instead which compatible with latest react-native versions and Android APIs

Introduce

Since there's not a strict API from React Native to allow us to handle operations on Hotspot. So, today I would like to share my small kit with you guys to help most of rn developers to be able to use wifi-hotspot and enjoy its powerful.

The kit is designed to be helpful and to provide an easy API that can suit your needs so let me tell you how this kit can help you a long away with:

Setup

Fetch it using npm or yarn

npm i --save react-native-wifi-hotspot
OR
yarn add react-native-wifi-hotspot

Then run this command to link it

react-native link react-native-wifi-hotspot

Almost done just put this lines into Settings.gradle

include ':hotspotmanager'
project(':hotspotmanager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wifi-hotspot/android/hotspotmanager')

šŸ’„ Just run it!

Example

šŸ”„ Full Example

Features

Demo

example app

Get Started

Parameters Required Types Default
SSID * none none
password * none password should be provided if you will use our settings
protocols - Hotspot.protocols.RSN
Hotspot.protocols.WPA
Hotspot.protocols.BOTH
Hotspot.protocols.BOTH
securityType - Hotspot.security.WPA_PSK
Hotspot.security.WPA_EAP
Hotspot.security.IEEE8021X
Hotspot.security.WPA2_PSK
Hotspot.security.WPA2_PSK
authAlgorithms - Hotspot.auth.OPEN
Hotspot.auth.SHARED
Hotspot.auth.LEAP
Hotspot.auth.SHARED
const hotspot = {SSID: 'ASSEM', password: 'helloworld', authAlgorithms: Hotspot.auth.OPEN, protocols: Hotspot.protocols.WPA }
    Hotspot.create(hotspot, () => {
      ToastAndroid.show("Hotspot enstablished", ToastAndroid.SHORT);
    }, (err) => {
      ToastAndroid.show(err.toString(), ToastAndroid.SHORT);
    })

You can also use your own old settings without the need of creating new one