DeepLinkDispatch 匹配任何路径

DeepLinkDispatch match any path

我正在使用 AirBnB 的 DeepLinkDispatch 来处理应用程序中的深度 links,我想匹配深度 links,例如:

appscheme://productsSection/some/nested/product/categories/structure
appscheme://productsSection/some/nested/product/categories
appscheme://productsSection

根据我在文档中看到的内容,我可以配置一个深度 link 路径,例如:

@DeepLink("appscheme://productsSection")
@DeepLink("appscheme://productsSection/{topCategoryId}")
@DeepLink("appscheme://productsSection/{topCategoryId}/{subCategoryId}")

我的问题是我在编译时不知道路径嵌套的深度。

是否有任何方法可以将库配置为匹配整个嵌套路径而不指定每个段,例如 @Deeplink("appscheme://productsSection/*"),以便我可以手动处理 URI 路径并从中构建我的导航堆栈?

如果是这样,class 的注释是什么? (我只对 匹配 深度 link 感兴趣,而不是从中提取路径段作为参数)

请注意,我还使用该库处理应用程序各个部分的其他深度 link(匹配主要在 URI 主机和一个或两个路径段上完成)和我不想删除库并手动处理所有深度 links。

谢谢!

通过查看代码库,库目前不支持此功能。

您可以尝试打开一个 issue 看看他们是否可以添加对它的支持。

在撰写本文时,考虑到您要实现的目标目前不在库的范围内,直接在 AndroidManifest.xml 中自己实现该方案会不会容易得多,并且然后从那里去?

<activity android:name=".MyDeepLinkActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="appscheme" android:host="productsSection" />
    </intent-filter>
</activity>

您可以阅读有关如何设置的更多信息here