In my app I want to have two Different URL Schemes.
Like One and Two
So the user can open my app with:one://something
andtwo://something
I am using this:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
}
How will the app know if the user types one or two?
Register your URL schemeRegister your scheme in Xcode from the Info tab of your project settings. Update the URL Types section to declare all of the URL schemes your app supports, as shown in the following illustration. In the URL Schemes box, specify the prefix you use for your URLs.
Setting up URL Scheme In Xcode, under your project configuration, select your target and navigates to Info tab. You'll see an URL Types section at the bottom.
Deep linking consists of using a hyperlink that links to a specific piece of content within an app. The specific content could be a specific view, a particular section of a page, or a certain tab. To see an example, download the Twitter app. Log into it and close it.
handleOpenURL
is deprecated, so if you're targeting iOS 4.2 or later, you should instead use application:openURL:sourceApplication:annotation:
In both cases, you will be passed an NSURL
, on which you can just access the scheme
property to find out what scheme was used to access your app.
EDIT: For readability; in your implementation of application:openURL:sourceApplication:annotation:
, the code would be something similar to;
if([[url scheme] caseInsensitiveCompare:@"one"] == NSOrderedSame)
{
/* one here */
} else {
/* not one here */
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With