简体   繁体   English

Ionic 3徽章未在iOS或Android上显示

[英]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个问题:

  1. The badge never appears (tested on iOs and Android) (but the notifications are working normally) 徽章从未出现(在iOs和Android上经过测试)(但通知正常运行)
  2. When I click on the notification, I am re-directed to my application's home page. 当我单击通知时,我将重定向到应用程序的主页。 But I would like to be re-directed on a specific page of my application. 但是我想在我的应用程序的特定页面上重定向。 Apparently, that should be specified by changing the "activity" on the "click_action" parameter, however my app doesn't have any activity. 显然,应该通过更改“ click_action”参数上的“活动”来指定,但是我的应用程序没有任何活动。

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.

相关问题 使用cordova在Android / Ios中显示徽章编号 - Display badge number in Android/Ios using cordova 如何使用 Ionic 2 在 Android 应用程序图标中增加徽章计数通知? - How to increase badge count notification in the Android app icon using Ionic 2? Android 6和IOS 9中的离子问题 - Problems with Ionic in android 6 and IOS 9 徽章 Drawable 正在从视图中剪切并且没有显示正确的方式 Android Kotlin - Badge Drawable is cutting from view and not showing proper way Android Kotlin 自定义 Firebase 推送通知未显示 Android 通知徽章点 - Android notification badge dot not showing for custom firebase push notification Ionic 2图像未在Android手机中显示 - Ionic 2 image not showing in Android phone 使用Xamarin表单为Android和iOS设置推送通知徽章时遇到问题 - Trouble setting push notification badge for Android and iOS using Xamarin Forms android是否像iOS一样支持消息通知图标气泡(Badge) - does android support messaging notification icon bubble (Badge) like iOS 在不打开应用程序的情况下更新cordova徽章(android&ios) - Update cordova badge without opening the app (android & ios) 徽章绘图未显示 - Badge Drawable not showing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM