1

是否可以在 iPhone 应用程序开发中使用 UIDocumentIntractionController 或 API将 iOS 应用程序中的图像和文本共享到WhatsApp ?

4

3 回答 3

4

Please look at this link from the FAQ:

http://www.whatsapp.com/faq/en/iphone/23559013

于 2013-11-06T07:20:16.500 回答
0

我发现如果您的应用程序创建了照片、视频或音频笔记,并且您希望您的用户使用 WhatsApp 共享这些媒体,您可以使用 Document Interaction API 将您的媒体发送给您的 WhatsApp 联系人和群组。

你可以参考这个链接: http: //www.whatsapp.com/faq/en/iphone/23559013

于 2014-04-30T07:28:40.103 回答
-1

在 Swift 3 中使用此代码

 @IBAction func whatsappShareWithImages(_ sender: AnyObject)
    {

        let urlWhats = "whatsapp://app"
        if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters:CharacterSet.urlQueryAllowed) {
            if let whatsappURL = URL(string: urlString) {

                if UIApplication.shared.canOpenURL(whatsappURL as URL) {

                    if let image = UIImage(named: "whatsappIcon") {
                        if let imageData = UIImageJPEGRepresentation(image, 1.0) {
                            let tempFile = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent("Documents/whatsAppTmp.wai")
                            do {
                                try imageData.write(to: tempFile, options: .atomic)
                                self.documentInteractionController = UIDocumentInteractionController(url: tempFile)
                                self.documentInteractionController.uti = "net.whatsapp.image"
                                self.documentInteractionController.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)

                            } catch {
                                print(error)
                            }
                        }
                    }

                } else {
                    // Cannot open whatsapp
                }
            }
        }

    }

在您的应用“plist”中添加此代码

  <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>whatsapp</string>
    </array>

也可以参考小程序参考:https ://github.com/nithinbemitk/iOS-Whatsapp-Share

于 2016-10-28T05:49:27.493 回答