【问题标题】:Android deeplinking Intent sspPattern issueAndroid 深度链接 Intent ssp 模式问题
【发布时间】:2021-09-18 23:26:57
【问题描述】:

我有两个用于电子邮件确认和密码重置的链接,因为电子邮件确认链接没有pathPrefix,它与密码重置链接冲突。

我使用sspPattern 根据它们之间的差异对它们进行分类,但密码链接会触发这两种意图。链接如下。

<activity
        android:name=".ui.deepLink.ResetPassword"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter android:label="@string/my_website">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="mywebsite.de"
                android:pathPrefix="/resetpassword"
                android:sspPattern="/resetpassword?userId=.*&amp;c=.*"
                android:scheme="https" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ui.deepLink.EmailConfirmation"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter android:label="@string/my_website">
            <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="mywebsite.de"
                android:sspPattern="//mywebsite.de/?userId=.*&amp;code=.*"/>
        </intent-filter>
    </activity>

电子邮件确认链接https://mywebsite.de/resetpassword?UserId=35541&c=B66ZcFVwXfGhyHZQ==

密码重置链接https://mywebsite.de/?userId=35541&code=S%2bvaKQjLJC

【问题讨论】:

    标签: android android-intent intentfilter


    【解决方案1】:

    两个链接都可以使用android:pathPrefix

    链接:https://mywebsite.de/resetpassword?UserId=35541&c=B66ZcFVwXfGhyHZQ==

    android:pathPrefix="/resetpassword"
    

    链接:https://mywebsite.de/userId=35541&code=S%2bvaKQjLJC

    android:pathPrefix="/userId"
    

    【讨论】:

    • 第二个链接是一个查询并且有一个问号“mywebsite.de/?userId= ...”因此我不能使用android:pathPrefix="/userId"。那时它不会被触发。谢谢你的回答