index.js 538 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const uniPush = uniCloud.getPushManager({
  3. appId: "__UNI__33EAA2D"
  4. })
  5. exports.main = async (event) => {
  6. let obj = JSON.parse(event.body);
  7. switch (obj.action) {
  8. case 'getClientDetail':
  9. return getClientDetailByCid(obj.cid)
  10. default:
  11. return sendMessage(obj)
  12. }
  13. };
  14. // 推送通知
  15. async function sendMessage(event) {
  16. const res = await uniPush.sendMessage(event)
  17. return res
  18. }
  19. // 查询设备的信息
  20. async function getClientDetailByCid(cid) {
  21. const res = await uniPush.getClientDetailByCid(cid)
  22. return res
  23. }