点击后台firebase推送通知后访问特定页面

时间:2018-02-19 07:01:12

标签: angular firebase ionic-framework push-notification ionic2

我正在使用firebase离子推送通知 import { Push, PushObject, PushOptions} from '@ionic-native/push'; `

      const pushObject: PushObject = this.push.init(options);
      pushObject.on('notification').subscribe((notification: any) => {
          if(notification.background){
            alert(JSON.stringify(notification));
                this.navCtrl.push('DetailPage', {
                  item: notification.additionalData
                });
            }
      });

      pushObject.on('registration').subscribe((registration: any) => {
         this.storage.get('isDeviceRegistered')
              .then((isDeviceRegistered) => {
                  if(!isDeviceRegistered){
                     this.registerDevice(registration.registrationId , this.token);
                     console.log(JSON.stringify(registration.registrationId));
                     this.storage.set('FireBaseRegID', registration.registrationId);
                  }
                  else{
                    console.log('Device Already Registered');
                  }
              });
      });

  pushObject.on('error').subscribe(error => alert('Error with Push plugin' + error));
  }`

但是在获得通知后的on通知中我无法重定向到DetailPage,我成功获取通知对象,同时提醒值但无法重定向到特定页面。

提前致谢!

0 个答案:

没有答案