1

I got how to open attachments in your app from the Mail app here.

But how do I handle this in an iOS4 app? When my app is in the background and I open a file from Mail, -application:didFinishLaunchingWithOptions: does not fire. -applicationDidBecomeActive does, but it does not seem to have a way to retrieve the link to the file from there.

Anyone encountered this before? Any additional pointers on pitfalls I have yet to encounter will be very helpful too. Thanks in advance!

Community
  • 1
  • 1
Altealice
  • 3,572
  • 3
  • 21
  • 41

1 Answers1

1

This should work:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {

    if ([url isFileURL])
    {

        NSLog(@"file at path %@", [url path ]);
                // do something with your file
                return YES;
        }
        return NO;
}
halfer
  • 19,824
  • 17
  • 99
  • 186
henklein
  • 777
  • 6
  • 8
  • 1
    Thanks for this answer. For iOS 4.2, `application:handleOpenURL:` seem to be deprecated in favor of `application:openURL:sourceApplication:annotation:`, but I guess I still need to implement it to support iOS 3.2. – Altealice Dec 17 '10 at 09:14