iOS share image AND text to WhatsApp

Js Lim picture Js Lim · Apr 20, 2015 · Viewed 18.8k times · Source

I have googled, and get some solutions, it seems the only possible way is thru UIDocumentInteractionController. I have found the result that able to share text ONLY, also found result that share image ONLY.

But what I want is share BOTH.

I know this question may be duplicated, I just wanted to make it clear, here is the screenshot...

WhatsApp share image + text

(This is shared from Android)

Answer

Gauraw picture Gauraw · Mar 2, 2016

You can use UIActivityViewController to share image , text or URL .Here is a small example :

NSString *textToShare = @"Enter your text to be shared";
UIImage * image = [UIImage imageNamed:@"imagename"];

NSArray *objectsToShare = @[textToShare, image];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];


[self presentViewController:activityVC animated:YES completion:nil];

Run the above code and select whats app to share if you want you can share by other mediums also . This is apple' s default share method