消息推送
This commit is contained in:
20
uniCloud-aliyun/cloudfunctions/push/index.js
Normal file
20
uniCloud-aliyun/cloudfunctions/push/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
const uniPush = uniCloud.getPushManager({appId: "__UNI__88BC25B"})
|
||||
exports.main = async (event, context) => {
|
||||
//event为客户端上传的参数
|
||||
console.log('event : ', event)
|
||||
let body = JSON.parse(event.body)
|
||||
let res = await uniPush.sendMessage({
|
||||
"push_clientid": body.push_clientid, //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
|
||||
"title": body.title,
|
||||
"content": body.content,
|
||||
"payload": body.payload,
|
||||
"force_notification": true,
|
||||
"settings": {
|
||||
"strategy": {
|
||||
"default": 4
|
||||
}
|
||||
}
|
||||
})
|
||||
return res
|
||||
};
|
||||
7
uniCloud-aliyun/cloudfunctions/push/package.json
Normal file
7
uniCloud-aliyun/cloudfunctions/push/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "push",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-push": {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user