feat: 增加消息通知配置

This commit is contained in:
zheng020 2026-05-21 10:50:13 +08:00 committed by zerosaturation
parent c887d30738
commit a37c672a1d
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,40 @@
'use strict';
const uniPush = uniCloud.getPushManager({
appId: "__UNI__9B0F7C5" // 你的应用appId
})
exports.main = async (event) => {
console.log(event)
// event为客户端上传的参数
const body = JSON.parse(event.body)
// const body = event
return await uniPush.sendMessage({
"force_notification": true, // 填写true客户端就会对在线消息自动创建“通知栏消息”不填写则需要客户端自己处理。
"push_clientid": body.cids, // 必选 设备id支持多个以数组的形式指定多个设备如["cid-1","cid-2"]数组长度不大于1000
"title": body.title, //必填 通知栏显示的标题
"content": body.content, //必填 通知栏显示的内容
"payload": body.data, //可选 自定义数据
"open_url": body.open_url, //可选 需要打开外部url就填写
"request_id": body.request_id, //必填 请求唯一标识号10-32位之间如果request_id重复会导致消息丢失
// options更多参数介绍https://doc.dcloud.net.cn/uniCloud/uni-cloud-push/options.html
"options": {
"HW": {
// 1 表示华为测试消息华为每个应用每日可发送该测试消息500条target_user_type 参数请勿发布至线上。
"/message/android/target_user_type": 1,
// "/message/android/category": "WORK"
},
"HO": {
//值为int 类型。1 表示测试推送不填默认为0。荣耀每个应用每日可发送该测试消息1000条。此测试参数请勿发布至线上。
"/android/targetUserType": 1
},
"VV": {
//值为int 类型。0 表示正式推送1 表示测试推送不填默认为0。此 pushMode 参数请勿发布至线上。
"/pushMode": 1
},
"XM": {
//新小米消息分类下私信公信id都必须要传否则请求小米厂商接口会被拦截
"/extra.channel_id": "填写小米平台申请的渠道id"
}
}
})
};

View File

@ -0,0 +1,8 @@
{
"name": "GM-uniPush",
"dependencies": {},
"extensions": {
"uni-cloud-jql": {},
"uni-cloud-push": {}
}
}