首页 > 解决方案 > 从重定向而不是链接打开 android 应用程序

问题描述

我在尝试深层链接和打开我的应用时遇到问题。我有以下代码,可以让我确定我是否有 ios 用户或 android。如果它是 android,那么我想重定向用户以打开他们的应用程序(如果已安装)。

问题是重定向到company://open.me/没有打开应用程序

如果我创建一个手动链接,例如

<a href="company://open.me/">Open Me</a>

这工作正常并打开我的应用程序。

有什么帮助吗?

<script>
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    location.replace("company://");
    setTimeout(function() {
        if (!document.webkitHidden) {
            location.replace("https://www.company.com");
        }
    }, 25);
} else if ((navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/Android/i))) {
    window.location = "company://open.me/";
} else {
    location.replace("https://www.company.com");
}
</script>

显现

<intent-filter>
    <data android:scheme="company" android:host="open.me" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

标签: androidandroid-studio

解决方案



推荐阅读