Network

The Network API provides events for monitoring network status changes, along with querying the current state of the network.

Usage
//get network status
Network.getStatus()
    .then((status)=>{
        console.log(status)
    })
    .catch((error) => {
        console.error(error);
    });
//get network status
window.Network.getStatus()
    .then((status) => {
        console.log(status);
    })
    .catch((error) => {
        console.error(error);
    });
//get network status
window.Network.getStatus()
    .then((status) => {
        console.log(status);
    })
    .catch((error) => {
        console.error(error);
    });
//get network status
(<any>window).Network.getStatus()
    .then((status) => {
        console.log(status);
    })
    .catch((error) => {
        console.error(error);
    });
//get network status
window.Network.getStatus()
    .then((status) => {
        console.log(status);
    })
    .catch((error) => {
        console.error(error);
    });

Classes


Network

getStatus
getStatus(): Promise<NetworkStatus>

Returns the current connection status.


RETURN
returns: Promise<NetworkStatus>
onChange
onChange(): Observable<any>

Returns an observable to watch connection changes.


RETURN
returns: Observable<any>
onConnect
onConnect(): Observable<any>

Get notified when the device goes online.


RETURN
returns: Observable<any>
onDisconnect
onDisconnect(): Observable<any>

Get notified when the device goes offline.


RETURN
returns: Observable<any>

Interfaces Used

NetworkStatus

NetworkStatus {
    connected: boolean; 
    type: string;  // One of Connection type
}

Enumeration

Connection

enum Connection{
    UNKNOWN: 'unknown',
    ETHERNET: 'ethernet',
    WIFI: 'wifi',
    CELL_2G: '2g',
    CELL_3G: '3g',
    CELL_4G: '4g',
    CELL: 'cellular',
    NONE: 'none'
}