Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Not able to share the video on twitter through UIActivityViewController.

Text and local video storage works fine. So authentication is not an issue.

If video is stored in the app itself, then the share works fine Path URL

file:///private/var/containers/Bundle/Application/B7855569-3254-4CC2-9573-254D09528E38/podhunt.app/PlugIns/podhunt-shareExtension.appex/demo_video.mp4

If the path is below, then the twitter share does not work Path Url

file:///var/mobile/Containers/Data/PluginKitPlugin/5831780C-50AF-41FA-8435-941CAC47EBE6/Documents/10c41d4a-c161-4c78-bc61-ca789804a982.mp4

This does not work

    URLSession.shared.downloadTask(with: audioUrl) { location, response, error in
    guard let location = location, error == nil else { return }
    do {
           try FileManager.default.moveItem(at: location, to: destinationUrl)
           DispatchQueue.main.async {
               let activityVC = UIActivityViewController(activityItems: [destinationUrl], applicationActivities: nil)
               self.present(activityVC, animated: true, completion: nil)
             }
           } catch {
      }
    }.resume()

This works


URLSession.shared.downloadTask(with: audioUrl) { location, response, error in
    guard let location = location, error == nil else { return }
    do {
           try FileManager.default.moveItem(at: location, to: destinationUrl)
           DispatchQueue.main.async {
           guard let path = Bundle.main.path(forResource: "demo_video", ofType:"mp4") else {
               return
            }
               let activityVC = UIActivityViewController(activityItems: [URL(fileURLWithPath: path)],applicationActivities: nil)
               self.present(activityVC, animated: true, completion: nil)
             }
           } catch {
      }
    }.resume() 

I am working on iOS app extension.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
437 views
Welcome To Ask or Share your Answers For Others

1 Answer

Resolved. Apparently I was sharing mp3 file as an mp4 to twitter which it does not recognize. You cannot share mp3 file to twitter as it does not support audio format.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...