[英]Is it possible to browser deeplink to an app? (without popup)
I'm trying to deeplink into an app from the browser, that's working fine. 我正试图从浏览器深入链接到一个应用程序,这工作正常。 But the problem is, that iOS is showing a "Safari can't open the page" and then redirects to the app store (fallback solution).
但问题是,iOS正在显示“Safari无法打开页面”,然后重定向到应用商店(后备解决方案)。
Is it possible to make some JS magic, so that popup box doesn't appear? 是否有可能制作一些JS魔法,以便不出现弹出框?
Here is the code: 这是代码:
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";
I encountered a similar scenario some time back and I figured the best way to go about is have an iframe and provide a source to it.. 我在一段时间后遇到了类似的情况,我认为最好的办法是拥有一个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();
That way you would not see the error popup when the scheme cannot be found. 这样,当找不到方案时,您将看不到错误弹出窗口。
Update 更新
This approach will only work for IOS 8 and lower. 这种方法仅适用于IOS 8及更低版本。 From IOS 9 and later, deep linking is being supported natively using universal links.
从IOS 9及更高版本开始,使用通用链接本地支持深度链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.