简体   繁体   中英

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

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',
  ),
);

在此处输入图像描述

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM