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

问题描述 投票:1回答:1

我目前正在尝试启用该功能以在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)

[我很高兴认识到有人可以帮助我。

ios swift whatsapp
1个回答
0
投票

尝试使用UIApplication's canOpenURL(_:)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)
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.