I need to share
both image
and text
directly to the WhatsApp
. I tried with actionsheet
and UIDocumentIntractionController
.
I tried with this code:
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){
[AdDetailsViewController processImageDataWithURLString:self.strThumbImage andBlock:^(NSData *imageData) {
self.watsappShareimg = [[UIImage alloc]initWithData:imageData];
}];
UIImage * iconImage = self.watsappShareimg; //[UIImage imageNamed:@"flag.png"];
NSString * savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];
[UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES];
self.documentationInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
self.documentationInteractionController.UTI = @"net.whatsapp.image";
self.documentationInteractionController.delegate = self;
[self.documentationInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];
} else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
Thank u in advance