0

我的 applink/deeplink 已经有一个意图过滤器。示例代码:

<activity android:name="com.XXXX.XXXX.XXXXXXXXXXXXActivity"
            android:enabled="true"
            android:excludeFromRecents="true"
            android:noHistory="true"
            android:theme="@android:style/Theme.Translucent"
            android:launchMode="singleInstance">
            <intent-filter android:autoVerify="true">
                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:host="www.xxxxxx.com" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
</activity>

由于我们没有任何路径或 pathPattern,因此此意图过滤器不会进行任何从 Web 浏览器到应用程序的链接重定向。我们只是那样做我们的行为。但是对于一个新的 saml 登录用例,我们必须在 Web 浏览器中打开 saml 登录页面(而不是在应用程序 webview 中),并在登录后重定向回应用程序。所以我们现在要使用 pathPattern。现在问题开始了。我们有相同的方案和主机。因此,如果我在具有相同方案的相同活动下创建一个新的意图过滤器,并使用 pathPattern 浏览器托管所有 url 重定向到我根本不想要的应用程序。示例代码:

<activity android:name="com.XXXX.XXXX.XXXXXXXXXXXXActivity"
            android:enabled="true"
            android:excludeFromRecents="true"
            android:noHistory="true"
            android:theme="@android:style/Theme.Translucent"
            android:launchMode="singleInstance">
            <intent-filter android:autoVerify="true">
                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:host="www.xxxxxx.com" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:host="www.xxxxxx.com" />

                <data android:pathPattern="/ap/signin.*" />

                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
</activity>

我尝试了一个新活动并在那里使用了第二个意图过滤器,但仍然是同样的问题。所有 url 开始从浏览器重定向到应用程序,而不是仅 /ap/signin url。

当我只使用第二个意图过滤器并删除了第一个意图过滤器时,/ap/signin url 仅从浏览器重定向到应用程序,但所有其他 deeplink/applink url 停止工作。这对我来说有点熟悉。

有人对此有适当的解决方案吗?在不破坏现有流程的情况下,如何引入新的 pathPattern ?

4

1 回答 1

0

您需要使用“pathPrefix”,因此只有 ap/signin 会在您的应用中打开

    <intent-filter>
            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:host="xxxxxx.com" />

            <data android:pathPrefix="/ap/signin/" />

            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
于 2020-10-04T12:28:51.710 回答