iPhoneアプリケーション開発でUIDocumentIntractionControllerまたはAPIを使用して、iOSアプリからWhatsAppに画像とテキストを共有することは可能ですか?
2798 次
3 に答える
4
FAQ の次のリンクを参照してください。
于 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 に答える