【发布时间】:2017-10-28 16:11:13
【问题描述】:
我尝试使用Firebase native plugin 发送推送通知。但它不起作用(没有收到消息到真实设备)。你能告诉我怎么做吗?
app.component.ts
constructor(platform: Platform, private firebase: Firebase) {
platform.ready().then(() => {
this.firebase.getToken()
.then(token => console.log(`The token is ${token}`)) // save the token server-side and use it to push notifications to this device
.catch(error => console.error('Error getting token', error));
this.firebase.onNotificationOpen()
.subscribe(res => {
if (res.tap) {
// background mode
console.log("background");
console.log(res);
alert(res);
} else if (!res.tap) {
// foreground mode
console.log("foreground");
console.log(res);
alert(res);
}
});
});
}
在上述实现之后,我尝试在 firebase compose 消息控制台上使用 User Segment 发送推送通知。
【问题讨论】:
-
您能解释一下不工作是什么意思吗?你安装插件了吗?您是否为您的应用配置了 Firebase?
-
是的。这些是基本的东西,不。不工作意味着没有收到消息到真实设备@naomi
-
我已经用这个插件实现了分析,它工作正常。问题在于推送通知。 @娜奥米
-
你需要调用
onNotificationOpen在回调ionicframework.com/docs/native/firebase/#onNotificationOpen获取通知数据
标签: angular firebase ionic-framework ionic2 ionic3