application:openURL:sourceApplication:annotation return NO versus YES
I am registering an application to handle being opened via URL and am confused wit开发者_如何学运维h
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?
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
精彩评论