first
This commit is contained in:
15
uniCloud-aliyun/cloudfunctions/queryCids/index.js
Normal file
15
uniCloud-aliyun/cloudfunctions/queryCids/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
const uniPush = uniCloud.getPushManager({
|
||||
appId: "__UNI__71D61A3"
|
||||
})
|
||||
exports.main = async (event, context) => {
|
||||
//event为客户端上传的参数
|
||||
const body = JSON.parse(event.body)
|
||||
console.log('入参', {
|
||||
cids: body.cids
|
||||
});
|
||||
const data = await uniPush.getDeviceStatusByCid(body.cids)
|
||||
|
||||
//返回数据给客户端
|
||||
return data
|
||||
};
|
||||
7
uniCloud-aliyun/cloudfunctions/queryCids/package.json
Normal file
7
uniCloud-aliyun/cloudfunctions/queryCids/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "queryCids",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-push": {}
|
||||
}
|
||||
}
|
||||
19
uniCloud-aliyun/cloudfunctions/unipush/index.js
Normal file
19
uniCloud-aliyun/cloudfunctions/unipush/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'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重复,会导致消息丢失
|
||||
})
|
||||
};
|
||||
7
uniCloud-aliyun/cloudfunctions/unipush/package.json
Normal file
7
uniCloud-aliyun/cloudfunctions/unipush/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "unipush",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-push": {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user