15

Reading the documentation for UIApplicationDelegate - application:openURL:options

Return:

YES if the delegate successfully handled the request or NO if the attempt to open the URL resource failed.

What does returning YES vs NO impact? Is it just a convenience if you happen to be sub-classing your app delegate and might want to let super handle the invocation? The return value doesn't seem to affect the behavior of UIApplication itself in any obvoius way.

Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
  • Are you saying that returning NO will also open the app? – hasan Mar 02 '17 at 23:11
  • Yes, returning NO also opens the app – Raunak Nov 22 '18 at 06:46
  • My theory was that the return value is sent back to the calling app. So I tested: app A launches app B. B returns `NO` from `application:openURL:options:`. In `openURL:options:completionHandler:`, app A still receives a `success=YES`. So the return value of the launched app is not sent back to the calling app. Theory invalidated. – Ortwin Gentz Oct 22 '20 at 09:02

1 Answers1

1

application:openURL:options should be implemented if the app opens deep links including waiting for a callback from another app as facebook login.

The URL/URI parameter value should contains the needed information to let you figure out to which view controller the app should be re-directed to.

One example with facebook callback there is facebookSDK method that can be called and it will handle the URI parsing for you.

If you decide to open the app you should return YES/true, and then proceed with re-directing. Otherwise, return NO/false.

If app accepts info. from 3rd party apps. This method allow you to check the validity of this info. and regardingly accept the request or reject it.

hasan
  • 23,815
  • 10
  • 63
  • 101
  • 1
    Ok, but still unclear what difference returning YES or NO actually makes. – Ben Flynn Mar 02 '17 at 23:27
  • are you saying that even if NO is returned app opens anyway? – hasan Mar 02 '17 at 23:29
  • 3
    That's what I'm seeing on iOS 10... I call openURL: from app A, and app B returns NO in openURL:options but it is still opened. – Ben Flynn Mar 02 '17 at 23:40
  • @BenFlynn I'm seeing the same thing in iOS 13, so the return value is for no use? – laucel Sep 09 '20 at 06:45
  • 1
    https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application#return_value read the discussion it may help – hasan Sep 09 '20 at 06:50
  • @hsan "true if the delegate successfully handled the request or false if the attempt to open the URL resource failed." it's not specified the effect – laucel Sep 09 '20 at 08:33
  • "If only one of the two methods is implemented, its return value determines whether this method is called." got it – laucel Sep 09 '20 at 20:28
  • 2
    This doesn't answer the question. Question is in what way the return value affects the system. – Ortwin Gentz Oct 22 '20 at 08:41