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.
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 })
Try the URL scheme approach described here on the official WhatsApp site:
https://www.whatsapp.com/faq/iphone/23559013
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With