Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending Push Notifications via Cloud - Master key is invalid #564

Closed
seecahkhing opened this issue Feb 22, 2016 · 6 comments
Closed

Sending Push Notifications via Cloud - Master key is invalid #564

seecahkhing opened this issue Feb 22, 2016 · 6 comments

Comments

@seecahkhing
Copy link

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

screen shot 2016-02-22 at 6 47 56 pm

@adamofsky
Copy link

I have the same problem in Android and IOS

@seecahkhing
Copy link
Author

I have tried some advises from this issue as well https://github.com/ParsePlatform/parse-server/issues/356 to no avail..

@wangmengyan95
Copy link
Contributor

Check #401

@gfosco
Copy link
Contributor

gfosco commented Feb 22, 2016

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 });

@maruthi-wal
Copy link

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,

@drew-gross
Copy link
Contributor

Don't call Parse.initialize in your Cloud Code, that is already done from within the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants