Corey1986
Corey1986

Reputation: 73

Objective-C: enable "Open in..." on special condition

I have a doubt, is it possible to enable the "Open in" only for a particular condition? Let me explain... I am creating an application that will allow only some users to open in my application some files.

For a particular user, I want that tapping an item in mail app will be shown the popover "Open in MyApplication".

For the other ones, i don't want to show the pop up.

Is it possible?

I know that i can manage the situation directly on the application when retrieving the URL of the request, but i'd like to have the behaviour described above.

Upvotes: 0

Views: 123

Answers (2)

keji
keji

Reputation: 5990

You could always just prevent the opened file from being displayed in your app through:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {    
     if (url != nil && [url isFileURL]) {
          if([self wantedUser])
               [self openURL:url];
          else
               return FALSE;
     }    

     return YES;
}

Upvotes: 2

rmaddy
rmaddy

Reputation: 318894

No, this is not possible. Your app either declares that it can handle files of a certain type or it doesn't. The standard "Open In" menu is based on what your app declares in the Info.plist. There is no way to make this conditional.

Upvotes: 1

Related Questions