Ionic 3 redirect from app.component class to another page

前端 未结 2 1037
臣服心动
臣服心动 2021-01-22 04:11

I’m getting push notification messages and once I receive the message, I want to redirect to another page or show another page instead of home page.

NavController<

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-22 04:47

    I don't see any reason why you can't use the NavController like so:

    import { Component } from '@angular/core';
    import { NavController } from 'ionic-angular';
    import { Push, PushToken } from '@ionic/cloud-angular';
    import { SomeOtherPage } from '...';
    
    export class HomePage {
    
      constructor(private push: Push
        public navCtrl: NavController) {
            push.register().then((t: PushToken) => {
              return this.push.saveToken(t);
            }).then((t: PushToken) => {
              console.log('Token saved:', t.token);
            });
            this.push.rx.notification().subscribe((msg) => {
              this.navCtrl.push(SomeOtherPage, { msg: msg });
            });
      }
    }
    

提交回复
热议问题