Sending Push Notifications via Cloud - Master key is invalid
Hi,
I was able to do queries via cloud but unfortunately I can't seem to let the push notification works via my cloud function. This was used to be working with the Parse platform before but after migration I am receiving this error: code = 115; message = "Master key is invalid, you should only use master key to send push";
Push Notification works when I'm using curl on the command line. Below is my code snippet
I have the same problem in Android and IOS
I have tried some advises from this issue as well https://github.com/ParsePlatform/parse-server/issues/356 to no avail..
Check #401
The code you have posted has 2 issues. useMasterKey:true; is not valid javascript. It should be passes as a second parameter to Parse.Push.send in an object.
return Parse.Push.send({
where: query,
data: { ... }
}, { useMasterKey: true });
Hello Everyone,
Iam getting Master key is invalid, you should only use master key to send push
Please find my cloud code below:
Parse.initialize("appid", "javascriptkey", "masterkey"); var pushQuery = new Parse.Query(Parse.Installation); Parse.Push.send({
channels: [ "Giants" ], data: { alert: "The Giants Mets 2-3." } }, { useMasterKey: true });
My index.js code
var api = new ParseServer({
databaseURI: databaseUri,
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID,
masterKey: process.env.MASTER_KEY,
clientKey: process.env.CLIENT_KEY,
restAPIKey: process.env.REST_API_KEY,
fileKey: process.env.FILE_KEY,
serverURL: 'http://IP/parse',
push: {
ios:
[
{
pfx: __dirname + '/name.p12', // Prod PFX or P12
bundleId: id',
production: false // Prod
},
{
pfx: __dirname + '/name.p12', // Prod PFX or P12
bundleId: 'id',
production: true // Prod
}
]
} }); Please help me on this Thanks,
Don't call Parse.initialize in your Cloud Code, that is already done from within the server.