I'm on day 3 of learning Cloud Code and have made minimal progress. I'm confused as to how the call process works. In Cloud Code, I need to use afterSave to query for a class, where key "sent" equals false, and for each recipient in recipients array, push a notification to each and set "sent" to true.
I have the afterSave function saved in main.js, but every time I call it using PFCloud.callFunctionInBackground() I'm getting [Error]: function not found (Code: 141, Version: 1.7.2).
Here's my afterSave trigger:
Parse.Cloud.afterSave("Send", function(request) {
query = new Parse.Query("Shares");
query.get(request.object.get("share").id, {
success: function(post) {
console.success("Howdy");
},
error: function(error) {
console.error("Got an error " + error.code + " : " + error.message);
}
});
});
And here I'm calling the function in Swift:
PFCloud.callFunctionInBackground("Send", withParameters: nil) {
(response: AnyObject?, error: NSError?) -> Void in
let result = response as? String
println(result)
}
If I'm calling the afterSave trigger inside a saveInBackgroundWithBlock closure, do I call it using PFCloud.callFunctionInBackground?