Update:
The issue ended up being that I was using sample cloud code for parse 3+, and this app was using 2.X. I had to add a 'response' after the request part of cloud code. Once I did that, it worked fine.
It's pretty much all there in the title for the problem I am experiencing. I have CloudCode set up with my Parse app on back4app to send targeted push notifications when a certain action is performed within the app. The notification sends immediately with no problem, but it doesn't return that it was actually successful in its notification. About a minute after it sends the notification, it will return an error message of
"The request timed out. (Code: 100, Version: 1.14.2)"
It then retries it, and AGAIN successfully sends the push, but doesn't ever register it did it properly. The full verbose language I get for the error message is:
<4> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x6000004f23a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <90826051-6A6B-46ED-BAE8-1CDF082B2465>.<4>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <90826051-6A6B-46ED-BAE8-1CDF082B2465>.<4>"
), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://parseapi.back4app.com/functions/invitationNotification, NSErrorFailingURLKey=https://parseapi.back4app.com/functions/invitationNotification, _kCFStreamErrorDomainKey=4}
The cloud code I am using is:
Parse.Cloud.define("invitationNotification", (request) => {
let userId = request.params.theUserId;
let query = new Parse.Query(Parse.Installation);
query.equalTo("userId", userId);
return Parse.Push.send({
where: query,
data: {
alert: "MESSAGEBODY",
category : "TAGGED_CATEGORY",
sound: "default.caf"
}
}, { useMasterKey: true }).then(function() {
response.success("Push was sent successfully.")
}, function(error) {
response.error("Push failed to send with error: " + error.message);
});
});
The code in iOS app to call this is:
[PFCloud callFunctionInBackground:@"invitationNotification"
withParameters:@{@"theUserId": @"USERIDGOESHERE"}
block:^(NSString *success, NSError *error) {
if (!error) {
NSLog(@"Successful push");
}
else {
NSLog(@"error %@", error.description);
}
}];