The Network API provides events for monitoring network status changes, along with querying the current state of the network.
//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);
});
onChange(): Observable<any>
Returns an observable to watch connection changes.
onConnect(): Observable<any>
Get notified when the device goes online.
onDisconnect(): Observable<any>
Get notified when the device goes offline.
NetworkStatus {
connected: boolean;
type: string; // One of Connection type
}
enum Connection{ UNKNOWN: 'unknown', ETHERNET: 'ethernet', WIFI: 'wifi', CELL_2G: '2g', CELL_3G: '3g', CELL_4G: '4g', CELL: 'cellular', NONE: 'none' }