0

I am trying to use TWTRComposerViewController to share a video to twitter. The videos resolution 540x960 and they are about 3-4 seconds. There is no problem to share images, but when I share video nothing happens and the app would not respond anymore. I use the following code:

private func presentTWTRComposerViewController(withInitialText initialText: String, image: UIImage?, videoUrl: URL?, presentingViewController: UIViewController)
{
    var composer: TWTRComposerViewController?

    if let videoUrl = videoUrl
    {
        composer = TWTRComposerViewController(initialText: initialText, image: nil, videoURL: videoUrl)
    }
    else
    {
        composer = TWTRComposerViewController(initialText: initialText, image: image, videoURL: nil)
    }

    presentingViewController.present(composer!, animated: true)
}

I also tried using h264 and h265 videos and got the same results. I tried to reduce the size of the video to around 200x300 and also got the same results. What might be the issue?

Erik Sapir
  • 23,209
  • 28
  • 81
  • 141
  • how are you getting the `videoUrl`? – Artal Dec 24 '17 at 23:09
  • This is a url pointing to local file stored in the app documents folder – Erik Sapir Dec 24 '17 at 23:10
  • it should probably be an asset url, not just a local file – Artal Dec 24 '17 at 23:11
  • I also tried to do it – Erik Sapir Dec 24 '17 at 23:12
  • their docs say that the url needs to be `Of the form of assets-library` (https://dev.twitter.com/twitterkit/ios/appledocs/Classes/TWTRComposerViewController.html#//api/name/initWithInitialText:image:videoURL:) so local file will not work for sure. there's also a bunch of other requirement that you can check out here: https://dev.twitter.com/twitterkit/ios/compose-tweets (under Video Requirements), and an example too – Artal Dec 24 '17 at 23:17

0 Answers0