Sending Push Notifications - Master key is invalid
I get Exception : "Master key is invalid, you should only use master key to send push" I don't understand where i supposed to enter the master key In Android : androidQuery.whereEqualTo("deviceType", "android"); ParsePush androidPush = new ParsePush(); androidPush.setQuery(androidQuery); androidPush.setData(androidData); Log.i("androidData=", androidData + ""); Log.i("LOG", "Sending Android"); androidPush.sendInBackground(new SendCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
IOS: PFPush *androidPush = [[PFPush alloc] init]; [androidPush setQuery:androidQuery]; [androidPush setData:androidData]; NSLog(@"Sending Android Data"); [androidPush sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error){ if (succeeded) {
My Server Settings: 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, push: { android: { senderId: '12345678', apiKey: 'My apikey' }, ios: [ { pfx: '/cer/developmentcertificate.p12', bundleId: 'bundleId', production: false // Dev }, { pfx: '/cer/distributioncertificate.p12', bundleId: 'bundleId', production: true // Prod } ] } });
With parse-server (and hosted parse too), you should not sent push notifications from the client (because then anyone can spam all of your users with push notifications.) Call a cloud function instead, and send them from cloud code by passing the { useMasterKey: true } option as a second parameter... See #564.
Thank you very much. Actually this what I thought but the reason for spending almost 10 hours to this and in the end open issue that ANY WORD OF THIS IN TUTORIAL HERE https://github.com/ParsePlatform/Docs/blob/master/en/android/push-notifications.mdown and here https://github.com/ParsePlatform/parse-server/wiki/Push My app it's something like WhatsApp so i must send pushes from the client. Anyway thank you !!!