1

I want to share an image via whatsapp. I'm using UIDocumentInteractionController with the following code. Can I skip the menu that is opened (and the user selects whatsapp) and just act as if he selected the first option?

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

                _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
                _documentInteractionController.UTI = @"net.whatsapp.image";
                _documentInteractionController.delegate = self;

                [_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated: YES];


            }
Boaz
  • 4,864
  • 12
  • 50
  • 90

1 Answers1

0

WhatsApp was updated with iOS 8 SDK with ShareKit extension. So now sharing to WhatsApp is 'default' in UIActivityController and there is no need to implement UIDocumentInteractionController to share the image.

Dennis Pashkov
  • 934
  • 10
  • 24