iPhone SDK File Handler with iOS 4 Background Processes

Posted by David Higgins on Stack Overflow See other posts from Stack Overflow or by David Higgins
Published on 2011-01-16T20:52:43Z Indexed on 2011/01/16 22:53 UTC
Read the original article Hit count: 141

Filed under:
|

The "application:applicationDidFinishLaunchingWithOptions:" message does not get called when an application is sitting in the background in iOS 4, and I'm trying to figure out how to be notified when the application is brought back into the foreground by another application.

My application registers itself as a handler for certain file types, and Safari and other supported applications allow passing the files over to my app. This works great if the app is closed before I try to use it, but fails otherwise.

In my application:applicationDidFinishLaunchingWithOptions: I have:

NSURL *url = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
if([url isFileURL]) {
}
[self.window makeKeyAndVisible];
return YES;

As stated already, this works great so far for starting the app when it's not sitting in the background - but when I switch back over to Safari or Mail and try to open a new file that is supported, my application wakes up from the background and becomes active again but I can't see any "withOptions" overrides for application:applicationWillEnterForeground: or any way to identify what was passed in when it enters the foreground.

What would be the appropriate way to receive these "open file notifications" when the application is in the background?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone-sdk-4.0