Cannot read firebase dynamic link inside flutter app

  Kiến thức lập trình

I’m trying to read a dynamic link that I created on firebase inside my flutter application, I did all the configuration but I’m always getting null as a value.

Here is my firebase config:

Shortlink: https://******.page.link/test

Dynamic link: https://*******.tn/restaurant?id=64fdf73f3ac564fe091a22e6

my android manifest file code:

 <meta-data 
                android:name="flutter_deeplinking_enabled" 
                android:value="true"/>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="https" />
                <data android:host="******.page.link" />
            </intent-filter>

And here is how i’m trying to read the dynamic link:

void initLink() {
  FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) {
    print('dynamic link');
    print(dynamicLinkData.toString());
  }).onError((error) {
    // Handle errors
  });
}

and this is my main function:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  initLink();
}

It doesn’t return me anything and actually it does not listen to any links, note that i’m running it on an android physical device on debug mode. Thanks for your help!

LEAVE A COMMENT