ios - 通过 WhatsApp 共享 PDF

标签 ios swift pdf whatsapp

我想直接将 PDF 分享到 WhatsApp。

下面是我在 iOS 应用程序中找到的在 WhatsApp 中发送文本和图像的链接,但无法找到如何将 PDF 直接发送到 WhatsApp。

Share image/text through WhatsApp in an iOS app

最佳答案

您可以使用共享扩展 (UIActivityViewController) 来共享您的 pdf 文件 URL。请注意,用户必须选择 WhatsApp 应用程序才能共享文件。如果您想首先检查是否安装了 WhatsApp,则需要注意编辑您的 info.plist 并将 whatsapp 添加到您的 LSApplicationQueriesSchemes 数组:

enter image description here


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")
        }
    }
}

关于ios - 通过 WhatsApp 共享 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49022906/

相关文章:

ios - FBSDKLog 缺少权限

ios - 将AFNetworking与YouTube UITableView结合使用

ios - 当应用程序进入前台时,AVPlayer 状态会更新

arrays - 返回没有具有更新索引的第一个元素的数组(Swift)

swift SpriteKit : "MCTFruit does not have a member named append?

javascript - 石勒堆导出为pdf

ios - UITableView - 什么是 indexPath?

ios - Swift:如何更改 Cell.TextLabel 对齐方式中的文本以从右到左显示?

java - 使用 iText 创建 10000 多页 PDF

c# - PDFsharp 1.50 测试版 3 : Empty owner password error when adding password to PDF