Alex Rivera | Logout

Lauching App with URL (via UIApplicationDelegate's handleOpenURL) working under iOS 4, but not under iOS 3.2

Asked 2010-08-31T19:24:26.280
11

I have implemented UIApplicationDelegate's

application:didFinishLaunchingWithOptions:

and

application:handleOpenURL:

according to specification, i.e.,

application:didFinishLaunchingWithOptions:
returns YES 

and

application:handleOpenURL: opens the URL. 

The code works under iOS 4 (in both cases, i.e., when the app is launched and when it becomes active from suspended state). However, the code does not work under iOS 3.2.

Edit
Report

1 Answer

33

I give an answer to my own question. Finding out the solution took me a while and was quite frustrating. If you do an internet search you find some partial answers, but it still took me a while to work out the following solution and I do hope it adds some clarity.

So first, the recommended behavior of your app appears to be the following (see Opening Supported File Types in iOS Ref Lib):

  • Do not implement applicationDidFinishLaunching: (see the note at UIApplicationDelegate).
  • Implement application:didFinishLaunchingWithOptions: and check the URL, return YES if you can open it, otherwise NO, but do not open it.
  • Implement application:handleOpenURL: and open the URL, return YES if successful, otherwise NO.

In iOS 4, passing an URL to an app results in one of the following two behaviors:

  • If the app is launched then application:didFinishLaunchingWithOptions: is called and application:handleOpenURL: is called if and application:didFinishLaunchingWithOptions: returned YES.
  • If the app is becoming active from suspended state then application:didFinishLaunchingWithOptions: is not called but application:handleOpenURL: is called.

However, in iOS 3.2 it appears as if application:handleOpenURL: is never called! A hint that the behavior is different under iOS 3.2 can be found in answered 2010-08-31T19:59:39.347

Your Answer