解析推送通知云代码错误? [英] Parse Push Notification Cloud Code Error?
问题描述
更新:由于Parse-Server 2.2.17中存在一个错误,我收到此错误.我回到2.2.16修复了它.
UPDATE: I was getting this error because of a bug that Parse-Server 2.2.17 has. I fixed it by going back to 2.2.16.
有人知道我为什么收到此错误吗?这是我的云代码:
Does anyone know why I am getting this error? Here is my cloud code:
`Parse.Cloud.define("Messages",function(request,response){
`Parse.Cloud.define("Messages", function(request, response) {
var pushQuery = new Parse.Query(Parse.Installation);
var pushQuery = new Parse.Query(Parse.Installation);
Parse.Push.send({
where: pushQuery,
data: {
alert: "New Event Added",
sound: "default"
}
},{
success: function(){
console.log("Push Sent!")
},
error: function (error) {
console.log(error)
},
useMasterKey: true
}); });`
这是我遇到的错误:
然后这就是我调用代码的方式:`PFCloud.callFunctionInBackground("Messages",withParameters:nil){(对象,错误)在
And then this is how I am calling the code: `PFCloud.callFunctionInBackground("Messages", withParameters: nil) { (object, error) in
if error == nil {
print("Success!")
} else {
print(error)
}
}
index.js: `
index.js: `
推荐答案
可以请尝试以下代码:
var query = new Parse.Query(Parse.Installation);
// query condition (where equal to .. etc.)
var payload = {
alert: "New Event Added",
sound: "default"
};
Parse.Push.send({
where: query, // Set our Installation query
data: payload
}, {
success: function () {
},
error: function (error) {
// Handle error
}
});
请注意,我要删除 useMasterKey ,如果要添加useMasterKey,则需要将其插入到闭包中,但对我来说,它不需要useMasterKey即可
Please notice that i remove the useMasterKey if you want to add useMasterKey you need to insert it inside closures but for me it's works without the useMasterKey
useMasterKeyVersion应该如下所示:
the useMasterKeyVersion should look like the following:
Parse.Push.send({
where: query, // Set our Installation query
data: payload
},
{
useMasterKey: true
},
{
success: function () {
},
error: function (error) {
// Handle error
}
});
promise版本(根据最佳实践):
The promises version (according to best practices):
Parse.Push.send({where: query,data: payload})
.then(function(){
// success
},function(error){
// error ..
});
更新
通过查看index.js文件,您似乎没有将facebook oauth添加到您的三方身份验证登录名中. 因此您需要添加以下内容:
by looking at your index.js file it looks like you didn't add the facebook oauth to your 3-party authentication logins. so you will need to add the following:
oauth: {
facebook: {
appIds: "FACEBOOK APP ID"
}
}
在您的 emailAdapter 配置下方,并在"FACEBOOK APP ID"中放入您在Facebook开发人员中创建的应用ID
below your emailAdapter config and inside "FACEBOOK APP ID" put the app ID that you created in facebook developers
这篇关于解析推送通知云代码错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!