【问题标题】:Make a link that opens app if installed, open Google Play/Appstore if not installed, and open another link if desktop pc?如果已安装,则创建一个打开应用程序的链接,如果未安装,则打开 Google Play/Appstore,如果是台式机,则打开另一个链接?
【发布时间】:2017-02-18 20:40:12
【问题描述】:

我想在电子邮件中创建一个链接,该链接会打开我的应用(如果已安装该应用)。 如果未安装,我希望它根据人们使用的手机打开 google play 或 Appstore。 如果他们在台式电脑上/除 android 和 IOS 之外的任何其他设备上,它应该打开另一个正常的网络链接。

这怎么可能?

【问题讨论】:

  • 我建议你为 playstore 和 appstore 使用 2 个不同的按钮。所以你不需要摆弄外部网站来检测消费者所在的设备

标签: android ios hyperlink html-email


【解决方案1】:

首先检测用户代理,然后据此将用户导航到不同的位置。这是简单的 javascript 代码,您可以将其添加到您的站点中,然后在电子邮件中提供站点 url。希望这有帮助。

//Useragent detection from http://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system
        function getMobileOperatingSystem() {
          var userAgent = navigator.userAgent || navigator.vendor || window.opera;

              // Windows Phone must come first because its UA also contains "Android"
            if (/windows phone/i.test(userAgent)) {
                //Code here for windows phone.
            }

            if (/android/i.test(userAgent)) {
                window.location = 'https://play.google.com/store/apps/details?id=YOUR_APPLICTION_ID';
            }

            // iOS detection from: http://stackoverflow.com/a/9039885/177710
            if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
               //Code here for itunes. 
            }

           //Code to navigation for your website.
        }

在 Android 中打开应用程序需要在 android 中实现特定的 URI,然后您可以将用户重定向到该 URI 以打开您的应用程序。

【讨论】:

  • 问题是,它是针对 HTML 电子邮件的,所以 Javascript 可能是不可能的?
  • 创建一个包含该javascript的简单页面,使用html中的href将您的用户重定向到该页面。从那里你可以决定它是哪个用户代理。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 1970-01-01
  • 1970-01-01
  • 2015-12-29
  • 1970-01-01
  • 2014-10-16
相关资源
最近更新 更多