如何在Ionic 2中将应用程序带到前台?

时间:2017-06-12 17:41:59

标签: api ionic2

当通知发生时,有什么方法可以将应用从background模式转移到foreground吗?喜欢 WhatsApp Skype ,当语音电话或视频通话到达时,它们会进入前台。

更新

public subscribeToPushNotificationEvents(): void {

    // Handle token refresh
    this.firebase.onTokenRefresh().subscribe(
      token => {
        //console.log(`The new token is ${token}`);
        this.saveToken(token);
      },
      error => {
        console.error('Error refreshing token', error);
      });

    // Handle incoming notifications
    this.firebase.onNotificationOpen().subscribe(
      (notification: NotificationModel) => {

         this.backgroundMode.moveToForeground();

        let notificationAlert = this.alertCtrl.create({
          title: notification.title,
          message: notification.body,
          buttons: ['Ok']
        });
        notificationAlert.present();
}

1 个答案:

答案 0 :(得分:1)

据我所知,您唯一的选择就是这个插件:http://ionicframework.com/docs/native/background-mode/