Firebase dynamic link with flutter: Deep link URL doesnt open app

4,731

You need to add this intent-filter in your first opening activity within the manifest,

<activity android:name="your default activity">
      
        <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:host="freshakaka.page.link"
                android:scheme="https" />
        </intent-filter>

    </activity>

to elaborate :

You need to search AndroidManifest.xml in your project when you find it out, you'll see something like this

   <activity
        android:name=".MainActivity"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

This is the first opening Activity because it has the intent-filter that contains LAUNCHER category which means your app will start from that Activity, so you need to add the intent-filter which I had provided above, like this

       <activity
        android:name=".MainActivity"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <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:host="freshakaka.page.link"
                android:scheme="https" />
        </intent-filter>

    </activity>

Also, you can check this to the more explicit explanation

https://firebase.google.com/docs/dynamic-links/android/receive

Share:
4,731
maaz
Author by

maaz

Updated on December 19, 2022

Comments

  • maaz
    maaz over 1 year

    I tried adding dynamic link to my flutter android app (not published) which is debug mode and running in a physical device. Configured firebase, dynamic links in the firebase console. everything is working as expected except one. When deeplink(https://www.mywebsite.com/deep-link-page) is clicked directly from anywhere it doesn't open the app. clicking dynamic link https://myapp.page.link opens app as expected.

     final DynamicLinkParameters parameters = DynamicLinkParameters(
      uriPrefix: 'https://freshakaka.page.link',
      link: Uri.parse('https://freshakaka.page.link/helloworld'),
      androidParameters: AndroidParameters(
        packageName: 'com.freshakaka.flutter',
        minimumVersion: 0,
      ),
      dynamicLinkParametersOptions: DynamicLinkParametersOptions(
        shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
      ),
      iosParameters: IosParameters(
        bundleId: 'com.google.FirebaseCppDynamicLinksTestApp.dev',
        minimumVersion: '0',
      ),
    );
    

    enter image description here

    As you see in the image - https://kannadaclub.com/2019/10/17/seltos-50k-bookings/ is my deeplink. when this link is been clicked from mobile, it always open website, not app.