如何在华为上显示应用程序图标徽章编号 [英] How to show App Icon Badge Numbers on Huawei

查看:131
本文介绍了如何在华为上显示应用程序图标徽章编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在华为设备 (Android 9) 上,我的应用没有在应用图标上显示用于推送通知的数字.在应用程序图标徽章"下的设备设置中,我可以在数字"和点"之间切换徽章显示模式".如果我使用点,一切正常并显示一个点,但如果我使用数字,我的应用程序不在列表中,并且在图标上不显示任何内容.

On Huawei device (Android 9) my app does not show numbers on app icon for push notification. In the settings from the device under "App icon badges" I can switch the "Badge disply mode" between "Numbers" and "Dots". If I use dots, everything works fine and a dot is shown but if I use numbers my app is not in the list and show nothing on the icon.

我为华为测试了以下权限但没有成功

I tested the following permissions for huawei but no success

<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>

我是否必须使用其他权限或实现一些特殊的东西才能出现在数字列表中并能够在应用图标上显示数字?

Do i have to use other permissions or implement something special to be in the list for numbers and be able to show numbers on the app icon?

推荐答案

Push Kit 提供了用于在服务器上设置徽章的 API.您可以在消息中封装徽章参数.发送推送请求时,您可以设置add_numclassset_num 参数来设置徽章.

Push Kit provides an API for setting badges on the server. You can encapsulate badge parameters in messages. When sending a push request, you can set the add_num, class, and set_num parameters to set the badge.

在服务器上设置徽章的示例代码:

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"
        ]
    }
}

更多信息请参见文档.

这篇关于如何在华为上显示应用程序图标徽章编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆