0
我使用离子云和Firebase云消息传递推送通知的代码如下。Ionic 3推送通知主题订阅
let topic = "topics/" + this.user.userRole + "/" + this.user.location;
const options:PushOptions = {
android: {
senderID: "XXXXX",
sound: true,
vibrate: true,
//topics: [topic]
},
ios: {
alert: "true",
badge: false,
sound: "true"
},
windows: {}
};
它的工作原理,但只要我尝试订阅特定话题,从运行Android时,然后应用程序崩溃。
当我使用订阅,在下面的方式:
pushObject.on('registration').subscribe((data:any) => {
console.log("device registered -> ", data);
this.saveToken(data.registrationId);
let topic = "topics/" + this.user.userRole + "/" + this.user.location;
pushObject.subscribe(topic).then((res:any) => {
console.log("subscribed to topic: ", res);
});
});
再次,什么也没有发生,我没有收到展示我能够订阅一个主题的任何信息。
我该如何完成主题订阅?