HarmonyOS 鸿蒙Next 获取推送服务
HarmonyOS 鸿蒙Next 获取推送服务
使用推送服务接口时报错: // 定义推送的消息体 const messagePayload = { msgId: msgId, // 唯一的消息ID appId: “”, // App ID toOpenId: toOpenId, // 用户OpenID templateId: “”, // 模板ID templateParams: { “time_1”: createTime, // 充值时间 “thing_0”: charge, // 充值金额 “thing_2”: balance // 余额 }, clickAction: { actionType: 0, // 点击跳转首页 data: { “extraInfo”: “testValue” } } };
try { // 发送推送请求 const response = await axios.post("", // 替换为你的 projectId messagePayload, { headers: { ‘Authorization’:
Bearer ${token}
, // 使用JWT Token ‘Content-Type’: ‘application/json’ } } );
console.log(‘推送成功:’, response.data); res.status(200).send({ code: response.data.code, message:response.data.msg}); } catch (error) { res.status(500).send(“推送信息错误:”, error); } 请求的返回结果为: { “code”: “82500002”, “message”: “Service notification msg send template get error” }
2 回复