This question is simple, but I didn't find it already asked ... Is there a way to cancel a Parse cloud function callback ?? I'm developing an app, where it would be great to ignore (or even better, not receive at all) the callback of a cloud function given certain events (like a log out).
I'm using cloudCode to retrieve an user New Messages, I'm doing that asynchronously. I would have to cancel that request if a user logs out, to avoid having the new messages from a user that is no longer logged in.
I've seen that, for example, on a PFQuery where we have a "Cancel" method to avoid the callback of the query, also for PFFiles there is a "cancel", but did not see anything like this for cloud functions .
Is there a way to do this ? to cancel the cloudCode request??
EDIT: Here the Objective-C code I'm using to call the function
[PFCloud callFunctionInBackground:"getNewMessages" withParameters:@{} block:^(id object, NSError *error) {
if (!error) {
NSArray *newMessages = (NSArray *)object;
NSLog(@"*** %lu NEW MESSAGES FOUND", (unsigned long)newMessages.count);
} else {
NSLog(@"*** ERROR getting new messages: %@", error);
}
}];
And this is the function in cloudCode
Parse.Cloud.define("getNewMessages", function(request, response) {
var newMessagesQuery = new Parse.Query("Messages");
newMessagesQuery.equalTo("receiver", request.user);
newMessagesQuery.descending("createdAt");
newMessagesQuery.find().then(function(myNewMessages) {
response.success(myNewMessages);
},function(error) {
console.error("Error getting new messages");
response.success(error);
});
});
Thanks!