javascript - Uber API 深度链接 Android

标签 javascript html uber-api

嵌入上车和下车地点的深层链接在 iOS 上有效,但在 Android 上测试时却不起作用。在 Android 上,深层链接只是打开 Uber 应用程序,而不是嵌入上车和下车地点。我认为我的 Javascript 可能有问题,因为我认为逻辑和实际的深层链接工作正常。

任何帮助将不胜感激。

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Emails</title>
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
    <script type="text/javascript">
      $(function() {

        // Parse the user agent to determine the device
        var isiPad = navigator.userAgent.match(/iPad/i) != null,
            isiPhone = !isiPad && ((navigator.userAgent.match(/iPhone/i) != null) || (navigator.userAgent.match(/iPod/i) != null)),
            isiOS = isiPad || isiPhone,
            isAndroid = !isiOS && navigator.userAgent.match(/android/i) != null,
            isMobile = isiOS || isAndroid,
            isDesktop = !isMobile;

        // Define all the potential redirection Urls
        var deepLink = 'uber://?action=setPickup&pickup=my_location&dropoff%5Blatitude%5D=33.784685&dropoff%5Blongitude%5D=-84.4121&dropoff%5Bnickname%5D=Apartment%20of%20Paul%20Jump&dropoff%5Bformatted_address%5D=1100%20Howell%20Mill%20RD%2C%20Atlanta%2C%20GA%2030318',
            appStoreUrl = 'https://itunes.apple.com/us/app/uber/id368677368',
            androidIntentUrl = 'intent://uber/#Intent;package=com.ubercab;scheme=uber;end',
            muberDotCom = 'http://m.uber.com';

        // Handle each case with a seamless fallback to the application store on mobile devices
        if (isiOS) {
          window.location = deepLink;
          setTimeout(function() { window.location = appStoreUrl; }, 25);
        } else if (isAndroid) {
          window.location = androidIntentUrl;
        } else if (isDesktop) {
          window.location = muberDotCom;
        }

      });
    </script>
  </head>
  <body>
  </body>
</html>

最佳答案

这是因为你还没有定义你想要的变量,这个URI中的上车和下车地点在哪里:

androidIntentUrl = 'intent://uber/#Intent;package=com.ubercab;scheme=uber;end',

isAndroidtrue 时,只需使用 deepLink,例如:

if (isiOS) {
      window.location = deepLink;
      setTimeout(function() { window.location = appStoreUrl; }, 25);
} else if (isAndroid) {
      window.location = deepLink;
      setTimeout(function() { window.location = 'https://play.google.com/store/apps/details?id=com.ubercab&hl=en_GB'; }, 25);
} else if (isDesktop) {
      window.location = muberDotCom;
}

关于javascript - Uber API 深度链接 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30508132/

相关文章:

javascript - 制作类似确认的功能

javascript - 如何对已更改的包运行单元测试

javascript - 为什么我应该使用 uber 的 fusion.js 而不是 create-react-app?

java - Uber/v1/payment-methods - 给出错误 "Unauthorized"且可用范围为空

javascript - JavaScript 构造函数和 Scala 构造函数有何不同?

javascript - 浏览器原生 JSON 支持 (window.JSON)

html - 如何解析和规范化来自不同 HTML 生成器的 HTML?

ios - 如何在 iOS UBER API 中设置我 future 的行程?

javascript - 来自远程服务器的脚本加载缓慢

javascript - 多个具有粘性位置的 div 相互重叠