Html 如何从网站上的链接打开原生 iOS 应用程序(日历、笔记...)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7658685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open native iOS app (calendar, notes...) from a link on website?
提问by nqw1
Is it possible to open native iOS app, e.g. calendar or notes, from an HTML link which is in website? I tried to find an example but I couldn't. I ran into these URL schemes but I don't know how to use them and what's the URL scheme for calendar or notes. Is it possible just to do something like this:
是否可以从网站中的 HTML 链接打开本机 iOS 应用程序,例如日历或笔记?我试图找到一个例子,但我不能。我遇到了这些 URL 方案,但我不知道如何使用它们以及日历或笔记的 URL 方案是什么。是否有可能只是做这样的事情:
<a href="calendar://something here?">Click me!</a>
Is it possible to do it only with HTML or is JavaScript needed?
是否可以仅使用 HTML 或是否需要 JavaScript?
回答by Cro
If you're looking for the URL Schema, iPhone Calendar is: CALSHOW:
如果您正在寻找 URL 架构,iPhone 日历是:CALSHOW:
回答by Dip Dhingani
Yes you can very well possible to do that. You're right in placing the link like this:
是的,你很可能做到这一点。您正确放置这样的链接:
<a href="calendar://">Click me!</a>
<a href="calendar://">Click me!</a>
Now go to your iOS app's info.plist file. In that add the following tags:
现在转到您的 iOS 应用程序的 info.plist 文件。在其中添加以下标签:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.companyname.appname</string>
<key>CFBundleURLSchemes</key>
<array>
<string>calendar</string>
</array>
</dict>
</array>
Save the plist file and exit it. After this when you open the web page in Safari browser of your iOS device and click on the link, your iOS app will invoke. I hope it helps!
保存 plist 文件并退出。此后,当您在 iOS 设备的 Safari 浏览器中打开网页并单击链接时,您的 iOS 应用程序将调用。我希望它有帮助!
回答by Andrew
Calendar and Notes do not have URL schemes. Apple provides a reference for those of their apps that do use URL schemes here:
日历和便笺没有 URL 方案。Apple 在此处为使用 URL 方案的应用程序提供了参考: