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

后端 未结 6 1949
你的背包
你的背包 2020-12-04 09:11

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

6条回答
  •  囚心锁ツ
    2020-12-04 09:27

    For solving this and avoid no wanted iOS safari alert I've used a different approach handle also an iframe but without jquery and listener events. It works perfectly.

        var iframe = document.createElement("iframe");
    
        iframe.style.border = "none";
        iframe.style.width = "1px";
        iframe.style.height = "1px";
        iframe.onload = function () {
            document.location = alt;
        };
        iframe.src = nativeSchemaUrl; //iOS app schema url
    
        window.onload = function(){
            document.body.appendChild(iframe);
        }
    
        setTimeout(function(){
            window.location = fallbackUrl; //fallback url
        },300);
    

提交回复
热议问题