Master key is invalid, you should only use master key to send push
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,
Did you set your master key in the environment before starting your server? with: APP_ID=appid MASTER_KEY=masterKey node index.js
Yes.. Master key and App Id i given.. Please help me on this..
Pass the third argument as "true" to .send function.
Its working for me. Thanks a lot for your suggestions.
My cloude code finally:
Parse.Push.send({ channels: ['Giants'], data: { alert: 'The Giants Mets 2-3.', badge: 1, sound: 'default' } }, { success: function() { console.log('##### PUSH OK'); }, error: function(error) { console.log('##### PUSH ERROR'); }, useMasterKey: true });
@maruthi-wal Did you still have to call Parse.initialize("appid", "javascriptkey", "masterkey");in the body of your cloud code function?
If you did, did you just copied and pasted the keys in as strings?
@AlecKriebel Thanks. Its working for me..
@maruthi-wal It is not working for me. Did you still have the initialize call in your Cloud Code. I may need to add it to mine.
Thanks.
@AlecKriebel Yep.. I added Parse.initialize("appid", "javascriptkey", "masterkey"); in my cloud code.
Make sure in index.js as below: push: { ios: [ { pfx: __dirname + '/name.p12', // Prod PFX or P12 bundleId: 'id',
production: false } ] }
Production should be false for testing.
{ params: { id: '45J1QIaKIi' }, master: false, user: { _objCount: 0, className: '_User', id: '45J1QIaKIi' }, installationId: '82e1d517-7aac-d887-d02b-e407c3de5e7f' }
PUSH OK
APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected APNS Connection 0 Socket Error APNS Connection 0 Socket Error APNS Connection 0 Disconnected
how to solve this problem when I send push it performs success but the it also shows these in the console.