Created
August 28, 2015 11:40
-
-
Save anvarazizov/80434be233dffa0b07a8 to your computer and use it in GitHub Desktop.
main file for Cloud code
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.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