PWA application - display a badge on the app icon works windows but not work on android

431 Views Asked by At

I am struggling with PWA and badging. I added if (navigator.setAppBadge) { navigator.setAppBadge(6); } to the push notification method(service-worker.js) and it works fine on windows(chrome browser) but it doesn't work on android(also chrome browser). Consent to notifications granted. Are you able to advise what is wrong or what I miss or maybe android requires additional permissions?

Thanks in advance.

I tried set badge without number but it also don't work. I also check if I can add additional permission for PWA app on the Android device.

1

There are 1 best solutions below

0
Jens Væver Hartfelt On

I struggled with this aswell. What i have found is that the badging api is not supported on android. Here is a quote from google:

The App Badging API works on Windows, and macOS, in Chrome 81 and Edge 81 or later. Support for ChromeOS is in development and will be available in a future release. On Android, the Badging API is not supported. Instead, Android automatically shows a badge on app icon for the installed web app when there is an unread notification, just as for Android apps.

Source (Chrome for developers)

It matches what mdn's compatibility chart says where Chrome is yellow and is noted with "Partial support. Windows and macOS only."

Source (mdn)