1

I'm using the following code to share an image via WhatsApp

-(void)shareImageUsingDocumentController:(UIImage *)image fileName:(NSString *)fileName UTI:(NSString *)UTI completion:(void (^)(SharingResult sharingResult))completion
{
    if (completion)
    {
        self.shareCompleted = completion;
    }

    self.documentInteractionController = nil;
    self.documentInteractionController = [[UIDocumentInteractionController alloc] init];
    NSURL *localUrl = [self writeLocalFileFromUIImage:image fileName:fileName];
    if (localUrl != nil) {
        self.documentInteractionController.URL = localUrl;
        self.documentInteractionController.UTI = UTI;
        self.documentInteractionController.delegate = self;

        [self presentDocumentIneractionController];
    }
}

-(UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
    return self.presentingViewController;
}

This is from the BDSshare library and I'm using it from a Swift app. I'm calling the function with this code.

img: UIImage = self.loadImage()
BDGShare.shared().shareImage(usingDocumentController: img, fileName: "whatsAppTmp.wai", uti: "net.whatsapp.image") {(SharingResult) -> Void in
    // Handle share result...
    self.handleShareResult(shareTarget.type, shareResult: SharingResult)
}

The problem I'm having is that I see two icons for WhatsApp in the controller. enter image description here

Can anyone see why there would be two WhatsApp icons here? I've been searching all over and I can't find any posts that do this differently than I am. I can't find any one mentioning the issue of having multiple WhatsApp icons either. If I use the first icon (labeled 'WhatsApp') then it doesn't actually work. I select a contact and hit send and I get a screen with the filename in it. Using the second button (labeled 'Copy to WhatsApp') I select a contact and I see the image on black screen with a text entry for caption.

I'd much rather skip the selector and go straight to WhatsApp but I'd settle for only one button (naturally the one that works ;))

TIA Mike

Mike
  • 788
  • 10
  • 27

2 Answers2

0

Turns out that I forgot about WhatsApp being one of the services supported by default. So what I was seeing was the default item and the one that I added by calling the UIDocumentInteractionController with the UTI for WhatsApp. So I switched to shareImageUsingActivityController from the same BDGShare lib and it's all good.

Mike

Mike
  • 788
  • 10
  • 27
0

I think there is a problem with Whatsapp, I had the same problem, but in my case you couldn't see the image preview when you share the image of type .wai, it shows a text "whatsapp image exclusive". My Solution is this combination:

UTI = @"net.whatsapp.image";

nameOfTemporalFile = @"WhatsAppimage.jpeg"; 

instead of

nameOfTemporalFile = @"WhatsAppimage.wai";