簡體   English   中英

當應用程序處於后台時顯示推送通知的徽章計數

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

我想在應用程序處於后台時顯示推送通知的徽章數。

我試過在類的oncreate()方法中設置徽章計數,該方法擴展了FirebaseMessagingService並且徽章計數正在運行。 但是每次生成新的firebase令牌時都會調用此oncreate()方法,因此徽章計數出錯。

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

對於不同的電話啟動器應用程序和制造商,方法可能有所不同。 新的Android API讓你有新的“徽章”請閱讀此內容

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM