So I have this iOS Share Extension for my app that sends a result to my server in didSelectPost()
when the 'POST' button is clicked.
It all works fine on simulator; the request is sent and I can see data packets going out in Charles.
On iOS 9, the Share Extension launches correctly, but the request is not sent in didSelectPost
function.
I'm not sure if it's something wrong with my Share Extension or the NSURLSession
.
The code -
- (void)didSelectPost {
//Get session configuration
NSString * const configName = @"com.xx.xxx";
self.sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configName];
self.sessionConfiguration.sharedContainerIdentifier = @"group.xx.ShareURL";
//Init NSURLSession
self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration];
NSURLRequest *request = [self postContentToService:self.shareUrl.absoluteString];
//post request
self.sessionTask = [self.session dataTaskWithRequest:request];
//resume
[self.sessionTask resume];
[self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
}
Any help is appreciated.