-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
navigator.setAppBadge does not work within onBackgroundMessage #8416
Comments
I'm not an expert on notifications but I did a little research and it seems like there may be some issues with updating the badge notification from the background on macOS: I did some testing on my machine (macOS, Chrome) and it seems like there's some odd behavior of setAppBadge in the service worker. You said that if you set it at the top of the service worker code (outside of onBackgroundMessage), it worked, and I found that too. But if I immediately then set it to a different number after that, still in the top level of the service worker, it didn't update to the new number.
I don't think this is a bug with the Firebase Messaging SDK but some kind of bug or at least unexpected behavior with setAppBadge and PWAs, maybe on a certain OS or browser. Can you let me know if you can get it to update to one number and then a second number in the service worker, even if not using onBackgroundMessage, and the code to do it? Maybe there's just a problem with my setup. I was able to get setAppBadge to update just fine in onMessage, in the main app code (not in the service worker). |
Hey @atgillette. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Hi, I had to stop |
Is this issue caused by the issue you linked? |
Hey @atgillette. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
This code worked for me. |
What specific information do you need from me? The simple code below should set the badge to 50. But it doesn't. Outside of this handler, the
|
In our testing it seems that something in the state of your service worker breaks the We need to understand more about what your service worker might be doing before the messaging event is fired so that we can reproduce the problem here. Additionally, given the link that @hsubox76 provided above, this issue might not be Firebase related but an issue with the browser implementation itself:
|
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
The text was updated successfully, but these errors were encountered: