Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

application:openURL:sourceApplication:annotation return NO versus YES

I am registering an application to handle being opened via URL and am confused with

application:openURL:sourceApplication:annotation

According to the documentation you should return YES if you can support the URL and NO if not. What good does this do though? I am returning NO in the event that the URL is malformed or unsupported but the app still opens as if nothing went wrong. Who listens for that BOOL return and what do they do with it? Is there anyway to prevent the app from opening if the URL is is malformed or not supported?

like image 850
Chris Wagner Avatar asked Sep 13 '11 21:09

Chris Wagner


1 Answers

The documentation says that you return YES if you successfully opened the URI and NO if you didn't. Note that "did succeed or did fail to open" is semantically different from "can or cannot open". Unfortunately, there's no way to prevent the app from launching - if it registers a schema then it will be launched regardless of whether the rest of the URI is correctly formatted.

UIApplication has two methods: canOpenURL: and openURL:. First one ONLY checks whether the schema is supported (not the full URL), where's the latter launches the app and returns the result of the application delegate.

So to answer your question: the other app who calls [[UIApplication sharedApplication] openURL:url] is the one who listens to your delegate's result

like image 156
Nick Avatar answered Sep 27 '22 00:09

Nick