Reputation: 122
I want to share image to WhatsApp directly, without showing any intermediate controllers, like UIDocumentInteractionController or UIActivityController.
Official WhatsApp documentation says nothing about direct image sharing, at first glance direct sharing seems impossible.
But I know it's possible. At least 2 apps in App Store can do it:
How does Workflow do it? Thanks in advance.
UPDATE: I found something interesting here: http://resources.infosecinstitute.com/ios-application-security-part-30-attacking-url-schemes/#gref. There is a hint to existence of "whatsapp://image/%@" url scheme.
Upvotes: 3
Views: 1089
Reputation: 361
I did this and it works.
UIImage *image = [UIImage imageNamed:@"your_image_name"];
NSArray *activityItems = @[image];
UIActivityViewController *activityViewControntroller = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityViewControntroller.excludedActivityTypes = @[];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
activityViewControntroller.popoverPresentationController.sourceView = self.view;
activityViewControntroller.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width/2, self.view.bounds.size.height/4, 0, 0);
}
[self presentViewController:activityViewControntroller animated:true completion:nil];
Upvotes: -1
Reputation: 122
Found the solution by LeoNatan@github. Works perfectly.
https://github.com/LeoNatan/LNExtensionExecutor/
Upvotes: 2