简体   繁体   中英

iOS 9.3.2 Custom URL Scheme not launching app from Safari

My web page detects the OS and browser, and in the case of iOS Safari will launch my app using a custom URL scheme.

It works fine on my test devices, but I'm seeing an issue with a user using Safari/9.0 on iOS/9.3.2 - the link simply does nothing!

Are custom URL schemes no longer supported? Do I need to start using universal links instead?

For those interested, here is the Javascript code I use in iOS browsers (which is working 99% of the time):

var timer;
var heartbeat;
var lastInterval;

window.addEventListener("pageshow", function(evt){
    clearTimers();
}, false);

window.addEventListener("pagehide", function(evt){
    clearTimers();
}, false);

function getTime() {
    return (new Date()).getTime();
}

// For all other browsers except Safari (which do not support pageshow and pagehide properly)
function intervalHeartbeat()
{
    var now = getTime();
    var diff = now - lastInterval - 200;
    lastInterval = now;
    if(diff > 1000)
    { // don't trigger on small stutters less than 1000ms
        clearTimers();
    }
}

function clearTimers()
{
    clearTimeout(timer);
    clearTimeout(heartbeat);
}

function intervalHeartbeat()
{
    if (document.webkitHidden || document.hidden)
    {
        clearTimers();
    }
}

function launch()
{
    lastInterval = getTime();
    heartbeat = setInterval(intervalHeartbeat, 200);
    timer = setTimeout(function ()
    {
        logErrorToMyServer();
    }, 2000);

    //Launch app via custom URL scheme
    window.location = "myapp://";
}

Custom URI schemes have been a not-good option since the introduction of iOS 9.2. Apple has definitely made it clear that Universal Links are the preferred approach to deep linking.

I'm not aware of any retroactive changes that would be causing Safari on 9.0 - 9.3.2 to do nothing in this situation (you should at least be getting an error pop-up), but this will continue to be unsupported for the foreseeable future and you should get Universal Links up and running as soon as possible. More details available in this blog post .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM