优步 API 深度 Link Android

Uber API Deep Link Android

用于嵌入上下车地点的 Deep link 在 iOS 上运行,但在 Android 上测试时它们不起作用。在 Android 上,深度 link 不是嵌入上车和下车地点,而是简单地打开 Uber 应用程序。我认为我的 Javascript 可能有问题,因为我认为逻辑和实际深度 link 工作正常。

如有任何帮助,我们将不胜感激。

<!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;
}