最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Open universal link from social network in-app browser - Stack Overflow

programmeradmin3浏览0评论

I have some universals links to open my app, something like /{id}, it opens the user profile on my app and works great.

At the moment I am working with firebase dynamics links, and it works, but the service will stop soon so I need to find an alternative.

My main issue are the links shared on social networks, for example Instagram, the page is opened in an in-app browser and my app is not opened

First I tried the following solution

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redirecting...</title>
    <script>
        function openApp() {
            var universalLink = ";; // Your actual Universal Link

            // Force the browser to open the Universal Link outside in-app browsers
            window.location.replace(universalLink);

            // Fallback: If Universal Link fails, show a button
            setTimeout(function() {
                document.getElementById("fallback").style.display = "block";
            }, 2000);
        }
    </script>
</head>
<body onload="openApp()">
    <h1>Redirecting...</h1>
    <p>If the app doesn't open, click the button below.</p>
    <a id="fallback" href="; style="display: none;">
        <button>Open in Browser</button>
    </a>
</body>
</html>

But none of the two alternatives works, the fallback is never called as the window.location.replace is always called, but the redirect is made into the same in-app browser same if I comment the window.location.replace, clicking on the button, the redirect is made in the same in-app browser.

Then I tried some target attributes in a tags, for example _blank or _system but the link is still opening in the same in-app browser.

Then I tried with browsers deep links as x-safari-, or Google Chrome but the links opens in the browser and not opening my app.

I do not know if I have to use a paying service as branch.io for something who could be that simple.

  1. if app installed, open app
  2. Open store if on android or iOS
  3. Open my website
发布评论

评论列表(0)

  1. 暂无评论