I've been looking for a way to open a native iOS app from the browser. I found a decent solution here: Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?
This solution works great when you have the app installed. but when a user doesn't have this app installed - safari fires an error message which says "Safari cannot open the page because the address is invalid."
Is there a way to prevent this behaviour and instead to prompt the user to download the app?
Turn on Restrictions from Settings > General > Restrictions and set a passcode. Scroll down, go to Apps and tap Don't Allow Apps. This will hide all apps you've installed, including LinkedIn. Switch to or open Mobile Safari, use the links and stay within Mobile Safari.
Here is a solution that works for me:
var timeout; function preventPopup() { clearTimeout(timeout); timeout = null; window.removeEventListener('pagehide', preventPopup); } function openApp() { $('<iframe />') .attr('src', appurl) .attr('style', 'display:none;') .appendTo('body'); timeout = setTimeout(function() { document.location = appstore; }, 500); window.addEventListener('pagehide', preventPopup); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With