Search code examples
huawei-mobile-servicespushkithuawei-push-notification

What is class in BadgeNotification at HMS push kit?


I will send push to huawei devices using api over a server. When I read the API document, it says it is mandatory to give a class name for the badge structure.

I do not know the class name in apk because I send notification via api.

What does this class name do? enter image description here

Can I name any class? Or do I have to give the correct class in apk?


Solution

  • Using HMS Core Push Kit, you can automatically change the app badge number after setting the badge field on the server. Class field is mandatory in this scenario. The value must be the full path of the launcher class of your app. For example, if your app package name is com.huawei.push and the launcher class name of your app is MainActivity, so the value should be com.huawei.push.MainActivity.

    So in your case, you can get this value from your client development colleagues. Here is an example for your reference:

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

    For more details, you can refer to this guide: Push Kit-Badging