We have an app that utilises Deeplinks. We also use the Android Navigation component.
Currently we configure our Deeplinks in out navigation.xml file and this works fine but we now have the requirement to be able to add another Deeplink at build time based on a set Environment Variable.
I have attempted setting String resources in the build.gradle and referenceing these in the navigation.xml.
I have also attempted setting a placeholder in the navigation.xml but cannot replace it as it has already been parsed as a URI.
I have also attempted setting direct intent filters in the Manifest with placeholders, this will work but we lose the nice routing from the navigation component.
Currently we configure our Deeplinks in out navigation.xml file in the following form:
<deepLink
android:autoVerify="true"
app:uri="foo.bar.baz/pull/{quxArg}/{quuxArg}" />
We now have the requirement to be able to create an additional Deeplink at build time based on a set Envar.
Example:
DEEPLINK_ENVAR = "replacement.com"
Build.gradle:
manifestPlaceholders = [deeplink:DEEPLINK_ENVAR]
navigation.xml:
<deepLink
android:autoVerify="true"
app:uri="${deeplink}/pull/{quxArg}/{quuxArg}" />
Please note the above does not work.
If this was just an intent-filter in the Manifest we could use Manifest placeholders to achieve this task and set them in the app.gradle. However Deeplinks set in navigation.xml are parsed as URIs and destroy any placeholders before they can be replaced.
Has anyone attempted anything similar? I am trying to avoid having to run a pre-build script to template the navigation file directly.
Desired outcome:
I am looking to be able to add an additional deeplink (4 actually to different destinations) at build time whilst making use of Android Navigation component.