Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WhatsApp with UIActivityViewController for sharing image not using UIDocumentInteractionController

Tags:

ios

ios7

whatsapp

How to set up WhatsApp with UIActivityViewController for sharing image, not using UIDocumentInteractionController. Please let me know if there is another way. Thanks in advance.

like image 893
iOS_Raj Avatar asked Apr 29 '14 13:04

iOS_Raj


2 Answers

This is the code to share text and url from activity controller

NSString *URLString=@"http://video.app.com/video.php?";

NSURL *VideoURL=[NSURL URLWithString:URLString];

NSMutableArray *activityItems= [NSMutableArray arrayWithObjects:VideoURL, @"Hey, check out this video I've shared with you, it's awesome!", nil];

self.activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
self.activityViewController.excludedActivityTypes = @[UIActivityTypePostToWeibo,UIActivityTypePrint,
                                                      UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,
                                                      UIActivityTypeSaveToCameraRoll,UIActivityTypeAddToReadingList,
                                                      UIActivityTypePostToFlickr,UIActivityTypePostToVimeo,
                                                      UIActivityTypePostToTencentWeibo,UIActivityTypeAirDrop];

[self presentViewController:self.activityViewController animated:YES completion:nil];

For Swift 3.0

let objectsToShare = ["\(Title) \n \(Description)"]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.setValue("App Name", forKey: "subject")

let excludeActivities = [UIActivityType.airDrop, UIActivityType.print, UIActivityType.assignToContact, UIActivityType.saveToCameraRoll, UIActivityType.addToReadingList, UIActivityType.postToFlickr, UIActivityType.postToVimeo, UIActivityType.postToFacebook, UIActivityType.message, UIActivityType.postToWeibo]
activityVC.excludedActivityTypes = excludeActivities

self.present(activityVC, animated: true, completion: { _ in })
like image 133
Mr. Bean Avatar answered Nov 15 '22 17:11

Mr. Bean


Try the URL scheme approach described here on the official WhatsApp site:

https://www.whatsapp.com/faq/iphone/23559013

like image 34
Stavash Avatar answered Nov 15 '22 19:11

Stavash