从单个链接打开本机应用程序商店?

Tus*_*mar 5 javascript iphone android cordova

我正在使用 PhoneGap 创建一个适用于 Android、iPhone 和 Windows Phone 的应用程序。我必须通过短信发送手机中的通用网址,那么是否可以通过通用链接打开手机中的本机应用商店?

就像如果有人有 iPhone,那么点击该链接后,应用程序商店将显示要下载的应用程序。

Pay*_*Pwn 4

您可以检测客户端正在使用哪个操作系统,然后继续加载相应的 URL。正如 Govind Singh Nagarkoti 在这篇文章中建议的那样(重定向到 appstore 或 google play),您可以执行以下操作:

<script>
     $(document).ready(function (){
         if(navigator.userAgent.toLowerCase().indexOf("android") > -1){
             window.location.href = 'http://play.google.com/store/apps/details?id=PACKAGEURL';
     }
         if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
             window.location.href = 'http://itunes.apple.com/lb/app/PACKAGEURL';
     }
    });
</script>
Run Code Online (Sandbox Code Playgroud)