how to prevent iOS safari alert when trying to open non-installed native app?

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);
} 

Leave a Comment