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).
Is it possible to make some JS magic, so that popup box doesn't appear?
Here is the code:
var now = new Date().valueOf();
setTimeout(function () {
if (new Date().valueOf() - now > 100) return;
window.location = "";
}, 10);
window.location = "twitter://timeline";
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).
Is it possible to make some JS magic, so that popup box doesn't appear?
Here is the code:
var now = new Date().valueOf();
setTimeout(function () {
if (new Date().valueOf() - now > 100) return;
window.location = "https://itunes.apple./us/app/twitter/id333903271?mt=8";
}, 10);
window.location = "twitter://timeline";
Share
Improve this question
edited Jul 22, 2015 at 20:25
Sushanth --
55.8k9 gold badges69 silver badges107 bronze badges
asked Jul 22, 2015 at 20:15
Simon ThomsenSimon Thomsen
1,4217 gold badges28 silver badges37 bronze badges
1 Answer
Reset to default 7I 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..
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./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. From IOS 9 and later, deep linking is being supported natively using universal links.