Search code examples
androidandroid-architecture-navigationandroid-12android-deep-linkandroid-13

Navigation Component: deep link won't open in app until a user checks an address as supported one in settings of app


So I have implemented the deep link logic like this with Navigation Component:

nav_graph.xml:

<fragment
    android:id="@+id/forgotPasswordChangeFragment"
    android:name="......ForgotPasswordChangeFragment" >
    <argument
        android:name="token"
        app:argType="string" />
    <deepLink app:uri="https://example.com/create-new-password/{token}" />
</fragment>

AndroidManifest.xml:

<activity
    android:name=".ui.MainActivity"
    android:exported="true">
    
    <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_main" />

</activity>

But the link https://example.com/create-new-password/24c37747e3a451e60c0c61c06b36eee7 opens only in browser apps (for Android 12+)

When I allow example.com as supported web address in the device system settings about app ("App info") then it works fine

enter image description here

enter image description here

enter image description here

But users are not going to do such things...

Should add some other permissions somehow for the address or deep link? What else do I miss?

UPDATE

I checked this https://developer.android.com/training/app-links/verify-site-associations

But how can I add android:autoVerify when I use Navigation Component and graph.xml?


Solution

  • As per the page you've linked to, the visual Navigation Editor allows you to set this when building your deep link:

    (optional) Check Auto Verify to require Google to verify that you are the owner of the URI.

    You can manually add this to your XML as well (which is all the visual editor is going to do for you):

    <deepLink
        app:uri="https://example.com/create-new-password/{token}"
        android:autoVerify="true" />
    

    This will automatically add that flag to the generated intent filters in your manifest.