通过WhatsApp共享PDF [英] Share PDF through WhatsApp
问题描述
我想直接与WhatsApp共享PDF.
I want to share a PDF directly to WhatsApp.
下面是我发现的在iOS应用程序的WhatsApp中发送文本和图像的链接,但是找不到如何直接将PDF发送到WhatsApp的链接.
Below is the link I found to send text and image in WhatsApp in an iOS app, but unable to find that how to send PDF directly to WhatsApp.
推荐答案
您可以使用共享扩展名(UIActivityViewController)共享pdf fileURL.请注意,用户将必须选择WhatsApp应用程序才能共享文件.如果要首先检查是否已安装WhatsApp,则需要注意编辑info.plist并将whatsapp
添加到LSApplicationQueriesSchemes
阵列中的步骤:
You can use Share Extension (UIActivityViewController) to share your pdf fileURL. Note that the user will have to select the WhatsApp application to share the file. Note is is required to edit your info.plist and add whatsapp
to your LSApplicationQueriesSchemes
array if you would like to check first if WhatsApp is installed:
func sharePdfWhatsApp(url: URL) {
let whatsappURL = URL(string:"whatsapp://app")!
// this will make sure WhatsApp it is installed
if UIApplication.shared.canOpenURL(whatsappURL) {
let controller = UIActivityViewController(activityItems: [url], applicationActivities: nil)
present(controller, animated: true) {
print("done")
}
}
}
这篇关于通过WhatsApp共享PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!