Sim*_*sen 3 javascript browser deep-linking ios
我正试图从浏览器深入链接到一个应用程序,这工作正常.但问题是,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";
Run Code Online (Sandbox Code Playgroud)
我在一段时间后遇到了类似的情况,我认为最好的办法是拥有一个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();
Run Code Online (Sandbox Code Playgroud)
这样,当找不到方案时,您将看不到错误弹出窗口.
更新
这种方法仅适用于IOS 8及更低版本.从IOS 9及更高版本开始,使用通用链接本地支持深度链接.
| 归档时间: |
|
| 查看次数: |
1428 次 |
| 最近记录: |