Sharing image and URL using UIActivityViewController works fine for facebook and gmail but didn't work for whatsapp. Here's the code i used
- (void)share {
UIScreen *screen = [UIScreen mainScreen];
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContextWithOptions(screen.bounds.size, NO, 0);
[keyWindow drawViewHierarchyInRect:keyWindow.bounds afterScreenUpdates:YES];
UIImage *snapShotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *imageToShare = snapShotImage;
NSURL *urlToShare = [NSURL URLWithString:@"http://google.com"];
NSMutableArray *activityItems = [NSMutableArray arrayWithObjects:urlToShare, imageToShare, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
activityViewController.excludedActivityTypes = @[
UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypeAirDrop];
[self presentViewController:activityViewController animated:YES completion:nil];
}
- Have I miss anything?
- Do i need to implement custom activity for whatsapp?
Note: Incase of 2 we need to find this hiding whatsapp from activityviewcontroller solution before proceeding