Skip to content

Instantly share code, notes, and snippets.

@dongalor
Created November 25, 2018 17:30
Show Gist options
  • Save dongalor/6dda14517778fecf3127f9d29fbe2a0c to your computer and use it in GitHub Desktop.
Save dongalor/6dda14517778fecf3127f9d29fbe2a0c to your computer and use it in GitHub Desktop.
Parse.Cloud.define("testPush", async (request) => {
const {params, master, log, headers, ip, functionName} = request;
let userQuery = new Parse.Query(Parse.User);
userQuery.equalTo("objectId", params.userId);
// Find devices associated with these users
let pushQuery = new Parse.Query(Parse.Installation);
pushQuery.matchesKeyInQuery('deviceToken', 'deviceToken', userQuery);
// pushQuery.matchesKeyInQuery('user', userQuery);
// pushQuery.matchesQuery('user', userQuery);
console.log('Sending push to user: ' + params.userId);
Parse.Push.send({
where: pushQuery,
data: {
data: params.dataPush,
alert: "Free hotdogs at the Parse concession stand!"
}
}, { useMasterKey: true }).then(function() {
return true;
// Push was successful
}, function(error) {
return error;
// Handle error
});
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment