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 - Master key is invalid #575

Closed
adamofsky opened this issue Feb 22, 2016 · 2 comments
Closed

Sending Push Notifications - Master key is invalid #575

adamofsky opened this issue Feb 22, 2016 · 2 comments

Comments

@adamofsky
Copy link

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

@gfosco
Copy link
Contributor

gfosco commented Feb 22, 2016

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.

@gfosco gfosco closed this as completed Feb 22, 2016
@adamofsky
Copy link
Author

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 !!!

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

2 participants