如何在不使用UIActivityViewController的情况下在WhatsApp上共享视频



我目前正在尝试启用在WhatsApp上共享视频的功能,但不使用UIActivityViewController,例如Tik Tok。当你在WhatsApp上点击"分享"时,它会直接将你重定向到WhatsApp,并弹出联系人,以便你可以分享视频。

我有点成功地分享了它,但与ActivityViewController,通过这种方式:

let path = Bundle.main.url(forResource: "Rap God", withExtension: "mp4")!.relativePath
let fileUrl = NSURL(fileURLWithPath: path)
controller = UIDocumentInteractionController(url: fileUrl as URL)
controller.uti = "net.whatsapp.movie"
controller.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)

我很高兴知道有人能帮我。

尝试使用UIApplication'scanOpenURL(_:)open(_:options:completionHandler:)

let urlString = "https://stackoverflow.com/questions/60282744/how-to-share-video-on-whatsapp-without-using-uiactivityviewcontroller"
let shareString = "whatsapp://send?text=(urlString)"
if let url = URL(string: shareString), UIApplication.shared.canOpenURL(url)  {
UIApplication.shared.open(url, options: [:]) { (completed) in
print(completed)
}
}

相关内容

最新更新