oa-base/uniCloud-aliyun/cloudfunctions/uni-cloud-push/index.js
Phoenix 629ce2f21b 1
2024-06-18 15:55:32 +08:00

24 lines
1.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__4796942"}) //注意这里需要传入你的应用appId
exports.main = async (event, context) => {
return await uniPush.sendMessage({
"push_clientid": "7d4aa359cc4dbab39f4e5fcbc7106b31", //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
"force_notification":true, //填写true客户端就会对在线消息自动创建“通知栏消息”。
"title": "通知栏显示的标题",
"content": "通知栏显示的内容",
"payload": {
"text":"体验一下uni-push2.0"
},
"options":{
"HW": {
// 值为int 类型。1 表示华为测试消息华为每个应用每日可发送该测试消息500条。此 target_user_type 参数请勿发布至线上。
"/message/android/target_user_type":1
} ,
"VV": {
//值为int 类型。0 表示正式推送1 表示测试推送不填默认为0。此 pushMode 参数请勿发布至线上。
"/pushMode":1
}
}
})
}