cashier_admin_app/uniCloud-aliyun/cloudfunctions/unipush/index.js

20 lines
766 B
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__71D61A3"
})
exports.main = async (event, context) => {
//event为客户端上传的参数
console.log('event : ', event)
let obj = JSON.parse(event.body)
return await uniPush.sendMessage({
"push_clientid": obj.cids, // 设备id支持多个以数组的形式指定多个设备如["cid-1","cid-2"]数组长度不大于1000
"title": obj.title, // 标题
"content": obj.content, // 内容
"payload": obj.data, // 数据
// "force_notification": true, // 服务端推送 需要加这一句
// "badge": +1, // 服务端推送 需要加这一句
"request_id": obj.request_id //请求唯一标识号10-32位之间如果request_id重复会导致消息丢失
})
};