设置桌面图标icon角标消息数量

前言

功能

  • 设置桌面图标icon角标消息数量
  • 清除桌面图标icon角标消息数量

接入步骤

如不了解原生插件接入步骤的同学请参考:
https://www.jianshu.com/p/830ccc503e29
https://blog.csdn.net/wenrisheng/article/details/124057700

介绍

  • 接口

var badge = uni.requireNativePlugin("wrs-badge");

  1. 设置桌面图标icon角标消息数量

                badge.setBadge({
                    "num": 2
                });

  1. 清除桌面图标icon角标消息数量

badge.clearBadge();

  1. ios如果角标设置不生效,请先调用registerUserNotificationSettings,如果集成了极光推送或个推等第三方消息推送平台一般角标设置都会生效,具体取决于项目配置或基座版本

                switch (uni.getSystemInfoSync().platform) {
                    case 'ios':
                        // type:
                        // 0:UIUserNotificationTypeNone  the application may not present any UI upon a notification being received
                        // 1:UIUserNotificationTypeBadge   he application may badge its icon upon a notification being received
                        // 2:UIUserNotificationTypeSound   the application may play a sound upon a notification being received
                        // 3:UIUserNotificationTypeAlert   the application may display an alert upon a notification being received
                        badge.registerUserNotificationSettings({
                            "types": 1 | 2 | 3
                        }, (resp)=>{
                            if(resp.granted) {
                                
                            } else {
                                
                            }
                        });
                        break;
                    default:
                        break;
                }
                
  1. Android由于碎片化太严重,各个厂家和版本都高度定制化,不一定支持所有版本,以下机型应该问题不大
image.png

支持定制,联系方式 QQ:252797991

如果觉得可以就点个👍吧,欢迎粉丝收藏,土豪打赏,您的关注就是我们创作的动力!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。