0

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];
}
ozd
  • 1,194
  • 10
  • 34

1 Answers1

0

@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:^{}];
Community
  • 1
  • 1
Mehul
  • 3,033
  • 23
  • 37
  • I see its only text... my problem is that there is only message with text OR message with image. i need to have them both – ozd Jun 18 '15 at 06:22
  • @ozd, can you check above link, i have given to you ? , is that not helpfull !! – Mehul Jun 18 '15 at 06:24