云函数
exports.main = async (event, context) => {
try {
return await cloud.openapi.templateMessage.send({
touser:event.openid,
page:event.page,
data: event.msgData,
templateId: event.msgid,
formId: event.formid
})
} catch (e) {
console.error(e)
}
消息体
var data = {
openid: app.globalData.userInfo.userid,
msgid: "msgid",
page: "page"
formid: e.detail.formId,
msgData: {
thing1: { DATA: "2019-12-13" },
time4: { DATA: "测试" }
}
}
云函数回调的结果
出现同样问题求解
1.pc端开发者工具:a.首先获取订阅权限,再调用message云函数,调用成功,接收者无法接收消息;b.若对message函数进行本地调试则云函数调用成功且消息可成功接收;在进行了本地调试发送消息后,再次进行a步骤则消息可以发出,但仅限于pc端开发者工具,一旦真机调试还是无法发出。