import { Injectable } from '@angular/core' ; import { Network } from '@ionic-native/network' ; import { Platform } from 'ionic-angular' ; import { Observable } from 'rxjs/Observable' ; declare var Connection ; @ Injectable ( ) export class ConnectivityProvider { onDevice : boolean ; constructor ( public platform , public network ) { this . onDevice = this . platform . is ( 'cordova' ) ; } isOnline ( ) { return navigator . onLine ; } isOffline ( ) { return ! navigator . onLine ; } watchOnline ( ) { return this . network . onConnect ( ) ; } watchOffline ( ) { return this . network . onDisconnect ( ) ; } }