0

I'm trying to use <nav-graph> generator to generate <intent-filter> elements in my AndroidManifest.xml

In one of the fragments in my nav_graph.xml, I added:

<deepLink app:uri="axzae://notifications" />

In the generated APK, the AndroidManifest.xml looks like below

<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="axzae" />
  <data android:host="notifications" />
  <data android:path="/" />
</intent-filter>

Now, the problem is with the additional android:path="/". It made the app only respond to axzae://notifications/ but not axzae://notifications (take note of the ending slash)

Is there anywhere I can make <nav-graph> to support axzae://notifications deeplink or without generating the <data android:path="/" /> line?

You Qi
  • 8,353
  • 8
  • 50
  • 68

1 Answers1

1

apparently, jetpack navigations can't resolve the generated axzae://notifications/. the app launched but it will always open up your startDestination. so it's actually broken.

another thing to note is it works fine for second-layer deep links. Example axzae://notifications/settings will work fine.

I will resort to a workaround for now by manually populating the TLD/host-only deep links in AndroidManifest.xml

<activity
  android:name=".ui.MainActivity"
  android:exported="true"
  android:theme="@style/Theme.App">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  
  <nav-graph android:value="@navigation/nav_graph" />

  <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="axzae" />
    <data android:host="home" />
    <data android:host="notifications" />
    ...
  </intent-filter>
</activity>
You Qi
  • 8,353
  • 8
  • 50
  • 68