Skip to content

Instantly share code, notes, and snippets.

@anvarazizov
Created August 28, 2015 11:40
Show Gist options
  • Save anvarazizov/80434be233dffa0b07a8 to your computer and use it in GitHub Desktop.
Save anvarazizov/80434be233dffa0b07a8 to your computer and use it in GitHub Desktop.
main file for Cloud code
Parse.Cloud.beforeSave("Photo", function(request, response) {
console.log("version is:" + request.object.get("version"));
var version = request.object.get("version");
if (version == null && version == undefined ) {
version = 0;
}
version += 1;
console.log("version is:" + version);
request.object.set("version", version);
response.success();
});
Parse.Cloud.afterSave("Photo", function(request, response) {
console.log("version is:" + request.object.get("version"));
var objectID = request.object.id;
Parse.Push.send({
channels: ["global"],
data:
{
"alert": "Product IDs updated for object with id: " + objectID,
}
},
{
success: function() {
console.log("push was successful");
},
error: function(error) {
console.log(error);
}
});
response.success();
});
Parse.Cloud.job("sendPush", function(request, status) {
Parse.Push.send({
channels: ["global"],
data:
{
"alert": "Update process has started",
"content-available":"1",
}
},
{
success: function() {
console.log("push was successful");
},
error: function(error) {
console.log(error);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment