2025-09-26 17:13:02 +08:00

40 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 简单的使用示例
'use strict';
const uniPush = uniCloud.getPushManager({appId:"__UNI__89F511F"}) //注意这里需要传入你的应用appId
exports.main = async (event, context) => {
return await uniPush.sendMessage({
"push_clientid": "a297ac02dc531b7d43ff539f3163efcb", //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
"force_notification":true, //填写true客户端就会对在线消息自动创建“通知栏消息”。
"title": "通知栏显示的标题",
"content": "通知栏显示的内容",
"settings": {
//消息有效期设置,单位毫秒,-1表示不设离线。默认是 2 小时,取值范围:-1 3 * 24 * 3600 * 1000(3天)之间
"ttl":86400000
},
"payload": {
"text":"体验一下uni-push2.0"
},
"category": {
//HarmonyOS NEXT系统纯血鸿蒙、非安卓鸿蒙的消息分类要给鸿蒙设备推送时才必传
"harmony":"MARKETING"
},
"options":{
"HW": {
// 值为int 类型。1 表示华为测试消息华为每个应用每日可发送该测试消息500条。此 target_user_type 参数请勿发布至线上。
"/message/android/target_user_type":1
} ,
"HO": {
//值为int 类型。1 表示测试推送不填默认为0。荣耀每个应用每日可发送该测试消息1000条。此测试参数请勿发布至线上。
"/android/targetUserType": 1
} ,
"VV": {
//值为int 类型。0 表示正式推送1 表示测试推送不填默认为0。此 pushMode 参数请勿发布至线上。
"/pushMode":1
} ,
"XM": {
//新小米消息分类下私信公信id都必须要传否则请求小米厂商接口会被拦截
"/extra.channel_id": "填写小米平台申请的渠道id"
}
}
})
};