firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

navigator.setAppBadge does not work within onBackgroundMessage

Open atgillette opened this issue 6 months ago • 8 comments

Operating System

macOS 14.4.1 and iOS 17.5.1

Browser Version

Chrome (macOS) and Safari PWA (iOS)

Firebase SDK Version

10.4.0

Firebase SDK Product:

Messaging

Describe your project's tooling

Reace - CRA

Describe the problem

within messaging.onBackgroundMessage, I'm unable to get navigator.setAppBadge to work in my service worker file.

But if I use navigator.setAppBadge when service worker initiates, it works as expected.

Steps and code to reproduce issue

messaging.onBackgroundMessage((payload) => {
  
  ++badgeCounter;

  console.log("badgeCounter", badgeCounter);

  navigator.setAppBadge(badgeCounter); 
}

atgillette avatar Aug 09 '24 03:08 atgillette