简体   繁体   English

iOS 9.3.2自定义URL方案未从Safari启动应用

[英]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. 我的网页检测到操作系统和浏览器,对于iOS,Safari会使用自定义URL方案启动我的应用程序。

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! 它可以在我的测试设备上正常运行,但是我看到用户在iOS / 9.3.2上使用Safari / 9.0时遇到了问题-该链接什么都不做!

Are custom URL schemes no longer supported? 不再支持自定义URL方案吗? 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): 对于那些感兴趣的人,以下是我在iOS浏览器中使用的Javascript代码(99%的时间都在工作):

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. 自iOS 9.2引入以来,自定义URI方案一直不是一个好的选择。 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. 我不知道任何追溯性更改会导致9.0-9.3.2上的Safari在这种情况下不执行任何操作 (至少应该出现错误弹出窗口),但是在可预见的情况下将继续不支持此操作。未来,您应该尽快启动并运行通用链接。 More details available in this blog post . 有关更多详细信息, 请参见此博客文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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