Ionic 3推送通知与有效载荷

Ionic 3推送通知与有效载荷

问题描述:

我已经集成推离子应用程序&它的工作。我使用push.rx.notification()。subscribe()来侦听通知。当应用程序是前台时它正在工作。但是,当应用程序未打开时,会收到通知,不会调用push.rx.notification()。subscribe()。这是我的app.component.ts代码:Ionic 3推送通知与有效载荷

this.push.register().then((t: PushToken) => { 
    return this.push.saveToken(t); 
    }).then((t: PushToken) => { 
    }).catch((err) => { 
    console.log('Error Saving Token: ' , err); 
    }); 

    this.push.rx.notification() 
    .subscribe((msg: any) => { 
//this block only executing when in foreground 
    console.log('Push Mesg : ' + msg.title + ' ' + msg.text); 
    }); 

我从Ionic仪表板发送推送。

当您点击通知时,会调用rx块内部的代码。 只有在使用离子API(通过仪表板或http请求)发送推送时才会发生,但是如果使用本地api(android/ios)发送推送不起作用。推送通知出现,但rx.notification方法从不调用。

+0

我已经提到过它。我从Ionic仪表板发送推送。 –