How to use the ionic-native.Network.onDisconnect function in ionic-native

To help you get started, we’ve selected a few ionic-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chsakell / ionic2-angular2-firebase / app / app.ts View on Github external
watchForDisconnect() {
    var self = this;
    // watch network for a disconnect
    let disconnectSubscription = Network.onDisconnect().subscribe(() => {
      console.log('network was disconnected :-(');
      console.log('Firebase: Go Offline..');
      self.sqliteService.resetDatabase();
      self.dataService.goOffline();
      self.events.publish('network:connected', false);
    });
  }
github microsoft / Bing-Maps-Fleet-Tracker / MobileClient / src / pages / home / home.ts View on Github external
ngOnInit() {
      this.connectSub = Network.onConnect().subscribe(() => this.ngZone.run(() => this.connected()));
      this.disconnectSub = Network.onDisconnect().subscribe(() => this.ngZone.run(() => this.disconnected()));

      this.settingsSrvc.get(Settings.BackendUrl).then((val) => {
        if (!val) {
          let registration = this.modalCtrl.create(RegistrationPage);
          registration.onDidDismiss(data => {
            if(!data){
              navigator.app.exitApp();
            }

            Promise.all([
              this.settingsSrvc.set(Settings.BackendUrl, data.baseUrl),
              this.settingsSrvc.set(Settings.SecurityToken, data.deviceToken),
              ]).then(() => {this.continueInitialization();});
          });
          registration.present();
        }
github crabcanon / angular2-ionic2-demo / src / providers / native-service.ts View on Github external
checkNetworkDisconnection() {
    this.networkDisconnectSubscription = Network.onDisconnect().subscribe(() => {
      this.events.publish('native:networkDisconnect', {networkDisconnect: true});
    }, error => {
      console.log('checkNetworkDisconnection Error: ', error);
    })
  }
github fossasia / open-event-organizer-android / src / app / app.component.ts View on Github external
private initDisconnectSubscription() {
    this.disconnectSubscription = Network.onDisconnect().subscribe(() => {
      this.networkCheckService.showNoNetworkAlert();
      this.disconnectSubscription.unsubscribe();
    });
  }
}
github haoshiyou / haoshiyou-client / lab / haoshiyou / app / pages / tabs / tabs.ts View on Github external
this.platform.ready().then(()=> {
      if (this.platform.is("ios") || this.platform.is("android")) {
        this.logger.debug(`The platform is ios or android, setting up disconnectModal.`);
        this.disconnectModal = Modal.create(DisconnectModal);

        this.onDisconnect = Network.onDisconnect().subscribe(() => {
          this.logger.debug(`Disconnected, show disconnectModal.`);
          this.nav.present(this.disconnectModal, {animate: true});
        });

        this.onConnect = Network.onConnect().subscribe(() => {
          this.logger.debug(`Connected, show disconnectModal.`);
          this.disconnectModal.dismiss();
        });

      }
    });
  }