Hotspot Wizard API

turnOnHotspot()

Enables Mobile Hotspot

Inputs

  SSID - The name of the network you want to set.

  Password - The secret Password you want to set.

Output

Javascript Object

For Android Version < 8

{status : "success"}
OR
{status : "success"}

For Android Version > 8

In Android > 8, Hotspot SSID and Password cannot be set programatically. Hence the Wizard will return the randomly generated credentials back to the user

{
status : "success",
SSID: " <Randmoly Generated SSID> ",
password: " <Randomly Generated Password">
}

USAGE


HotspotWizard.turnOnHotspot("John Doe Network","helloworld").then(data=>{
  let status = data.status;
  if(status=="success"){
    // Hotspot Enabled Successfully with custom credentials.
  }
  else if(status=="auth"){
    // Hotspot Enabled Successfully with random credentials.
    console.log(data.SSID);
    console.log(data.status);
  }
}).catch(err=>console.log(err))

PERMISSIONS

All Runtime Permissions are managed by the library and will be asked when required.

Make sure your AndroidManifest.xml file has the following permissions.

<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission
    android:required="true"
    android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_COARSE_LOCATION"/>

v1.0.3 and below implementation (Deprecated)

Inputs

  SSID - The name of the network you want to set.

  Password - The secret Password you want to set.

Output

JSON Stringified Object

For Android Version < 8

{status : "success"}
OR
{status : "success"}

For Android Version > 8

In Android > 8, Hotspot SSID and Password cannot be set programatically. Hence the Wizard will return the randomly generated credentials back to the user

{
status : "success",
SSID:" <Randmoly Generated SSID> ",
password: " <Randomly Generated Password">
}

USAGE


HotspotWizard.turnOnHotspot("John Doe Network","helloworld").then(data=>{
  let jsonData = JSON.parse(data);
  let status = jsonData.status;
  if(status=="success"){
    // Hotspot Enabled Successfully with custom credentials.
  }
  else if(status=="auth"){
    // Hotspot Enabled Successfully with random credentials.
    console.log(jsonData.SSID);
    console.log(jsonData.status);
  }
}).catch(err=>console.log(err))

PERMISSIONS

All Runtime Permissions are managed by the library and will be asked when required.

Make sure your AndroidManifest.xml file has the following permissions.

<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission
    android:required="true"
    android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_COARSE_LOCATION"/>

turnOffHotspot()

Disables the mobile hotspot and restores previous wifi configuration.

OUTPUT

JavaScript Object

{status : "success"}
OR
{status : "success"}

USAGE

HotspotWizard.turnOffHotspot().then(data=>{
  let status = data.status;
  if(status=="success"){
    // Hotspot Disabled Successfully
  }
  else
  {
    // Failed to disabled Hotspot.
  }
})

PERMISSIONS

All Runtime Permissions are managed by the library and will be asked when required.

Make sure your AndroidManifest.xml file has the following permissions.

<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission
    android:required="true"
    android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_COARSE_LOCATION"/>

v1.0.3 and below implementation (Deprecated)

OUTPUT

JSON Stringified Object

{status : "success"}
OR
{status : "success"}

USAGE

HotspotWizard.turnOffHotspot().then(data=>{
  let jsonData = JSON.parse(data);
  let status = jsonData.status;
  if(status=="success"){
    // Hotspot Disabled Successfully
  }
  else
  {
    // Failed to disabled Hotspot.
  }
})

PERMISSIONS

All Runtime Permissions are managed by the library and will be asked when required.

Make sure your AndroidManifest.xml file has the following permissions.

<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission
    android:required="true"
    android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission
    android:required="true"
    android:name="android.permission.ACCESS_COARSE_LOCATION"/>

isHotspotEnabled()

Returns the status of Mobile Hotspot

OUTPUT

Boolean Value

true / false

USAGE

HotspotWizard.isHotspotEnabled().then(status=>{
  if(status){
    // Hotspot is Enabled.
  }
  else
  {
    // Hotspot is Disabled.
  }
})