Set and clear badges
This API sets the application badge on a device.
Note
This API is only supported on Huawei, Honor, and vivo devices.
For Huawei devices, the badge feature is supported on EMUI 4.1 or later.
For Honor devices, numeric badges are supported on Magic UI 6.0 or later.
This API is supported on Mobile Push SDK V3.9.1 or later.
setBadgeNum
API definition
void setBadgeNum(Context context, int num)
Class
CloudPushService
Parameters
Parameter | Type | Required | Description |
context | Context | Yes | The current environment context. |
num | int | Yes | The number to display on the badge. Set this parameter to 0 to clear the badge. |
Code example
// Set the badge.
PushServiceFactory.getCloudPushService().setBadgeNum(context, 1);
// Clear the badge.
PushServiceFactory.getCloudPushService().setBadgeNum(context, 0);该文章对您有帮助吗?