I am using the share option in my app using UIActivityViewController
; it's working fine in iOS 9.2 and Google+ share option is not working in iOS 9.3
To confirm this, I had downloaded other app which has the share option using UIActivityViewController
, and the issue is the entire UI of the app is hanging up.
How can I resolve this issue?
Edit 1: code:
NSURL * URL = [[NSURL alloc]initWithString:@"http://domainName/message.php?"];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:@"GET"];
NSString *tempEmailId = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:CURRENT_USER_EMAIL_ID_UD_KEY];
NSString *tempPassword = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:CURRENT_USER_PASSWORD_UD_KEY];
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", tempEmailId, tempPassword];
[request setValue:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)] forHTTPHeaderField: @"Authorization"];
//NSLog(@"request %@\n",request);
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (data != nil) {
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray * activityItems = @[responseString];
dispatch_async(dispatch_get_main_queue(), ^{
activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:activities];
[activityViewController setValue:@"Today's Recommendations" forKey:@"subject"];
activityViewController.excludedActivityTypes = @[UIActivityTypePostToFacebook];
[activityViewController setCompletionWithItemsHandler:
^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"activityType: %@, returnedItems: %@, activityError: %@", activityType, returnedItems, activityError.userInfo);
if (completed)
{
NSLog(@"The Activity: %@ was completed", activityType);
}
else
{
NSLog(@"The Activity: %@ was NOT completed", activityType);
}
});
}];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:activityViewController animated:YES completion:nil];
}
//if iPad
else {
activityViewController.modalPresentationStyle = UIModalPresentationPopover;
// activityViewController.popoverPresentationController.sourceView = sender;
activityViewController.popoverPresentationController.sourceView = self.view;
if ([sender isKindOfClass:[UIButton class]]) {
UIButton *btn = (UIButton *)sender;
activityViewController.popoverPresentationController.sourceRect = btn.frame;
}
[self presentViewController:activityViewController animated:YES completion:nil];
}
});
}
}] resume];
NOTE:: Mail, Twitter, and Evernote are working. Only Google+ is hanging up.
Edit 2:: I don't know exactly but I think- its not related to open URL. If it's related then please let me know HOW?