1

I have a url, e.g. https://www.mobilePhoneSystem.com/{user}/registerDate/{date}. So the {user} path-prefix is dynamic. I need to handle ONLY the deeplinks, that contains registerDate. I wrote in my manifest something like this

<!-- 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>

But it doesn't trigger. When I add any user in mainfest, e.g. pathPrefix=/user111/registerDate, it triggers and works fine. But the user is dynamic. So how can I handle this type of deeplink?

Hayk Mkrtchyan
  • 2,835
  • 3
  • 19
  • 61

3 Answers3

4

This should work for you :

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

Explanation : The . enforces a pattern of "one of any character". The .* enforces "any number (or none!) of any character".

Combining these two, ..* enforces "any number of any characters, but at least one must be provided"

  • 4
    android:pathPattern="..*/registerDate/..*" - For me this solution worked with 2 dots, I didn't try with single dot, but anyway I'll accept your answer. Thanks – Hayk Mkrtchyan Oct 09 '20 at 09:04
1

You can check navGraphs here

in navGraph

<deepLink
    android:id="@+id/deepLink"
    app:uri="mobilePhoneSystem.com/{userId}/registerDate" />
       
<argument
    android:name="userId"
    app:argType="string"/>
gmetax
  • 3,853
  • 2
  • 31
  • 45
0

you could use library it will solve the problem for you github.com/airbnb/DeepLinkDispatch and you could even get your {user} and {date} directly without any added hassle

mhemdan
  • 101
  • 2
  • 9