Arnas Pecelis
Arnas Pecelis

Reputation: 149

Clearing badges count on RN app using firebase

I have no worries sending push notifications to my RN app from my backend and adjusting badges count there, no matter there are 100 badges or 0. What I am curious about is how to clear that badge count without actually showing any new push notification? Is there any kind of "silent" push notifications that will never be showed but the badge count will be updated? I have this situation since I have web and mobile apps and if the user reads his notifications on WEB I want to reset its count on mobile as well without waiting to open the mobile app.

On my backend I'm using firebase-admin library

Upvotes: 0

Views: 561

Answers (1)

saqib kafeel
saqib kafeel

Reputation: 306

yes, it is possible to send a silent push without any sound and appear in notifications with this payload and it will set your badge no. reset means zero and 0 badge will not show

{
    "aps" : {
        "alert" : "You received simple notification!",
        "badge" : 0,
        "content-available" : 1
    }
}

OR

try options

const options = { content_available: true }

and pass options as an additional parameter

admin.messaging().sendToDevice(tokens, payload, options); 

Upvotes: 1

Related Questions