Reputation: 11
I am using Cordova on my project and have been trying to implement deeplink where if the app is installed on the device, clicking the URL will open the app, else it will open the browser to go to the website.
In my project's requirement, there are paths that are only allowed to be visited in the website so I decided to use intent-filter
with pathPrefix
to only state the allowed paths in the app. However, when I built the app, the app will also open with paths that I did not include like example.com/blocked-path
etc.
Here's the sample codeblock of how I implemented it on my config.xml:
<platform name="android">
....
<config-file parent="application/activity" target="AndroidManifest.xml">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.category.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/allowed-path" />
</intent-filter>
</config-file>
....
</platform>
What might cause this problem?
I have also tried to achieve this using ionic-plugin-deeplinks
. It works as I expected, however, it seems like it allows only 5 ANDROID_PATH_PREFIX
. Below is how I initially tried it:
<plugin name="ionic-plugin-deeplinks" spec="^1.0.20">
<variable name="URL_SCHEME" value="example" />
<variable name="DEEPLINK_SCHEME" value="https" />
<variable name="DEEPLINK_HOST" value="example.com" />
<variable name="ANDROID_PATH_PREFIX" value="/allowed-path-1" />
<variable name="ANDROID_2_PATH_PREFIX" value="/allowed-path-2" />
<variable name="ANDROID_3_PATH_PREFIX" value="/allowed-path-3" />
<variable name="ANDROID_4_PATH_PREFIX" value="/allowed-path-4" />
<variable name="ANDROID_5_PATH_PREFIX" value="/allowed-path-5" />
<variable name="DEEPLINK_2_SCHEME" value="https" />
<variable name="DEEPLINK_2_HOST" value="example.com" />
<variable name="DEEPLINK_3_SCHEME" value="https" />
<variable name="DEEPLINK_3_HOST" value="example.com" />
<variable name="DEEPLINK_4_SCHEME" value="https" />
<variable name="DEEPLINK_4_HOST" value="example.com" />
<variable name="DEEPLINK_5_SCHEME" value="https" />
<variable name="DEEPLINK_5_HOST" value="example.com" />
</plugin>
Adding DEEPLINK_6_HOST
, DEEPLINK_6_SCHEME
, and ANDROID_6_PATH_PREFIX
does not work. I also tried having multiple ANDROID_PATH_PREFIX
with different paths but it doesn't work either so I resorted to just doing it by intent-filter
Upvotes: 1
Views: 24