'use strict';
const uniPush = uniCloud.getPushManager({appId:"__UNI__XXXXXX"}) //注意这里需要传入你的应用appId
exports.main = async (event, context) => {
return await uniPush.sendMessage({
"push_clientid": "xxx", //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
"title": "通知栏显示的标题",
"content": "通知栏显示的内容",
"payload": {
"text":"体验一下uni-push2.0"
}
})
};

4***@qq.com
- 发布:2022-10-28 17:04
- 更新:2022-11-03 20:04
- 阅读:293
产品分类: uniCloud/App
示例代码:
操作步骤:
上传并运行
上传并运行
预期结果:
客户端收到通知
客户端收到通知
实际结果:
16:55:59.449 [阿里云:app-admin]正在上传云函数push...
16:56:02.122 [云端运行:阿里云:app-admin]云函数push上传完成,开始运行...
16:56:15.438 [云端运行:阿里云:app-admin]运行状态:失败
16:56:15.442 [云端运行:阿里云:app-admin]运行结果:
16:56:15.445 [云端运行:阿里云:app-admin]运行日志:
Data must be a string or a buffer
TypeError: Data must be a string or a buffer
at Hash.update (crypto.js:99:16)
at UniPush.getToken (/tmp/function/@common_modules/uni-cloud-push/main.js:1153:5)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
16:56:15.447 [云端运行:阿里云:app-admin]运行报告:计费时间:ms 运行时间:ms 运行内存:0B
16:55:59.449 [阿里云:app-admin]正在上传云函数push...
16:56:02.122 [云端运行:阿里云:app-admin]云函数push上传完成,开始运行...
16:56:15.438 [云端运行:阿里云:app-admin]运行状态:失败
16:56:15.442 [云端运行:阿里云:app-admin]运行结果:
16:56:15.445 [云端运行:阿里云:app-admin]运行日志:
Data must be a string or a buffer
TypeError: Data must be a string or a buffer
at Hash.update (crypto.js:99:16)
at UniPush.getToken (/tmp/function/@common_modules/uni-cloud-push/main.js:1153:5)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
16:56:15.447 [云端运行:阿里云:app-admin]运行报告:计费时间:ms 运行时间:ms 运行内存:0B
bug描述:
根据文档操作,unipush.sendMessage方法报错

