简体   繁体   English

检查是否从网页安装了应用

[英]Check if app is installed from webpage

I have an iOS and Android app and I'm building a corresponding website. 我有一个iOS和Android应用程序,我正在建立一个相应的网站。 I would like that the webpage, if opened using a mobile device, opens the app or its corresponding app store page (without using Facebook app links). 我希望该网页,如果使用移动设备打开,打开应用程序或其相应的应用程序商店页面(不使用Facebook应用程序链接)。 On the app side everything is working, including the url schema. 在应用程序方面,一切正常,包括url架构。

Does someone know how to implement this procedure, without external services, using HTML and JS? 有人知道如何在没有外部服务的情况下使用HTML和JS实现此过程吗?

Thanks in advance for your help. 在此先感谢您的帮助。

To be honest, this is kind of a pain to implement on your own. 说实话,这是你自己实施的一种痛苦。 There is no easy way to handle everything without a ton of nasty edge cases, most notably the 'Cannot Open Page" error users will see if they don't have your app installed. Until iOS 9, a reasonable basic implementation was putting a JavaScript redirect like this into a dedicated redirect page on your site: 如果没有大量令人讨厌的边缘情况,没有简单的方法来处理所有事情,最明显的是,如果他们没有安装你的应用程序,用户会看到“无法打开页面”错误。 在iOS 9之前,合理的基本实现是放置JavaScript像这样重定向到您网站上的专用重定向页面:

setTimeout(function() {
  window.location = "https://yourdomain.com";
}, 25);

// If "yourapp://" is registered, the user will see a dialog
// asking if they want to open your app. If they agree, your
// app will launch immediately and the timer won't fire.
// If not installed, you'll get an ugly "Cannot Open Page" 
// dialogue and your fallback page will open when the timer expires.

window.location = "yourapp://";

Unfortunately this would still show a 'Cannot Open Page' error, but until recently it was possible to get around this in a reasonably user-friendly way by using a more nuanced version of this script. 不幸的是,这仍然会显示“无法打开页面”错误,但直到最近才有可能通过使用此脚本的更细微版本以合理的用户友好方式解决此问题。 Sadly, Apple intentionally broke that with the iOS 9.2 update , so custom URL schemes are actually pretty much useless for deep linking now, unless you are certain the app is already installed on that device. 可悲的是, Apple故意用iOS 9.2更新破坏了它 ,所以自定义URL方案现在对于深度链接实际上几乎没用,除非您确定该应用程序已经安装在该设备上。

Apple is obviously trying to push the newer Universal Links standard as much as possible. Apple显然试图尽可能地推出更新的Universal Links标准。 Universal Links lets you use a normal http:// URL to a page on your website (the page could be a simple redirection to your desired fallback webpage without the custom URL trigger that causes the 'Cannot Open Page' error), which is intercepted by your phone and sent directly into your app if installed. 通用链接允许您使用正常的http:// URL到您网站上的页面(该页面可以是一个简单的重定向到您想要的后备网页,而不会导致“无法打开页面”错误的自定义URL触发器被拦截)如果已安装,请通过手机直接发送到您的应用中。

This is quite a lot to handle, so the best option might be a free service like Branch.io (full disclosure: I work with the team) to take care of all the technical aspects. 这是非常需要处理的,所以最好的选择可能是免费服务,如Branch.io (完全披露:我与团队合作)来处理所有技术方面。 You can find examples of apps using the Branch service here . 您可以在此处找到使用分支服务的应用示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM