'Not all apps are in the notification number badge list

Hi there Android / HUAWEI friends!

I am designing an App for Android. I have utilized Firebase to send push notifications to the device where the app is installed. It is all good and works fine - I can see the notification as a tile with Title, Body and Icon. I can navigate to the App when I tap on it.

But I have a problem with the app icon notification badge. By default it was set to dot (HUAWEI P30 Pro, EMUI 11). When I receive a notification, the dot appears. All good.

But when I change the notification badge type to number it doesn't show (1) for example. I can see with some other apps it is the same. The main difference is that the DOT BADGE list contains all apps (my app including), while the NUMBER BADGE list contains quite few apps (Phone, Messages, and some other 3rd party apps, but not all).

So my question is - should I set some setting in the app manifest or somewhere else in order to see numbered badge?



Solution 1:[1]

You are advised to use Huawei Push Kit.

According to the document , Push Kit provides an API for setting badges on the server. A badge number indicates the number of unread messages. You can encapsulate badge parameters in messages. For notification messages, Push Kit will display the badge number on the app icon. For data messages, your app needs to call the getBadgeNumber method to obtain badge parameters from each message and display the badge number.

Sample code for setting a badge on the server:

{
    "validate_only": false,
    "message": {
        "notification": {
            "title": "message title ",
            "body": "message body"
        },
        "android": {
            "notification": {
                "click_action": {
                    "type": 2,
                    "url": "https://example.com"
                },
                "badge": {
                    "add_num": 1,
                    "class": "com.huawei.codelabpush.MainActivity",
                    "set_num": 10
                }
            },
            "ttl": "1000"
        },
        "token": [
            "pushtoken1"
        ]
    }
}

For details about badge development on the client, please refer to Interface Description for Badging on Huawei Desktop.

Note: If you have any queries about Push kit, please feel free to contact us back.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shirley