I'm having a bit of a problem with AFNetworking in a share extension. In the didSelectPost
, I'm calling:
[[AuthClient sharedClient] POST: @"/v1/events"
parameters: params success: ^ (AFHTTPRequestOperation * operation, id responseObject) {
[self.extensionContext completeRequestReturningItems: nil completionHandler: nil];
}
failure: ^ (AFHTTPRequestOperation * operation, NSError * error) {
NSLog(@"error: %@", error);
[self.extensionContext cancelRequestWithError: error];
}
];
[AuthClient sharedClient]
uses the singleton pattern to get an instance of AFHTTPSessionManager
with NSURLSessionConfiguration
set with a background identifier.
However, neither the success or failure callbacks are invoked and it just hangs indefinitely until the extension gets killed. Interestingly, the HTTP request finishes fine on the server side; the completion just never gets invoked.