javascript – Home screen app of PWA do not show badge in Android system


We have a website which is capable of adding to (install) home screen in both Android and iOS systems. In the “app” Notification is requested and works well in both systems. Now we would like to add “Badge” feature to the app. We simply added to the app a short javascript code snippet as follows:

if(navigator.setAppBadge){
    alert("Badge Supported.");
    navigator.setAppBadge(3);
} else {
    alert("No Badges.");
}

The test results in both systems are:
iOS(iPhone 8 Plus, iOS 16.7.4):
alert shows “Badge Supported”, and return to the home screen we can see a badge showing “3” on the app icon. As shown in the picture below:

enter image description here

Android(Pixel 6 Pro with Android 14, and Samsung Galaxy Note 7 with Android 10):
alert shows “Badge Supported”, but the home screen app icon does NOT show the badge. Both devices do not show. As shown in the picture below:

enter image description here

We would like to ask if anyone know how to make both systems show badge normally? Thanks!

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img