对于通过JavaScript的应用程序打开谷歌游戏详情页面Android浏览器重定向应用程序、重定向、浏览器、详情

2023-09-05 00:45:21 作者:全身的帅气

我希望我的网站重定向到在谷歌的特定应用程序中播放市场,如果它被打开在Android设备上。我也跟着在http://developer.android.com/guide/publishing/publishing.html:

 显示详细信息屏幕为特定应用程序:http://play.google.com/store/apps/details?id=<package_name>。
 

与链接的用户主动点击的伟大工程

 &LT; A HREF =htt​​p://play.google.com/store/apps/details?id=<package_name>&GT;下载应用程式&LT; / A&GT;
 

但是,如果我检测设备使用JavaScript和尝试自动重定向浏览器更改HTTP:// ...为https:// ...,用户被重定向到谷歌Play网站,而不是谷歌Play应用在手机上。

 如果(navigator.userAgent.toLowerCase()的indexOf(机器人)&GT; -1){
    如果(确认(下载的应用程序?)){
        window.location.href =htt​​p://play.google.com/store/apps/details?id=<package_name>;
    }
}
 
在Ubuntu 18.04等Linux系统中安装并运行Android应用程序

有没有办法来改变这种行为,我的测试设备是三星Galaxy采用Android 2.3.3?

解决方案

这似乎工作。重定向打开,而使用默认的浏览器谷歌Play应用,但转换链接到https:// play.google ...使用镶边时

 如果(navigator.userAgent.toLowerCase()的indexOf(机器人)&GT; -1){
    如果(确认(下载的应用程序?)){
        window.location.href =市场://细节ID =&LT;包名称&gt;中;
    }
}
 

I want my website to redirect to a specific app in the Google Play Market if it is opened on an android device. I followed the instructions on http://developer.android.com/guide/publishing/publishing.html:

"Display the details screen for a specific application: http://play.google.com/store/apps/details?id=<package_name>".

Works great with a link the user is actively clicking on:

<a href="http://play.google.com/store/apps/details?id=<package_name>">Download app</a>

But if I am detecting the device with javascript and trying to redirect the browser automatically changes the http://... to https://... and the user is redirected to the Google Play website instead of the Google Play app on the phone.

if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
    if(confirm("Download app?")) {
        window.location.href= "http://play.google.com/store/apps/details?id=<package_name>";
    }
}

Is there any way to change this behavior, my test device is a Samsung Galaxy with android 2.3.3?

解决方案

This seems to work. The redirect opens the Google Play app while using the default browser, but translates the link to https:// play.google... when using chrome

if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
    if(confirm("Download app?")) {
        window.location.href= "market://details?id=<packagename>";
    }
}