通过WhatsApp共享PDF [英] Share PDF through WhatsApp

查看:355
本文介绍了通过WhatsApp共享PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想直接与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.

在iOS应用中通过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屋!

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