Sending image to whatsapp with ActivityVC

405 views Asked by At

I'm trying to share an image and text.

But when i'm trying to share using whatsapp i dont see the image and it doesnt get sent (i do see it when i'm trying to share to facebook or mail...).

Whats going on?

- (void)shareImage:(UIImage *)image 
{

    NSString *sharedMsg=[NSString stringWithFormat:@"Hello world"];
    UIImage* sharedImg=image;
    NSArray* sharedObjects=[NSArray arrayWithObjects:sharedMsg, sharedImg, nil];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc]
                                                        initWithActivityItems:sharedObjects applicationActivities:nil];
    activityViewController.popoverPresentationController.sourceView = self.view;
    [self presentViewController:activityViewController animated:YES completion:nil];
}
1

There are 1 answers

2
Mehul On

@ozd,

if image Share then

see link : Share image/text through WhatsApp in an iOS app

& if Share Text

JBWhatsAppActivity Library: https://github.com/jberlana/JBWhatsAppActivity

using Below Code You can share Text , Link..etc, may be helpful to you.

 WhatsAppMessage *whatsappMsg = [[WhatsAppMessage alloc] initWithMessage:@"Hey , I would like you to experience this fabulous app which helps you to create , store and share your MOMENTS. You can add your voice message to every photo and moments too !!!\n\nDownload the app from https://play.google.com/store?hl=en" forABID:@""];

    NSArray *applicationActivities = @[[[JBWhatsAppActivity alloc] init]];
    NSArray *excludedActivities    = @[UIActivityTypePrint, UIActivityTypePostToWeibo, UIActivityTypeMessage];
    NSArray *activityItems         = @[@"Hey , I would like you to experience this fabulous app which helps you to create , store and share your MOMENTS. You can add your voice message to every photo and moments too !!!\n\nDownload the app from https://play.google.com/store?hl=en", whatsappMsg];

    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
    activityViewController.excludedActivityTypes = excludedActivities;

    [self presentViewController:activityViewController animated:YES completion:^{}];