iOS 检测网页上已安装的应用程序

iOS Detecting installed app on a webpage

当我在 iOS 的 Safari 浏览器中进入 YouTube 时,小部件让我打开已安装的应用程序

他们是怎么做到的?我尝试调试 window,但它可能隐藏在缩小的 js

附上部分截图:

这是 Apple's Smart App Banners 的一部分。

您可以通过添加以下元标记将其添加到您自己的网站上:

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

app-id 是 App Store URL 中 id?mt 之间的九位数字。 affiliate-dataapp-argument 是可选的。查看文档以获取更多信息。

第三方浏览器不支持它,例如 Chrome 不支持 iOS。在那种情况下,您将不得不自己做或使用像这样的脚本:

https://github.com/ijason/Smart-App-Banners
https://github.com/jasny/jquery.smartbanner
http://kurtzenisek.com/p/smart-web-banner/