我一直在努力解决这种重定向问题。我能够让移动重定向的脚本工作。该脚本将识别移动设备并基于该重定向到存储或应用程序(如果已安装)。
现在我需要更先进的东西。我需要将用户重定向到特定的InApp URL(类似于appname // mylink /#id123)
所以,假设用户试图在桌面上打开以下链接:
www.mysite.com/mylink#id123 那会是 应用程序名称// myLink的/#ID123
如果未安装应用程序,则存储。我需要能够定义不同的案例。
有人在网上看到类似的东西吗?我无法弄明白,下面是我用于基本重定向的脚本。
<script>
/*$(document).ready(function () {
console.log('Redirect to APP');
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Windows Phone must come first because its UA also contains "Android"
if (/windows phone/i.test(userAgent)) {
//return "Windows Phone";
console.log('Windows Phone');
}
if (/android/i.test(userAgent)) {
//return "Android";
console.log('Android');
var now = new Date().valueOf();
setTimeout(function () {
if (new Date().valueOf() - now > 100) return;
window.location = "https://play.google.com/store/apps/";
}, 25);
window.location = "appname://";
}
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
//return "iOS";
console.log('iOS');
var now = new Date().valueOf();
setTimeout(function () {
if (new Date().valueOf() - now > 100) return;
window.location = "https://itunes.apple.com/appdir";
}, 25);
window.location = "appname://";
}
});*/
</script>