简体   繁体   English

当应用程序处于后台时显示推送通知的徽章计数

[英]Show the badge count for push notifications when the app is in background

I want to show the badge count of the push notifications when the app is in background. 我想在应用程序处于后台时显示推送通知的徽章数。

I've tried by setting the badge count inside the oncreate() method of the class which is extending FirebaseMessagingService and the badge count is working. 我试过在类的oncreate()方法中设置徽章计数,该方法扩展了FirebaseMessagingService并且徽章计数正在运行。 But this oncreate() method is getting called each time when new firebase token is generated so badge count goes wrong. 但是每次生成新的firebase令牌时都会调用此oncreate()方法,因此徽章计数出错。

public void onCreate() {
    super.onCreate();  
    String badgeCount = sharedPreferencesObj.getString(key, "");
            ShortcutBadger.applyCount(MyDocPatientFbmService.this, String.valueOf(badgeCount));
   }

Approach might be different for different phone Launchers apps and manufacturers. 对于不同的电话启动器应用程序和制造商,方法可能有所不同。 New android API lets you have new kind of "badge" please read this 新的Android API让你有新的“徽章”请阅读此内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在后台和前台使用 Expo 更改推送通知中的徽章计数 - Changing badge count in Push Notifications with Expo in background and foreground Firebase 推送通知在后台应用程序时显示错误图标 - Firebase push notifications show wrong icon when app in background 如何在后台在Android应用程序图标上计算推送通知消息徽章 - How to count Push notification message badge on android app icon in background 如何以编程方式在Android上的应用程序图标上显示推送通知徽章计数? - How to show push notification badge count on app icon in android programmatically? 取消推送通知并打开应用程序时如何增加计数徽章? - How to increase the count badge when push notification recevied and app is open? 当 foreground_show 设置为 false 并且我的应用程序在后台时,如何获取推送通知以显示? - How do I get push notifications to show when foreground_show is set to false and my app is in the background? React Native AppCenter Push-应用程序在后台时的通知 - React Native AppCenter Push - Notifications when app is in background Amazon Pinpoint 和 Ionic - 当应用程序在后台时推送通知不起作用 - Amazon Pinpoint and Ionic - Push notifications not working when app is in background 当应用程序在后台(Titanium)时,Android 5上的推送通知未送达 - 但它确实在前台 - Push notifications on Android 5 not delivered when app in background (Titanium) - But it does in foreground 在后台运行应用程序时,未发送Android上的Apigee推送通知(Phonegap) - Apigee push notifications on Android not delivered when app in background (Phonegap)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM