我目前正在尝试启用在 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的
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)
}
}
关于ios - 如何在不使用 UIActivityViewController 的情况下在 WhatsApp 上分享视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60282744/