如何从我的应用程序发送图像到WhatsApp? [英] How send image to WhatsApp from my application?
问题描述
2013年7月,WhatsApp为我们的应用程序开放了他们的URL方案。我已经从我的应用程序发送文本到Whatsapp,但现在我想发送一个图像。如何将图像发送到Whatsapp?
我不知道怎么做。
谢谢。
根据他们的文档,您需要使用 UIDocumentInteractionController
。要在文档控制器中选择性地仅显示Whatsapp(它呈现给用户,此时他们可以选择要分享的Whatsapp),按照他们的指示:
或者,如果您只想在应用程序列表中显示WhatsApp(而不是WhatsApp以及任何其他符合公共/ *的应用程序),您可以指定一个上述类型的文件,该文件使用扩展名保存WhatsApp:
images - «.wai»,类型为net.whatsapp.image
视频 - «.wam»,类型为net.whatsapp.movie
音频文件 - «.waa»,类型为net.whatsapp.audio
您需要将映像保存到磁盘,然后使用该文件URL创建 UIDocumentInteractionController
。 / p>
以下是一些示例代码:
_documentController = [UIDocumentInteractionController interactionControllerWithURL: _图像文件URL]
_documentController.delegate = self;
_documentController.UTI = @net.whatsapp.image;
[_documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]
In July 2013 WhatsApp opened their URL schemes for our apps. I have sent text to Whatsapp from my application, but now I would like send a image. How send a image to Whatsapp?
I'm not sure how do it.
Thank you.
Per their documentation, you need to use UIDocumentInteractionController
. To selectively display only Whatsapp in the document controller (it is presented to the user, at which point they can select Whatsapp to share to), follow their instructions:
Alternatively, if you want to show only WhatsApp in the application list (instead of WhatsApp plus any other public/*-conforming apps) you can specify a file of one of aforementioned types saved with the extension that is exclusive to WhatsApp:
images - «.wai» which is of type net.whatsapp.image
videos - «.wam» which is of type net.whatsapp.movie
audio files - «.waa» which is of type net.whatsapp.audio
You need to save the image to disk, and then create a UIDocumentInteractionController
with that file URL.
Here is some example code:
_documentController = [UIDocumentInteractionController interactionControllerWithURL:_imageFileURL];
_documentController.delegate = self;
_documentController.UTI = @"net.whatsapp.image";
[_documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]
这篇关于如何从我的应用程序发送图像到WhatsApp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!