Tyler Tyler - 4 months ago 39
iOS Question

Is there a way to share video with SLComposeViewController fb and twitter

I need to allow users to share video and images to fb and twitter. I recently found the SLComposeViewController but it seems there is only an addImage method and no addVideo method. I'd really like to use the SLComposeViewController to share video because I'm on a tough time constraint. This is what I have so far and it works but there is no addVideo method:

var shareToTwitter : SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
shareToTwitter.setInitialText("initial text")
//shareToTwitter.addImage(UIImage(named: "32.png"))

self.presentViewController(shareToTwitter, animated: true, completion: nil)


I'd really like to have the same sharing feature like instagram does. Is this possible with the SLComposeViewController?

Answer

SLComposeViewController is only used for share text and image now, it cannot be used for share video, maybe in the future it can share video if Apple want to do it.

Now you can use twitter's the uploading media new API to share video to twitter.

I made a convenient class to make post video to twitter more easily.

Please check this: https://github.com/liu044100/SocialVideoHelper

You just need to call this class method.

+(void)uploadTwitterVideo:(NSData*)videoData account:(ACAccount*)account withCompletion:(dispatch_block_t)completion;

Hope it can resolve your problem.

Best Regards.