I am to add an image and some text in whatsapp with the help of coding. How can I perform it to solve my problem?
Asked
Active
Viewed 1,686 times
0
-
Have you checked this post - http://stackoverflow.com/questions/19524635/how-send-image-to-whatsapp-from-my-application ? – May13ank Jun 19 '15 at 09:05
-
@AshishKakkad i want to share an image with text like (image with caption) – Anil Jangir Jun 19 '15 at 09:19
1 Answers
4
You can post Image or Text on WhatsApp. But you wont post both at a time becouse whatsapp not provide any API that you can add caption and post image with text.
Following is an example for posting image from iPhone app to whatsapp as par WhatsApp Documentation:
in ViewController.h file:
@interface ViewController : UIViewController
{
}
@property(nonatomic,retain) UIDocumentInteractionController *documentationInteractionController;
in ViewController.m file:
- (IBAction)bocClick:(UIButton *)sender {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]; //here i am fetched image path from document directory and convert it in to URL and use bellow
NSURL *imageFileURL =[NSURL fileURLWithPath:getImagePath];
NSLog(@"imag %@",imageFileURL);
self.documentationInteractionController.delegate = self;
self.documentationInteractionController.UTI = @"net.whatsapp.image";
self.documentationInteractionController = [self setupControllerWithURL:imageFileURL usingDelegate:self];
[self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL
usingDelegate: (id ) interactionDelegate {
self.documentationInteractionController =
[UIDocumentInteractionController interactionControllerWithURL: fileURL];
self.documentationInteractionController.delegate = interactionDelegate;
return self.documentationInteractionController;
}

Nitin Gohel
- 49,482
- 17
- 105
- 144