You can send text messages using WhatsApp URL Scheme like this:
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
This will open the application and ask for destination to send Hello World!
.
To send images or videos, you can use the UIActivityViewController
like you already noticed, or use UIDocumentInteractionController
, that may be closer to what you are looking for:
_documentController = [UIDocumentInteractionController interactionControllerWithURL:_imageFileURL];
_documentController.delegate = self;
_documentController.UTI = @"net.whatsapp.image";
[_documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
To show only whatsapp in the application list, use the private whatsapp file extension or UTI:
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
When triggered, WhatsApp will immediately
present the user with the contact/group picker screen. The media will
be automatically sent to a selected contact/group.
More information in this WhatsApp FAQ.