提交 c8186330 编写于 作者: M MicroMilo

实现在线消息推送并解决版本适配且跳转

上级 c89c4f0f
......@@ -3,34 +3,40 @@
exports.main = async (event, context) => {
const db = uniCloud.database()
const regsTable = db.collection('mustgo-registration')
const res = await regsTable.where(
const res = await regsTable.where({
owner_id: event.uid,
notified: false
).get()
}).get()
// console.log(res)
let arr = new Array
let list = new Array
arr = res.data
for (var i = 0; i < arr.length; i++) {
const teamActivityTable = db.collection('mustgo-team-activity')
const title = await teamActivityTable.where(
const activity = await teamActivityTable.where({
_id: arr[i]["team_activity_id"]
).get()
list.push(title.data.title)
}).get()
list.push(activity.data[0].title)
}
const uniPush = uniCloud.getPushManager({
appId: "__UNI__AAFC50C"
});
for (var i = 0; i < list.length; i ++) {
await uniPush.sendMessage({
"push_clientid": event.push_clientid,
let result = new Array
for (var i = 0; i < list.length; i++) {
let tmp = await uniPush.sendMessage({
"push_clientid": event.cid,
"title": "小队活动即将开始",
"content": "您报名的" + list[i] + "小队活动即将开始,快来看看吧~",
"content": "您报名的小队活动" + list[i] + "即将开始,快来看看吧~" + Math.random() * 100,
"payload": event.payload,
"force_notification": true,
"request_id": event.request_id,
"badge": event.badge
});
result.push(tmp)
}
return result
};
\ No newline at end of file
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/rundebug.html#runparam
{
"uid": "645c972809e298919852519f",
"cid": "e1ad5019d8aec999f1ef4df59e809b7b"
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册