【问题标题】:android deeplinking - the first path prefix is dynamic, but the second notandroid deeplinking - 第一个路径前缀是动态的,但第二个不是
【发布时间】:2020-11-13 01:29:09
【问题描述】:

我有一个网址,例如https://www.mobilePhoneSystem.com/{user}/registerDate/{date}。所以{user} 路径前缀是动态的。我只需要处理包含registerDate 的深层链接。 我在清单中写了这样的内容

<!-- Deep linking-->
        <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="https"
                android:host="/www.mobilePhoneSystem.com"
                android:pathPrefix="/registerDate" />

        </intent-filter>
    </activity>

但它不会触发。当我在 mainfest 中添加任何用户时,例如pathPrefix=/user111/registerDate,它触发并且工作正常。但是用户是动态的。那么我该如何处理这种类型的深层链接呢?

【问题讨论】:

    标签: android manifest deep-linking intentfilter


    【解决方案1】:

    这应该适合你:

    android:pathPattern="/.*/registerDate/.*/"
    

    说明 : 这 。强制执行“任何字符之一”的模式。 .* 强制执行“任何数字(或无!)任何字符”。

    结合这两者,..* 强制执行“任意数量的任意字符,但必须至少提供一个”

    【讨论】:

    • android:pathPattern="..*/registerDate/..*" - 对我来说,这个解决方案使用 2 个点,我没有尝试使用单点,但无论如何我会接受你的回答.谢谢
    【解决方案2】:

    您可以查看导航图here

    在导航图中

    <deepLink
        android:id="@+id/deepLink"
        app:uri="mobilePhoneSystem.com/{userId}/registerDate" />
           
    <argument
        android:name="userId"
        app:argType="string"/>
    

    【讨论】:

    • 那是导航组件?
    • 如果我不使用导航组件怎么办?
    【解决方案3】:

    你可以使用库它会为你解决问题github.com/airbnb/DeepLinkDispatch 您甚至可以直接获取您的 {user} 和 {date},而无需任何额外的麻烦

    【讨论】:

      猜你喜欢
      • 2018-05-23
      • 1970-01-01
      • 2020-12-12
      • 1970-01-01
      • 2021-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      相关资源
      最近更新 更多