[英]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));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.