Receive Firebase Dynamic Links in a Flutter app

Note: Firebase Dynamic Links isdeprecated and should not be used in new projects. The service will be shutting down soon. Follow the migration guide and see theDynamic Links Deprecation FAQ for more information.

To receive the Firebase Dynamic Links thatyou created,you must include the Dynamic Links SDK in your app and call theFirebaseDynamicLinks.getDynamicLink() method when your app loads toget the data passed in the Dynamic Link.

Set up Firebase and the Dynamic Links SDK

  1. Install and initialize the Firebase SDKs for Flutter if youhaven't already done so.

  2. From the root directory of your Flutter project, run the followingcommand to install the Dynamic Links plugin:

    flutter pub add firebase_dynamic_links
  3. If you're building an Android app, open theProject settingspage of the Firebase console and make sure you've specified your SHA-1signing key. If you use App Links, also specify your SHA-256 key.

Platform integration

Complete the following platform integration steps for the platforms you'rebuilding your app for.

Android

On Android, you must add a new intent filter catch deep links of your domain, since theDynamic Link will redirect to your domain if your app is installed. This is required for your app toreceive the Dynamic Link data after it is installed/updated from the Play Store and one taps onContinue button. InAndroidManifest.xml:

<intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:host="example.com"android:scheme="https"/></intent-filter>

When users open a Dynamic Link with a deep link to the scheme and host you specify, your app willstart the activity with this intent filter to handle the link.

The next step is to ensure the SHA-256 fingerprint of the signing certificate is registered in the Firebase consolefor the app. You can find more details on how to retrieve your SHA-256 fingerprint on theAuthenticating Your Client page.

Apple platforms

  1. Create an Apple developer accountif you don't already have one.

  2. On theProject settingspage of the Firebase console, ensure that your iOS app is correctlyconfigured with your App Store ID and Team ID.

  3. On the Apple Developer site, create a provisioning profile for your appwith the Associated Domain capability enabled.

  4. In Xcode, do the following:

    1. Open your app under theTARGETS header.

    2. On the Signing & Capabilities page, ensure your Team is registered, andyour Provisioning Profile is set.

    3. On the Signing & Capabilities page, enableAssociated Domains andadd the following to the Associated Domains list (replace example with your domain):

      applinks:example.page.link
    4. On the Info page, add a URL Type to your project. Set the URL Schemesfield to your app's bundle ID. (The Identifier can beBundle ID orwhatever you wish.)

    5. If you have set up a custom domain for your Firebase project, add theDynamic Link URL prefix into your iOS project'sInfo.plist fileusing theFirebaseDynamicLinksCustomDomains key.

      <?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEplistPUBLIC"-//Apple//DTDPLIST1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plistversion="1.0"><dict><key>FirebaseDynamicLinksCustomDomains</key><array><string>https://custom.domain.io/path1</string><string>https://custom.domain.io/path2</string></array>...othersettings</dict></plist>
    6. Optional: Disable the Dynamic Links SDK's use of the iOS pasteboard.

      By default, the Dynamic Links SDK uses the pasteboard to improve thereliability of post-install deep links. By using the pasteboard, DynamicLinks can make sure that when a user opens a Dynamic Link but needs toinstall your app first, the user can go immediately to the originallinked content when opening the app for the first time afterinstallation.

      The downside of this is that use of the pasteboard triggers anotification on iOS 14 and later. So, the first time users open yourapp, if the pasteboard contains a Dynamic Link URL, they will see anotification that your app accessed the pasteboard, which can causeconfusion.

      To disable this behavior, edit your Xcode project'sInfo.plist fileand set theFirebaseDeepLinkPasteboardRetrievalEnabled key toNO.

      Note: When you disable this feature, the Dynamic Links you receive will haveamatchType ofweak at best. Adjust your app's logic accordingly.

Handle deep links

To handle a Dynamic Link in your application, two scenarios require implementing.

Warning: You may have unexpected results if you have enabled Flutter deep linking in your app.SeeMigrating from plugin-based deep linking.ThisGitHub issue illustrates what you ought to be aware of.

Terminated State

Set up the following methods:

  1. FirebaseDynamicLinks.getInitialLink - returns aFuture<PendingDynamicLinkData?>
  2. FirebaseDynamicLinks.onLink - event handler that returns aStream containing aPendingDynamicLinkData?

Android will always receive the link viaFirebaseDynamicLinks.getInitialLink from a terminated state,but on iOS, it is not guaranteed. Therefore, it is worth setting them both up in the following orderto ensure your application receives the link:

Future<void>main()async{WidgetsFlutterBinding.ensureInitialized();awaitFirebase.initializeApp(options:DefaultFirebaseConfig.platformOptions);// Check if you received the link via `getInitialLink` firstfinalPendingDynamicLinkData?initialLink=awaitFirebaseDynamicLinks.instance.getInitialLink();if(initialLink!=null){finalUrideepLink=initialLink.link;// Example of using the dynamic link to push the user to a different screenNavigator.pushNamed(context,deepLink.path);}FirebaseDynamicLinks.instance.onLink.listen((pendingDynamicLinkData){// Set up the `onLink` event listener next as it may be received hereif(pendingDynamicLinkData!=null){finalUrideepLink=pendingDynamicLinkData.link;// Example of using the dynamic link to push the user to a different screenNavigator.pushNamed(context,deepLink.path);}},);runApp(MyApp(initialLink));}

Within your application logic, you can then check whether a link was handled and perform an action, for example:

if(initialLink!=null){finalUrideepLink=initialLink.link;// Example of using the dynamic link to push the user to a different screenNavigator.pushNamed(context,deepLink.path);}

Background / Foreground State

Whilst the application is open, or in the background, use theFirebaseDynamicLinks.onLinkgetter:

FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData){Navigator.pushNamed(context,dynamicLinkData.link.path);}).onError((error){// Handle errors});

Alternatively, if you wish to identify if an exact Dynamic Link was used to open the application, pass it tothegetDynamicLink method instead:

Stringlink='https://dynamic-link-domain/ke2Qa';finalPendingDynamicLinkData?initialLink=awaitFirebaseDynamicLinks.instance.getDynamicLink(Uri.parse(link));

Testing A Dynamic Link On iOS Platform

To test a dynamic link on iOS, it is required that you use an actual device. You will also need to run the app in release mode (i.e.flutter run --release.),if testing a dynamic link from a terminated (i.e. app has been swiped closed.) app state.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-03 UTC.