index.js 995 字节
Newer Older
M
MicroMilo 已提交
1 2 3
// 简单的使用示例
'use strict';
exports.main = async (event, context) => {
4 5 6 7 8 9
	const db = uniCloud.database()
	const regsTable = db.collection('mustgo-registration')
	const res = await regsTable.where(
		owner_id: event.uid,
		notified: false
	).get()
L
ljw 已提交
10

11 12 13 14 15 16 17 18 19 20 21
	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(
			_id: arr[i]["team_activity_id"]
		).get()
		list.push(title.data.title)
	}
	
L
ljw 已提交
22
	const uniPush = uniCloud.getPushManager({
23
		appId: "__UNI__AAFC50C"
L
ljw 已提交
24
	});
25 26 27 28 29 30 31 32 33 34 35
	for (var i = 0; i < list.length; i ++) {
		await uniPush.sendMessage({
			"push_clientid": event.push_clientid,
			"title": "小队活动即将开始",
			"content": "您报名的" + list[i] + "小队活动即将开始,快来看看吧~", 
			"payload": event.payload,
			"force_notification": true,
			"request_id": event.request_id,
			"badge": event.badge
		});
	}
M
MicroMilo 已提交
36
};