iosaudioshareuidocumentinteractionsocialshare

Automatic selection of the destination App in UIDocumentINteractionController without presenting the available Apps


I am developing and App for sharing an audio file with Whatsapp. Since, I am only focused on Whatsapp, I am not interested on showing other available apps such as VLC or Telegram.

Can I select Whatsapp App to share the file without presenting the menu for choosing? In other words, can I avoid presentOpenInMenuFromRect:inView:anmiated:?


Solution

  • You need to use UIDocumentInteractionController UTI: net.whatsapp.audio

    Custom URL scheme for whatsApp

      _documentController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    _documentController.delegate = self;
    _documentController.UTI = @"net.whatsapp.audio";
    [_documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]
    

    When triggered, WhatsApp will immediately present the user with the contact/group picker screen. The media will be automatically sent to a selected contact/group.