check internet connection in background ionic 3?

时间:2018-12-19 11:17:57

标签: javascript cordova ionic3

Need to run background process when internet is connected.

Is there any plugins available in ionic 3,cordova

export class MyApp {
  constructor (
    private network: Network,
    private platform: Platform,
    private alertCtrl: AlertController,
  ) {
    platform.ready().then(() => {
      this.listenConnection();
    })
  }

  private listenConnection(): void {
    this.network.onDisconnect()
      .subscribe(() => {
        this.showAlert();
      });
  }

  private showAlert(): void {
    // omitted;
  }
}

How to check internet connection background

0 个答案:

没有答案