从单一链接打开本地应用商店?

5
我正在使用PhoneGap为Android、iPhone和Windows Phone创建一款应用程序。我需要通过短信将一个公共URL发送到手机上,那么是否可以通过一个公共链接在手机上打开原生的应用商店呢?
比如说,如果有人使用iPhone,那么在点击该链接后,应用商店会显示该应用以供下载。
1个回答

4

您可以检测客户端使用的操作系统,然后加载相应的URL。正如Govind Singh Nagarkoti在这篇文章中所建议的那样(重定向到App Store或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>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接