从 URL 下载视频并使用 UIActivityViewController 在 Facebook、消息、Twitter 上分享

Download video from URL and share it on Facebook, Messages, Twitter using UIActivityViewController

我正在使用 Alamofire 进行联网并使用 Swift 4

我需要从 URL 下载视频并将其存储在特定位置,然后在 FacebookMessages、[=16 上使用 UIActivityViewController 分享它=]等

有人可以提供一些示例代码或指导我吗?

问候!!

尝试使用 Alamofire 下载视频

func downloadVideo() {
    let destination = DownloadRequest.suggestedDownloadDestination()
    let url = "https://lynda_files2-a.akamaihd.net/secure/courses/391599/VBR_MP4h264_main_SD/391599_00_01_WX30_welcome.mp4?c3.ri=3770828196132302975&hashval=1522966719_0c357049da0562665ab3f99ccd3e8bca"

    Alamofire.download(url, to: destination).downloadProgress(queue: DispatchQueue.global(qos: .utility)) { (progress) in
        print("Progress: \(progress.fractionCompleted)")
    } .validate().responseData { [weak self] (response)  in
        self?.shareVideo(from: response.destinationURL!)
    }
}

并使用 UIActivityViewController 分享

func shareVideo(from url: URL) {
    let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
    present(activityViewController, animated: true, completion: nil)
}