parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Sending Push Notifications via Cloud - Master key is invalid

Open seecahkhing opened this issue 10 years ago • 6 comments

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

seecahkhing avatar Feb 22 '16 10:02 seecahkhing

I have the same problem in Android and IOS

adamofsky avatar Feb 22 '16 12:02 adamofsky

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

seecahkhing avatar Feb 22 '16 14:02 seecahkhing

Check #401

wangmengyan95 avatar Feb 22 '16 18:02 wangmengyan95

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

gfosco avatar Feb 22 '16 19:02 gfosco

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,

maruthi-wal avatar Mar 01 '16 13:03 maruthi-wal

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

drew-gross avatar Mar 01 '16 19:03 drew-gross