Created
November 25, 2018 17:30
-
-
Save dongalor/6dda14517778fecf3127f9d29fbe2a0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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