UIDocumentInteractionController is disabled in some applications

I am currently using the UIDocumentInteractionController for public functions. When it opens, a list of all applications on the device that can process this type of file is displayed.

Is there a way to disable my application sending a document to certain applications, even if they support this type of file? For example, if I have a PDF file open in my application and iBooks is on the iPad, if I touch the iBooks icon in the UIDocumentInteractionController, I don’t want it to send it to the application.

Ideally, I see this as creating a black list (or white list). For example, it would be great to do this:

- (void) documentInteractionController: (UIDocumentInteractionController *) controller willBeginSendingToApplication: (NSString *) application { // if app is blacklisted if ([application isEqualToString:@"com.schimera.WebDAVNavigator"]) { [self.interactionController dismissMenuAnimated:YES]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"FAIL" message:@"NO" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; return } } 

However, the document is still sent to the application, even if it is black.

Is such an approach possible?

Hooray!

+4
source share
2 answers

Change the UIDocumentInteractionController URL to an invalid value if the application is blacklisted. In the method -[UIDocumentInteractionControllerDelegate documentInteractionController: willBeginSendingToApplication:] .

 -(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application { if([application isEqualToString:@"com.evilcorp.badapp"){ controller.URL = nil; } } 
+2
source

To open a file in a specific application (as a white list), simply add (using swift 3.0):

 docController.uti = @"com.yourapp.package"; 
0
source

All Articles