3

In my app I've implemented a custom activity in the Share Sheet titled Open In, and tapping this icon will generate a .txt file and present a list of applications that are capable of opening and working with this generated .txt file. iOS automatically prepends "Open in" before each app's name in the share sheet.

But now that third-party developers have implemented share extensions, for some reason those are appearing in this Open In interface as well. For example, Twitter shows up but when I tap on it, the text in the .txt file does not appear in the compose window. Therefore, these third-party share extensions are entirely useless in this interface. Plus they were already presented in the original share sheet (and they work there) - the user tapped Open In so they only care to see apps that can open a .txt file.

How can I ensure only the Open In apps are offered in this custom activity?

    //make a txt file to write the data
    NSString *fileName = [NSString stringWithFormat:@"%@Text.txt", NSTemporaryDirectory()];
    [self.textToShare writeToFile:fileName
                       atomically:NO
                         encoding:NSUTF8StringEncoding
                            error:nil];

    NSURL *textFileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"Text.txt"]];

    self.openInController = [UIDocumentInteractionController interactionControllerWithURL:textFileURL];
    self.openInController.delegate = self;

    BOOL didPresentOpenIn = [self.openInController presentOpenInMenuFromBarButtonItem:self.buttonToPresentFrom animated:YES];
    if (!didPresentOpenIn) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Apps Available"
                                                        message:@"You do not have any apps installed that can open text files."
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];
    }

screenshot

Jordan H
  • 52,571
  • 37
  • 201
  • 351

0 Answers0