问题描述
在我的iPhone上,我注意到如果我使用Google搜索(在Mobile Safari中)并在quora.com上选择结果,结果页面会在我的手机上启动原生Quora应用。
On my iPhone, I just noticed that if I do a Google Search (in Mobile Safari) and select a result on quora.com, the result page launches the native Quora app on my phone.
这是怎么做到的?具体来说,它是用户代理的检测和iOS URL方案的使用吗?它能否判断本机应用是否已安装和/或重定向到应用商店?
How is this done? Specifically, is it a detection of the user agent and the use of an iOS URL scheme? Can it tell if the native app is installed and/or redirect to the app store?
推荐答案
我正在从这里找到我自己相关的答案(但最初是Ruby-on-Rails特定的) :
I'm reposting an answer to my own related (but was originally Ruby-on-Rails-specific) question from here: Rails: redirect_to 'myapp://' to call iOS app from mobile safari
您可以使用javascript重定向 window.location
。
You can redirect using javascript window.location
.
示例代码:
<html><head>
<script type="text/javascript">
var userAgent = window.navigator.userAgent;
if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
window.location = "myiosapp://"
}
</script>
</head>
<body>
Some html page
</body>
</html>
这篇关于如何从Mobile Safari重定向到Native iOS应用程序(如Quora)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!