Description
Which @angular/* package(s) are relevant/related to the feature request?
service-worker
Description
Currently you can use Push notification for displaying notification messages. But it is not possible to change application badge from push notification when application is not started.
You can use setAppBadge from SwPush.messages, but this only works when application is already running.
Proposed solution
Support setting application badge natively in ngsw-worker.js. New push payload would look something like this:
{
"notification": {
"actions": NotificationAction[],
....
},
"appBadge": number | undefined
}If appBadge property is not set nothing will happened, but if it is set, then inside "push" event, self.navigator.setAppBadge should be called with value of "appBadge". Setting "appBadge" to 0, will clear badge.
Alternatives considered
Now the only way to change application badge when application is offline is to use custom service worker to handle "push" event and then import ngsw-worker.js. But I'm not sure that even this will work on WebKit, because as stated in https://webkit.org/blog/14112/badging-for-home-screen-web-apps/ and if I understand correctly, both showNotification and setAppBadge must be 'promise' from same "push" event.
Activity
KrishDevCrafting commentedon Jan 15, 2024
what the fuck is that
JeanMeche commentedon Jan 15, 2024
On that topic, the
setBadgefunction has only partial support ATMangular-robot commentedon Jan 16, 2024
This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.
You can find more details about the feature request process in our documentation.
JeanMeche commentedon Aug 27, 2025
Per #63364, we won't be addressing this issue.
The message is also visible here: https://angular.dev/ecosystem/service-workers
angular-automatic-lock-bot commentedon Sep 27, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.