iOS custom url scheme:
Example for html:
<p>Run the app<a href='BundleURLSchemes://BundleURLName?param=1'>iPhone/iPad</a></p>
CFBundleURLSchemes
- An array of strings containing the URL scheme names—for example, http, mailto, tel, and sms.
BundleURLName
- A string containing the abstract name of the URL scheme. To ensure uniqueness, it is recommended that you specify a reverse-DNS style of identifier, for example, com.acme.myscheme.
The string you specify is also used as a key in your app’s InfoPlist.strings file. The value of the key is the human-readable scheme name.
via Apple's documentation:
Implementing Custom URL Schemes
If your app can receive specially formatted URLs, you should register the corresponding URL schemes with the system. A customURL scheme is a mechanism through which third-party apps can communicate with each other. Apps often use custom URLschemes to vend services to other apps. For example, the Maps app supports URLs for displaying specific map locations.
Registering Custom URL Schemes
To register a URL type for your app, include the CFBundleURLTypes
key in your app’s Info.plist
file. The CFBundleURLTypes
key contains an array of dictionaries, each of which defines a URL scheme the app supports.
In your AppDelegate:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
NSString *query = [url query];
// NSLog(@"query->%@",query);//param=1
// NSLog(@"host->%@",host);//BundleURLName
// NSLog(@"resourceSpecifier->%@",resourceSpecifier);//BundleURLName?param=1
if(![[url scheme] isEqualToString:@"BundleURLSchemes"])
return NO;
else{
NSArray* paramsData =[query componentsSeparatedByString:@"="];
NSLog(@"param->%@", paramsData[1]);
}
return YES;
}