[英]Is it possible to browser deeplink to an app? (without popup)
我正试图从浏览器深入链接到一个应用程序,这工作正常。 但问题是,iOS正在显示“Safari无法打开页面”,然后重定向到应用商店(后备解决方案)。
是否有可能制作一些JS魔法,以便不出现弹出框?
这是代码:
var now = new Date().valueOf();
setTimeout(function () {
if (new Date().valueOf() - now > 100) return;
window.location = "https://itunes.apple.com/us/app/twitter/id333903271?mt=8";
}, 10);
window.location = "twitter://timeline";
我在一段时间后遇到了类似的情况,我认为最好的办法是拥有一个iframe并为它提供一个来源。
function mobileDeepLink() {
var iframe = document.createElement('iframe');
iframe.src = "twitter://timeline";
// hide iframe visually
iframe.width = 0;
iframe.height = 0;
iframe.frameBorder = 0;
var now = new Date().valueOf();
setTimeout(function () {
if (new Date().valueOf() - now > 100) return;
window.location = "https://itunes.apple.com/us/app/twitter/id333903271?mt=8";
}, 10);
// Append it to the body.
document.body.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
}
mobileDeepLink();
这样,当找不到方案时,您将看不到错误弹出窗口。
更新
这种方法仅适用于IOS 8及更低版本。 从IOS 9及更高版本开始,使用通用链接本地支持深度链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.