Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
828 views
in Technique[技术] by (71.8m points)

iphone - How send image to WhatsApp from my application?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...