nativescript-wifi-info
by liberborn | v0.0.5
NativeScript plugin for retrieving device's wifi information details
npm i --save nativescript-wifi-info

NativeScript Wifi Info Plugin apple android

A plugin for retrieving device's wifi information details.

Prerequisites / Requirements

iOS

Make sure that your app has Access WiFi Information capability.

XCode > Open app > Capabilities > Access Wifi Information (ON)

Installation

tns plugin add nativescript-wifi-info

Usage

The wifi info plugin exposes a simple WifiInfo() class with several instance methods. To get the device's current Wifi SSID, instantiate an instance of WifiInfo and call its getSSID() method.

Angular

import {Component, OnInit} from '@angular/core';
import {WifiInfo} from 'nativescript-wifi-info';

@Component({
selector: 'Home',
moduleId: module.id,
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit {

ssid: string;
nativeSsid: string;

private wifiInfo: WifiInfo;

constructor() {
this.wifiInfo = new WifiInfo();
}

ngOnInit(): void {
this.ssid = this.wifiInfo.getSSID();
this.nativeSsid = this.wifiInfo.getNativeSSID();
}
}

TypeScript

import { WifiInfo } from 'nativescript-wifi-info';

const wifiInfo = new WifiInfo();
const ssid = wifiInfo.getSSID();
const nativeSsid = wifiInfo.getNativeSSID();

console.log('Wifi SSID', ssid);
console.log('Wifi SSID (native)', nativeSsid);

The plugin is currently set up to use:

Additional Examples

Scan Wifi Network and show available Wifi SSID list (Android only)

In angular app there is a simple implementation of scanning wifi network and populating wifi ssid list.

Known Issues

Getting Wifi SSID is not working on iOS simulator (returns No WiFi Available). On Android it should detect a default demo Wifi Network AndroidWifi.

License

MIT