问题描述
2013 年 7 月,WhatsApp 为我们的应用程序开放了 URL 方案.我已经从我的应用程序向 Whatsapp 发送了文本,但现在我想发送一张图片.如何将图像发送到 Whatsapp?
我不知道该怎么做.
谢谢.
推荐答案
根据他们的 文档,你需要使用UIDocumentInteractionController.要在文档控制器中选择性地仅显示 Whatsapp(它会呈现给用户,此时他们可以选择 Whatsapp 进行共享),请按照他们的说明进行操作:
<块引用>或者,如果您只想在应用程序列表中显示 WhatsApp(而不是 WhatsApp 以及任何其他公共/*符合标准的应用程序),您可以指定使用 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
您需要将图像保存到磁盘,然后使用该文件 URL 创建一个 UIDocumentInteractionController.
下面是一些示例代码:
_documentController = [UIDocumentInteractionController interactionControllerWithURL:_imageFileURL]; _documentController.delegate = self; _documentController.UTI = @"net.whatsapp.image"; [_documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]