嘿,我使用 Parse 作为后端,我喜欢它,但 afterSave 钩子有问题。
这是我正在使用的代码:
Parse.Cloud.afterSave ("JGZwoelf",function (request) {
Parse.Push.send({
//Selecting the Channel
channels: [ request.object.get('JGZwoelfPush') ],
data: {
//Selecting the Key inside the Class
alert: request.object.get('AusfallInfo')
}
}, {
success: function () {
//Push was send successfully
},
error: function (error) {
//Handle error
throw "Got an error" + error.code + " : " + error.message;
}
});
});
每次日志控制台告诉我:结果:
未捕获 出现错误 112:缺少频道名称。
我只是不明白出了什么问题!它必须在那个 JavaScript 代码中。如果我手动输入推送通知一切正常:/
编辑: Parse.Push.send 部分应如下所示:
Parse.Push.send ({
//Selecting the already existing Push Channel
channels: ["JGAchtPush"], //This has to be the name of your push channel!!
data: {
//Selecting the Key inside the Class
alert: request.object.get ("AusfallInfo")
}
}, {
success: function () {
//Push was sent successfully
//nothing was loged
},
error: function (error) {
throw "Got and error" + error.code + " : " + error.message;
}
});
频道名称需要类似于 ["exampleChannel"]。
提前感谢任何给定的帮助:)