问题
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?
回答1:
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 */
}
来源:https://stackoverflow.com/questions/14538472/xcode-multiple-url-schemes