|
@@ -0,0 +1,51 @@
|
|
|
+'use strict';
|
|
|
+const uniPush = uniCloud.getPushManager({
|
|
|
+ appId: "__UNI__33EAA2D"
|
|
|
+})
|
|
|
+exports.main = async (event) => {
|
|
|
+ let obj = JSON.parse(event.body)
|
|
|
+ console.log(obj)
|
|
|
+ // const res = await uniPush.sendMessage({
|
|
|
+ // category: {
|
|
|
+ // //HarmonyOS NEXT系统(纯血鸿蒙、非安卓鸿蒙)的消息分类,要给鸿蒙设备推送时才必传
|
|
|
+ // "harmony":"MARKETING"
|
|
|
+ // },
|
|
|
+ // options:{
|
|
|
+ // "HW": {
|
|
|
+ // // 值为int 类型。1 表示华为测试消息,华为每个应用每日可发送该测试消息500条。此 target_user_type 参数请勿发布至线上。
|
|
|
+ // "/message/android/target_user_type":1
|
|
|
+ // } ,
|
|
|
+ // "HO": {
|
|
|
+ // //值为int 类型。1 表示测试推送,不填默认为0。荣耀每个应用每日可发送该测试消息1000条。此测试参数请勿发布至线上。
|
|
|
+ // "/android/targetUserType": 1
|
|
|
+ // } ,
|
|
|
+ // "VV": {
|
|
|
+ // //值为int 类型。0 表示正式推送;1 表示测试推送,不填默认为0。此 pushMode 参数请勿发布至线上。
|
|
|
+ // "/pushMode":1
|
|
|
+ // } ,
|
|
|
+ // "XM": {
|
|
|
+ // //新小米消息分类下,私信公信id都必须要传,否则请求小米厂商接口会被拦截
|
|
|
+ // "/extra.channel_id": ""
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // ...obj,
|
|
|
+ // })
|
|
|
+ switch (obj.action) {
|
|
|
+ case 'getClientDetail':
|
|
|
+ return getClientDetailByCid(obj.cid)
|
|
|
+ default:
|
|
|
+ return sendMessage(obj)
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 推送通知
|
|
|
+async function sendMessage(event) {
|
|
|
+ const res = await uniPush.sendMessage(event)
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
+// 查询设备的信息
|
|
|
+async function getClientDetailByCid(cid) {
|
|
|
+ const res = await uniPush.getClientDetailByCid(cid)
|
|
|
+ return res
|
|
|
+}
|