如何在不使用 UIActivityViewController 的情况下在 WhatsApp 上分享视频? [英] How to share video on WhatsApp without using UIActivityViewController?

查看:38
本文介绍了如何在不使用 UIActivityViewController 的情况下在 WhatsApp 上分享视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am currently trying to enable the functionality to share a video on WhatsApp but without using UIActivityViewController, as Tik Tok does for example. When you click on "share" on WhatsApp, it directly redirects you to WhatsApp and contacts pop up so that you can share the video.

我有点成功地与 ActivityViewController 共享它,这样:

I kinda succeeded in sharing it but with ActivityViewController, this way:

 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)

我很高兴知道有人可以帮助我.

I would be glad to know someone can help me out.

推荐答案

尝试使用 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)
    }
}

这篇关于如何在不使用 UIActivityViewController 的情况下在 WhatsApp 上分享视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆