This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com:
You can create short or long Dynamic Links with the Firebase Dynamic Links Builder API. This API accepts either a long Dynamic Link or an object containing Dynamic Link parameters, and returns URLs like the following examples:
Before you can create Dynamic Links in your Android app, you must include the Firebase SDK. If your app is set up to receive Dynamic Links, you have already completed these steps and you can skip this section.
Install and initialize the Firebase SDKs for Flutter if you haven't already done so.
From the root direcctory of your Flutter project, run the following command to install the Dynamic Links plugin:flutter pub add firebase_dynamic_links
If you're building an Android app, open the Project settings page of the Firebase console and make sure you've specified your SHA-1 signing key. If you use App Links, also specify your SHA-256 key.
In the Firebase console, open the Dynamic Links section.
If you have not already set up a domain for your Dynamic Links, click the Get Started button and follow the prompts.
If you already have a Dynamic Links domain, take note of it. You need to provide a Dynamic Links domain when you programmatically create Dynamic Links.
Recommended: From the "More" (⋮) menu, specify the URL patterns allowed in your deep links and fallback links. By doing so, you prevent unauthorized parties from creating Dynamic Links that redirect from your domain to sites you don't control.
To create a Dynamic Link, create a new
DynamicLinkParameters object and pass it to
The following minimal example creates a long Dynamic Link to
https://www.example.com/ that opens with
com.example.app.android on Android
and the app
com.example.app.ios on iOS:
To create a short Dynamic Link, pass the
DynamicLinkParameters object to
buildShortLink(). Building the short link requires a network call.
By default, short Dynamic Links are generated with suffixes that are only a few characters long. Although this makes links more compact, it also introduces the possibility that someone could guess a valid short link. Often, there's no harm if someone does so, because the link leads to public information.
However, if your short links lead to user-specific information, you should
create longer links with 17-character suffixes that make it very unlikely that
someone can guess a valid Dynamic Link. To do so, pass
Dynamic Link parameters
You can use the Dynamic Link Builder API to create Dynamic Links with any of the supported parameters. See the API reference.
The following example creates a Dynamic Link with several common parameters set:
You can set Dynamic Link parameters with the following methods:
|setLink||The link your app will open. Specify a URL that your app can handle, typically the app's content or payload, which initiates app-specific logic (such as crediting the user with a coupon or displaying a welcome screen). This link must be a well-formatted URL, be properly URL-encoded, use either HTTP or HTTPS, and cannot be another Dynamic Link.|
|setDomainUriPrefix||Your Dynamic Link URL prefix, which you can find in the Firebase console. A Dynamic Link domain looks like the following examples:|
|setFallbackUrl||The link to open when the app isn't installed. Specify this to do something other than install your app from the Play Store when the app isn't installed, such as open the mobile web version of the content, or display a promotional page for your app.|
|setMinimumVersion||The versionCode of the minimum version of your app that can open the link. If the installed app is an older version, the user is taken to the Play Store to upgrade the app.|
|setAppStoreId||Your app's App Store ID, used to send users to the App Store when the app isn't installed|
|setFallbackUrl||The link to open when the app isn't installed. Specify this to do something other than install your app from the App Store when the app isn't installed, such as open the mobile web version of the content, or display a promotional page for your app.|
|setCustomScheme||Your app's custom URL scheme, if defined to be something other than your app's bundle ID|
|setIpadFallbackUrl||The link to open on iPads when the app isn't installed. Specify this to do something other than install your app from the App Store when the app isn't installed, such as open the web version of the content, or display a promotional page for your app.|
|setIpadBundleId||The bundle ID of the iOS app to use on iPads to open the link. The app must be connected to your project from the Overview page of the Firebase console.|
|setMinimumVersion||The version number of the minimum version of your app that can open the link. This flag is passed to your app when it is opened, and your app must decide what to do with it.|
|setForcedRedirectEnabled||If set to '1', skip the app preview page when the Dynamic Link is opened, and instead redirect to the app or store. The app preview page (enabled by default) can more reliably send users to the most appropriate destination when they open Dynamic Links in apps; however, if you expect a Dynamic Link to be opened only in apps that can open Dynamic Links reliably without this page, you can disable it with this parameter. This parameter will affect the behavior of the Dynamic Link only on iOS.|
|setTitle||The title to use when the Dynamic Link is shared in a social post.|
|setDescription||The description to use when the Dynamic Link is shared in a social post.|
|setImageUrl||The URL to an image related to this link. The image should be at least 300x200 px, and less than 300 KB.|
|Google Play analytics parameters. These parameters (`utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, `utm_content`) are passed on to the Play Store as well as appended to the link payload.|
|iTunes Connect analytics parameters. These parameters (`pt`, `at`, `ct`) are passed to the App Store.|