How to use PathPattern in order to create DeepLink Apps Android?
It's a common drawback in android deep linking that it only support *
and .
regex character. It's mentioned in Android docs and can be observed in source code.
From docs:
For more information on these three types of patterns, see the descriptions of PATTERN_LITERAL, PATTERN_PREFIX, and
PATTERN_SIMPLE_GLOB
in the PatternMatcher class.
PATTERN_SIMPLE_GLOB is for regex and it says only match
/** * Pattern type: the given pattern is interpreted with a * simple glob syntax for matching against the string it is tested against. * In this syntax, you can use the
'*'
character to match against zero or * more occurrences of the character immediately before. If the * character before it is'.'
it will match any character. The character *'\'
can be used as an escape. This essentially provides only the '*' * wildcard part of a normal regexp. */
public static final int PATTERN_SIMPLE_GLOB = 2;
So only *
, .
and \
are allowed. Usage of other pattern literal +,?
etc; will result in failure.
Either you can use your working option or you can use
https://example.com/./....*
....*
at least 3 characters then .*
mean 0 or more characters
<activity
android:name="packagename.ActivityName" >
<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="http"
android:host="www.example.com"
android:pathPattern="/./....*" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
</activity>