Javascript 是否可以链接到应用程序?(无弹出窗口)
我正在尝试从浏览器深度链接到一个应用程序,这很好。 但问题是,iOS显示“Safari无法打开页面”,然后重定向到应用商店(后备解决方案) 有没有可能使一些JS变魔术,这样弹出框就不会出现 代码如下:Javascript 是否可以链接到应用程序?(无弹出窗口),javascript,ios,browser,deep-linking,Javascript,Ios,Browser,Deep Linking,我正在尝试从浏览器深度链接到一个应用程序,这很好。 但问题是,iOS显示“Safari无法打开页面”,然后重定向到应用商店(后备解决方案) 有没有可能使一些JS变魔术,这样弹出框就不会出现 代码如下: var now = new Date().valueOf(); setTimeout(function () { if (new Date().valueOf() - now > 100) return; window.location = "
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及更高版本中,使用通用链接本机支持深度链接。@simontomsen。。很高兴能帮忙:)