Поделиться изображением и текстом в WhatsApp в IOS программно?

Я должен добавить изображение и некоторый текст в WhatsApp с помощью кодирования. Как я могу выполнить это, чтобы решить мою проблему?


person Anil Jangir    schedule 19.06.2015    source источник
comment
Вы проверили этот пост - stackoverflow.com/questions/19524635/ ?   -  person May13ank    schedule 19.06.2015
comment
@AshishKakkad Я хочу поделиться изображением с текстом вроде (изображение с подписью)   -  person Anil Jangir    schedule 19.06.2015


Ответы (1)


Вы можете опубликовать изображение или текст в WhatsApp. Но вы не будете публиковать оба сообщения одновременно, потому что WhatsApp не предоставляет никакого API, с помощью которого вы можете добавить подпись и опубликовать изображение с текстом.

Ниже приведен пример публикации изображения из приложения для iPhone в WhatsApp в соответствии с документацией WhatsApp:

в файле ViewController.h:

@interface ViewController : UIViewController
{
}

@property(nonatomic,retain) UIDocumentInteractionController *documentationInteractionController;

в файле ViewController.m:

- (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;

}
person Nitin Gohel    schedule 19.06.2015