I'm writing an iOS app that has locally saved videos (.mov). I'm trying to attach the video via UIActivityViewController. It works great for email. The video is successfully attached and sent. It also works when saving to camera roll.
It doesn't work when attaching to Messages. Only the text is shown. Also Twitter and Facebook do not even show up. When I remove the video attachment, Twitter and Facebook finally begin to show. I don't really care too much about Messages but can anyone tell me why Facebook and Twitter are not showing up?
Heres my code:
- (IBAction) shareVideo {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *URL = [documentsDirectory stringByAppendingPathComponent:demoName];
NSString* someText = demoName;
NSURL *urlToShare = [NSURL fileURLWithPath:URL isDirectory:NO];
NSArray* dataToShare = @[someText, urlToShare];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare
applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypePrint,UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact];
activityViewController.completionHandler = ^(NSString *activityType, BOOL completed) {
//if (completed) {
[self dismissViewControllerAnimated:YES completion:nil];
//}
};
[self presentViewController:activityViewController animated:YES completion:nil];
}
The other answers are outdated. This works:
@IBAction func didTapShare(sender: AnyObject) {
let videoURL = NSURL(fileURLWithPath:localVideoPath)
let activityItems = [videoURL, "Check this out!" ]
let activityController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
activityController.popoverPresentationController?.sourceView = self.view
activityController.popoverPresentationController?.sourceRect = self.view.frame
self.presentViewController(activityController, animated: true, completion: nil)
}
You cannot share videos on Facebook, twitter or on sms in iOS 6 or below. It's only available in iOS7.
Also, please check https://stackoverflow.com/a/20211603/2074320 for your information.
they are hidden because you cannot display movs on fb twitter or in sms
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