Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I share image +text caption(URL) on whatsapp from iphone?

I have used following code for share image on WhatsApp but I am unable to set the caption text using following code.

I have tried annotation property of UIDocumentInteractionController,But in WhatsApp developer form there is not any key is specified for annotation.

I do know that we can do it by using UIImageGraphicContext, But I need to share URL as caption

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]])
{
    NSString * savePath  = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];

    [UIImageJPEGRepresentation([UIImage imageNamed:@"Convenor- image-SURANA1.png"], 1.0) writeToFile:savePath atomically:YES];

    _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
    _documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"wwww.google.com" forKey:@"whatsappCaption"];

    _documentInteractionController.UTI = @"net.whatsapp.image";
    _documentInteractionController.delegate = self;

    [_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];

} else {
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Alert." message:@"Por favor, instale Whatsapp." delegate:nil cancelButtonTitle:@"Está bem" otherButtonTitles:nil];
    [alert show];
}
like image 935
Bhavik Avatar asked Nov 23 '14 12:11

Bhavik


People also ask

How do you send picture captions on WhatsApp iPhone?

Open WhatsApp and go to the chat from where you want to forward the image. Tap and hold the image and click on the 'forward' option. Select the personal chat or group to which you want to forward the image. The image will be shared without losing the caption.

How do you add a caption on WhatsApp status?

Open WhatsApp > STATUS. Tap: Text to compose a written status update. You can tap Emoji to add emoji or GIFs, T to pick a font, or Color to pick a background color.


1 Answers

You cannot pre-fill caption while sharing image on whatsapp. Facebook has already deprecated this functionality from Facebook, Instagram also.

You can either send a text or an image. But programmatically pre-filling caption is not possible.

The code in the question is fine to send an image. In order to send a plain text you can use the reference of below mentioned link:

http://www.whatsapp.com/faq/en/iphone/23559013

NOTE: Setting caption programmatically is not possible.

Hope this helps!

enter image description here

like image 124
Dharmesh Siddhpura Avatar answered Oct 31 '22 13:10

Dharmesh Siddhpura