URL scheme打开方式 html
根据第三方应用程序的类型,打开IOS系统应用的方式划分为两种URL Scheme分类 ios
IOS支持的URL Schemes分为如下几类<a href="mailto:frank@wwdcdemo.example.com">John Frank</a>本地应用中
if(![[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"mailto:frank@wwdcdemo.example.com"]] ){ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"没法打开程序" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles: nil] ; [alert show] ; }另外也能够经过to,cc,bcc,subject,body字段来指定邮件的抄送,密送,主题,消息内容。参数值都要通过URL编码处理。
mailto:foo@example.com?cc=bar@example.com&subject=Greetings%20from%20Cupertino!&body=Wish%20you%20were%20here!
<a href="tel:1-408-555-5555">1-408-555-5555</a>本地应用中
if(![[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tel:1-408-555-5555"]] ){ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"没法打开程序" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles: nil] ; [alert show] ; }
<meta name = "format-detection" content = "telephone=no">Text links(文本连接)
<a href="sms:">Launch Messages App</a> <a href="sms:1-408-555-1212">New SMS Message</a>本地应用中
if(![[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms:1-408-555-1212"]] ){ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"没法打开程序" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles: nil] ; [alert show] ; }iTunes links(iTunes连接)
<a href="https://itunes.apple.com/cn/app/numbers/id361304891?mt=8">Numbers</a>本地应用中
if(![[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/numbers/id361304891?mt=8"]] ){ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"没法打开程序" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles: nil] ; [alert show] ; }Map links(地图连接)
<a href="http://maps.apple.com/?q=cupertino">Cupertino</a>本地应用
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://maps.apple.com/?q=cupertino"]] ;正确的地图连接格式规则以下
<a href="http://www.youtube.com/watch?v=xNsGNlDb6xY">iPhone5</a> <a href="http://www.youtube.com/v/xNsGNlDb6xY">iPhone5</a>本地应用程序中
//或 http://www.youtube.com/v/xNsGNlDb6xY if(![[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=xNsGNlDb6xY"]] ){ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"没法打开程序" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles: nil] ; [alert show] ; }
注:描述于IOS6.0下,关于地图协议,在IOS5.X版本使用的地图为Google Map,详情参见IOS5.X对应的开发者文档。 git
参见:Apple URL Reference
代码: Demo github