Reputation: 95
I have gotten the "open in" feature to work in an app I am developing to open files. I am currently implementing the application:DidFinishLaunchingWithOptions:
and using the UIApplicationLaunchOptionsURLKey
to get the file URL from the options dictionary, but I'm not sure what to do when the application is already open.
Any help would be appreciated, thanks.
Upvotes: 2
Views: 219
Reputation: 15400
If the app was already open, then application:didFinishLaunchingWithOptions:
won't be called again. Only application:openURL:sourceApplication:annotation:
will be called.
Note that if the app wasn't open, application:didFinishLaunchingWithOptions:
will be called and then application:openURL:sourceApplication:annotation:
will be called (unless you returned NO in didFinishLaunchingWithOptions to signify that you cannot open the URL in question).
So the best place to actually process the "Open In" feature is inside openURL
. How exactly to do this depends on your app, but if user interaction is involved and if different view controllers need to behave differently, a good approach is to create and post a NSNotification inside openURL
to describe the "Open In" action, and have subscribers elsewhere in your app act accordingly.
Upvotes: 1