[英]Ionic 3 badge not showing on iOS or Android
I have a mobile app built on Ionic 3, using Firebase and FCM plugin to send notifications. 我有一个基于Ionic 3的移动应用程序,使用Firebase和FCM插件发送通知。
I have 2 problems : 我有2个问题:
Thanks for your help. 谢谢你的帮助。
Here is my code : 这是我的代码:
sendNotif(){
this.postRequest()
var headers = new Headers();
headers.append("Accept", 'application/json');
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'key=xxxxx:xxxx')
let options = new RequestOptions({ headers: headers });
let postParams = {
"notification": {
"title": "Mon-appli",
"body": "Nouvelle réservation",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon"
},
"data": {
"param1": "value1",
"param2": "value2"
},
"to": "/topics/all",
"priority": "high",
"restricted_package_name": ""
}
this.http.post("https://fcm.googleapis.com/fcm/send", postParams, options)
.subscribe(data => {
this.nb_notif = this.nb_notif +1;
}, error => {});
}
I ended up here because I have the same problem with badge as you. 我到这里结束了,因为徽章的问题和您一样。 But I think that I can answer your number 2 problem: 但我认为我可以回答您的第二个问题:
The redirection has nothing to do with your notification set-up. 重定向与您的通知设置无关。 You'll need to unsubscribe from the authentication observer. 您需要取消订阅身份验证观察者。 So unsubscribe in app.component.ts from the listener as follow: 因此,请从监听器中取消订阅app.component.ts,如下所示:
const authUnsubscribe = afAuth.authState.subscribe( user => {
if (user) {
authUnsubscribe.unsubscribe();
this.rootPage = 'HomePage';
}
else{
this.rootPage = 'LoginPage';
}
});
And for question number 1: You'll have to add badge:1 in your notification:{..} description. 对于问题1:您必须在通知:{..}说明中添加徽章:1。
"notification": {
"title": "Mon-appli",
"body": "Nouvelle réservation",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon",
"badge":1
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.