更新记录

1.0.0(2025-07-05)

初始化


平台兼容性

uni-app

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - - 4.4 12
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - -

uni-app x

Chrome Safari Android iOS 鸿蒙 微信小程序
- - 5.0 12 -

xtf-brage

android ios 桌面角标设置

插件支持Android ios 设置桌面角标数量 Android 支持 华为 荣耀 小米 vivo oppo(需要向官网申请角标权限) 魅族 三星 等多种手机

因为系统限制 小米手机实现方法不同 所以单独实现

若不显示角标 请确认应用是否有通知权限 无通知权限可能不显示角标

插件测试使用方法

  1. 选择试用,绑定要试用的项目appid,

  2. 选择后下载到对应的本地项目,

  3. 按照文档 -》把插件引入项目(即

    import { NotifationPara, cancelNotifation, checkAppNotification, onOpenNotificationSetting, sendNotifation, showBrage,isXiaomiDevice } from '@/uni_modules/xtf-brage';

    需要先引入),

  4. 发布-》云打包-》选择制作基座-》打包等基座制作完成

  5. 运行 -》 运行到手机或模拟器-》运行到Androidapp基座-》选择使用自定义基座运行-》选择手机-》运行

  6. 若之前手机安装过基座需要先卸载之前的基座

uniapp

<template>
    <view>
        <button type="primary" style="margin: 10rpx;" @click="onClick(0)">设置桌面角标数量66</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(1)">设置桌面角标数量0</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(2)">检测是否有通知权限</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(3)">打开通知权限设置</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(4)">发送通知</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(5)">取消通知</button>
    </view>
</template>

<script>
    import { NotifationPara, cancelNotifation, checkAppNotification, onOpenNotificationSetting, sendNotifation, showBrage,isXiaomiDevice } from '@/uni_modules/xtf-brage';
    export default {
        data() {
            return {
                title: 'Hello'
            }
        },
        onLoad() {

        },
        methods: {
            onClick(id){
                if(id==0){
                    showBrage(66)
                    if(isXiaomiDevice()){
                            sendNotifation({
                                title:"Test",
                                content:"msg",
                                showBrage:true,
                                count:66,
                            })
                    }
                }else if(id==1){
                    showBrage(0)
                    if(isXiaomiDevice()){
                            cancelNotifation();
                    }
                }

                else if(id==2){
                    uni.showToast({
                        title:""+checkAppNotification(),
                        icon:"none"
                    });
                }else if(id==3){
                    onOpenNotificationSetting(function(res:boolean){
                        uni.showToast({
                            title:""+res,
                            icon:"none"
                        });
                    })
                }else if(id==4){
                    sendNotifation({
                        title:"Test",
                        content:"msg",
                    })
                }else if (id==5){
                    cancelNotifation(6234542);
                }

            }
        }
    }
</script>

<style>
</style>

uniappx

<template>
    <view>
        <button type="primary" style="margin: 10rpx;" @click="onClick(0)">设置桌面角标数量66</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(1)">设置桌面角标数量0</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(2)">检测是否有通知权限</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(3)">打开通知权限设置</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(4)">发送通知</button>
        <button type="primary" style="margin: 10rpx;" @click="onClick(5)">取消通知</button>
    </view>
</template>

<script>
    import { NotifationPara, cancelNotifation, checkAppNotification, onOpenNotificationSetting, sendNotifation, showBrage,isXiaomiDevice } from '@/uni_modules/xtf-brage';
    export default {
        data() {
            return {
                title: 'Hello'
            }
        },
        onLoad() {

        },
        methods: {
            onClick(id:number){
                if(id==0){
                    showBrage(66)
                    if(isXiaomiDevice()){
                            sendNotifation({
                                title:"Test",
                                content:"msg",
                                showBrage:true,
                                count:66,
                            } as NotifationPara)
                    }
                }else if(id==1){
                    showBrage(0)
                    if(isXiaomiDevice()){
                            cancelNotifation();
                    }
                }

                else if(id==2){
                    uni.showToast({
                        title:""+checkAppNotification(),
                        icon:"none"
                    });
                }else if(id==3){
                    onOpenNotificationSetting(function(res:boolean){
                        uni.showToast({
                            title:""+res,
                            icon:"none"
                        });
                    })
                }else if(id==4){
                    sendNotifation({
                        title:"Test",
                        content:"msg",
                    } as NotifationPara)
                }else if (id==5){
                    cancelNotifation(6234542);
                }

            }
        }
    }
</script>

<style>
</style>

通知参数

export type NotifationPara={
    id?:number,// 通知id
    title?:string,//通知标题
    content?:string,// 通知内容
    channelId?:string,// 通知channelid
    channelName?:string,// 通知channelName
    channelSound?:boolean,//通知是否有声音 和channelid 绑定 无效换channelid或者卸载应用
    showBrage?:boolean,// 桌面角标  
    count?:number // 角标数量
}

开发文档

UTS 语法 UTS API插件 UTS uni-app兼容模式组件 UTS 标准模式组件 Hello UTS

隐私、权限声明

1. 本插件需要申请的系统权限列表:

通知权限

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问