如果已安装,则重定向到应用程序,否则重定向到 App Store [英] Redirect to application if installed, otherwise to App Store

查看:46
本文介绍了如果已安装,则重定向到应用程序,否则重定向到 App Store的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以通过注册自定义方案(例如 so://)直接链接到 iOS 中的应用程序,也可以通过 iTunes 链接到应用程序商店中的应用程序.

I know it's possible to link directly to an app in iOS by registering a custom scheme (e.g. so://) and it's also possible to link to the app in the appstore via itunes.

在许多情况下,理想的流程是提供一个链接,该链接如果已安装,则重定向到应用程序,如果未安装,则重定向到商店.这可能吗,如果可以,怎么做?

In many cases, the ideal flow is to provide a link that redirects to the app if it's installed and to the store if not. Is this possible, and if so, how?

为清楚起见而添加,场景是我在我的 iphone 上打开一封电子邮件中的链接 (http),邀请我加入应用程序中的组.如果用户在该设备上安装了应用程序,它应该打开,否则 http 链接应该重定向到 iTunes.

Added for clarity, the scenario is I'm opening a link (http) from an e-mail on my iphone that's inviting me to join a group in an application. If the user has the app installed on that device it should open, otherwise the http link should redirect to itunes.

推荐答案

没有办法检查这个.但是,有一个很好的解决方法.

There is no way to check for this. However, there is a nice workaround.

这个想法基本上是这样的:

The idea is basically this:

  1. 第一次打开应用时,您会从应用内打开移动 safari,访问服务器上的预定义网址
  2. 您在该 URL 上设置了一个 cookie,例如 appInstalled to the users mobile safari
  3. 然后,您使用您注册的方案将用户踢回您的应用(与 FB 对 SSO 的做法相同)
  4. 您的所有电子邮件链接都指向您的网站,但在该网站上,您会检查浏览器是否为移动版 Safari 以及 appInstalled cookie 是否存在
  5. 如果浏览器不是移动版 Safari 或未找到 cookie,您将重定向到 AppStore,或留在您的网页中.
  6. 如果 #4 的条件为真,您将用户重定向到您的应用程序,并使用已注册的方案
  7. 如果应用已被用户删除,因此自定义 url 方案失败,则您可以安全地重定向到应用商店

在此 SO 帖子中对最后 2 个步骤进行了说明

这篇关于如果已安装,则重定向到应用程序,否则重定向到 App Store的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆