Skip to content

Instantly share code, notes, and snippets.

@monjer
Last active September 20, 2021 17:29
Show Gist options
  • Save monjer/0f70df1e1a5067e8d754 to your computer and use it in GitHub Desktop.
Save monjer/0f70df1e1a5067e8d754 to your computer and use it in GitHub Desktop.
IOS Open URL
#define SharedApplication [UIApplication sharedApplication]
// open tel call
[SharedApplication openURL:[NSURL URLWithString:@"tel:1-408-555-5555"]];
// open itunes application
[SharedApplication openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/numbers/id361304891?mt=8"]];
// open map
[SharedApplication openURL:[NSURL URLWithString:@"http://maps.apple.com/?q=cupertino"]];
// open sms
[SharedApplication openURL:[NSURL URLWithString:@"sms:1-408-555-1212"]];
// open youtube
[SharedApplication openURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=xNsGNlDb6xY"]];
// open web page in safari
[SharedApplication openURL:[NSURL URLWithString:@"http://www.apple.com.cn"]];
// open mail client
[SharedApplication openURL:[NSURL URLWithString:@"mailto:hmj@gmail.com"]];
// open facetime client
[SharedApplication openURL:[NSURL URLWithString:@"facetime://user@example.com"]];
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="description" content="Safari3 on the desktop, on iPhone, or iPod touch">
<meta name="viewport" content="width=device-width, user-scalable=no" />
</head>
<body>
<h1>手机拨号</h1>
<ul>
<!-- 使用href标签和tel:链接来构建 -->
<li><a href="tel:408-555-5555">Home <span class="secondary">408-555-5555</span></a></li>
</ul>
<h2>在iPhone上点击链接会询问用户是否需要拨号,在iPod touch上会弹出错误提示框.</h2>
<h1>电子邮件</h1>
<ul>
<!-- 在iPhone上打开邮件页面并在将地址填充到收件人一栏中-->
<li><a href="mailto:frank@wwdcdemo.com">Address Only <span class="secondary">frank@wwdcdemo.com</span></a></li>
<!-- 在iPhone上打开邮件页面,填充收件人地址栏,主题,以及消息 -->
<li><a href="mailto:frank@wwdc.com?cc=tom@wwdc.com,lisa@wwdc.com&subject=Greetings from Santa Cruz!&body=Wish you were here!">Address Plus <span class="secondary">Frank, Tom, Lisa</span></a></li>
</ul>
<h2>点击邮件链接,在iPhone上会打开内置的mail组件 ,在iPod touch上会打开一个空白的Safari窗口。<em>cc:抄送地址</em><em>subject:邮件主题</em><em>body:邮件内容</em></h2>
<h1>Google地图</h1>
<ul>
<!-- This link points to Apple store locations in the San Francisco area on a map -->
<li><a href="http://maps.google.com/maps?q=apple+store+san+francisco">Query <span class="secondary">Apple Stores, San Francisco</span></a></li>
<!-- This link opens to the 1 Infinite Loop Cupertino, CA 95014 address on a map -->
<li><a href="http://maps.google.com/maps?q=1+Infinite+Loop,+Cupertino,+CA+95014">Address <span class="secondary">1 Infinite Loop Cupertino, CA 95014</span></a></li>
<!-- This link provides directions between two points, Santa Cruz and Cupertino on a map -->
<li><a href="http://maps.google.com/maps?daddr=Santa+Cruz,+CA&amp;saddr=1+infinite+loop,+cupertino,+ca">Directions <span class="secondary">From: 1 Infinite Loop Cupertino, CA To: Santa Cruz, CA</span></a>
</li>
</ul>
<h2>点击Google maps链接,iPhone上打开并连接到内置的Google maps客户端,iPod touch会链接至Google maps的站点</h2>
<!--Youtube links load the YouTube application and play the movie specified in a tapped URL -->
<h1>YouTube</h1>
<ul>
<!-- This link points to a Mac Ad on Youtube whose URL format is as follows: http://youtube.com/watch?v<video identifier>. The <video identifier> represents your YouTube video identifier. -->
<li><a href="http://youtube.com/watch?v=1EbCyibkNB0"><span class="secondary">/watch?v&lt;video identifier&gt;</span></a></li>
<!-- This link points to a Mac Ad on Youtube whose URL format is given as http://youtube.com/v/<video identifier>. The <video identifier> represents your YouTube video identifier. -->
<li><a href="http://youtube.com/v/pVPZHjPriWc"><span class="secondary">/v/&lt;video identifier&gt;</span></a></li>
</ul>
<h2>点击Youtube链接,iPhone上会打开内置的Youtube客户端,并播放指定的video.</h2>
<!--iTunes链接,连接用户到iTunes Music Store页面-->
<h1>iTunes</h1>
<ul>
<!-- 以下链接将打开 iTunes Music Store.-->
<li><a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/storeFront"><span class="secondary">http://&lt;iTunes store link&gt;/storeFront</span></a></li>
<!-- 以下链接将执行艺术家在iTunes Music store上的相册 -->
<li><a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?playlistId=114688"><span class="secondary"> http://&lt;iTunes store link&gt;/viewAlbum?playlistId=&lt;album identifier&gt;</span></a></li>
</ul>
<h2>iTunes链接,连接用户到iTunes Music Store页面-。</h2>
</body>
</html>