Professional Documents
Culture Documents
Firebase Dynamic Links - Google (202109)
Firebase Dynamic Links - Google (202109)
!" # $% !
Firebase Dynamic Links are links that work the way you want, on multiple platforms,
and whether or not your app is already installed.
With Dynamic Links, your users get the best available experience for the platform
they open your link on. If a user opens a Dynamic Link on iOS or Android, they can
be taken directly to the linked content in your native app. If a user opens the same
Dynamic Link in a desktop browser, they can be taken to the equivalent content on
your website.
In addition, Dynamic Links work across app installs: if a user opens a Dynamic Link
on iOS or Android and doesn't have your app installed, the user can be prompted to
install it; then, after installation, your app starts and can access the link.
You create a Dynamic Link either by using the Firebase console, using a REST API,
iOS or Android Builder API, or by forming a URL by adding Dynamic Link parameters
to a domain speciNc to your app. These parameters specify the links you want to
open, depending on the user's platform and whether your app is installed.
When a user opens one of your Dynamic Links, if your app isn't yet installed, the
user is sent to the Play Store or App Store to install your app (unless you specify
otherwise), and your app opens. You can then retrieve the link that was passed to
your app and handle the deep link as appropriate for your app.
You can create Dynamic Links using your own domain name
(/docs/dynamic-links/custom-domains):
https://example.com/summer-sale
https://example.com/links/promos/summer-sale
https://links.example.com/summer-sale
https://ex.amp.le/summer-sale
Or, if you don't have a domain for your app, you can use a free custom page.link
subdomain:
https://example.page.link/summer-sale
All Dynamic Links features, including analytics, post-install attributions, and SDK
integrations, work with both custom page.link domains and your own domain.
Implementation path
Learn about some of Firebase Dynamic Links' most common use cases
(/docs/dynamic-links/use-cases) and how to implement them.
Except as otherwise noted, the content of this page is licensed under the Creative
Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/),
and code samples are licensed under the Apache 2.0 License
(https://www.apache.org/licenses/LICENSE-2.0). For details, see the Google
Developers Site Policies (https://developers.google.com/site-policies). Java is a
registered trademark of Oracle and/or its a\liates.
Using the Firebase console. This is useful if you're creating promo links to
share on social media. This way you can select a custom su?x and a name
for the link in the Firebase console. You can track the performance of these
Dynamic Links in the Firebase console or via the Analytics REST API.
Using the Dynamic Link Builder API on iOS and Android. This is the preferred
way to dynamically create links in your app for user-to-user sharing or in any
situation that requires many links. You can track the performance of Dynamic
Links created with the Builder API using the Dynamic Links Analytics API.
Using the REST API. This is the preferred way to dynamically create links on
platforms that don't have a Builder API. The Analytics REST API can be used
to track the performance of promo campaigns created in the console.
Manually. If you don't need to track click data and you don't care if the links
are long, you can manually construct Dynamic Links using URL parameters,
and by doing so, avoid an extra network round trip.
Next steps
After you create Dynamic Links, you need to set up your app to receive Dynamic
Links and send users to the right place in your app after a user opens them.
To receive Dynamic Links in your app, see the documentation for iOS, Android, C++,
and Unity.
Except as otherwise noted, the content of this page is licensed under the Creative
Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0
License. For details, see the Google Developers Site Policies. Java is a registered
trademark of Oracle and/or its a?liates.
https://example.com/link-suffix
https://example.com/links/promos/link-suffix
https://links.example.com/link-suffix
https://ex.amp.le/link-suffix
The part of the URL before link-su(x is called the URL pre(x, and contains both
your custom Dynamic Link domain and a path preDx. You will need to provide a URL
preDx when you create Dynamic Links.
! Note: To use a custom domain for Dynamic Links, the domain must point
to Firebase Hosting. If you have a domain you want to use with Dynamic
Links and the domain points to a different host, you can either move to
Firebase Hosting or create a subdomain hosted by Firebase, which you
can use for Dynamic Links.
You can use the same domain for your Dynamic Links and your web pages,
Universal Links, and App Links, but if you do, you must take care that your Dynamic
Link URLs don't conNict with your web URLs. When you conDgure Dynamic Links to
use a particular URL preDx, all URLs that begin with that preDx are treated as
Dynamic Links, so you can't use URLs with that preDx to point to ordinary hosted
content.
So, the following long-form Dynamic Links (and equivalent short links) won't work
as intended because the URLs speciDed by the link parameter start with the
Dynamic Link URL preDx, https://example.com/ :
" https://example.com/?link=https://example.com/my-resource
" https://example.com/?
link=https://example.com/resources/my-resource
But the following long-form Dynamic Links (and equivalent short links) can work,
because the URL preDxes don't conNict with the link URLs:
# https://link.example.com/?link=https://example.com/my-
resource
# https://example.com/links/?link=https://example.com/my-
resource
# https://ex.amp.le/?link=https://example.com/my-resource
You can usually set up a custom domain completely in the Firebase console. To do
so:
1. If you haven't set up Firebase Hosting for your project, open the Hosting page
of the Firebase console, click Get Started, and click through the setup
instructions. You don't have to complete the indicated steps at this time.
3. If you haven't used Dynamic Links before, click Get Started. Otherwise, click
Add URL pre1x from the drop-down menu.
Then, complete the setup wizard, specifying the domain and path preDx you
want to use when prompted.
! Note: You can't use the same URL preDx for both Dynamic Links
and regular hosting. If you want to use the same branding for
both, consider using a path preDx (for example,
example.com/links) or subdomain (links.example.com/) in your
Dynamic Links URL preDx.
4. iOS only: In your Xcode project's Info.plist Dle, create a key called
FirebaseDynamicLinksCustomDomains and set it to your app's Dynamic
Links URL preDxes. For example:
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://example.com/link</string>
<string>https://example.com/promos</string>
</array>
In some situations, such as when you already have a custom domain set up for
Dynamic Links and want to add another domain, or when you are adding a domain
already connected to a Hosting site, you have to set up your custom domain
manually.
To do so:
1. Connect your domain to Firebase Hosting if you haven't already done so.
Specify the path preDxes you want to use for Dynamic Links by setting
rewrite rules with dynamicLinks set to true . Requests to these
paths get proxied to Dynamic Links.
Unlike rules that rewrite paths to URLs, Dynamic Link rewrite rules can't
contain regular expressions.
If you have multiple rewrite rules for your site, be aware that Hosting
executes the Drst rewrite rule that matches the request.
For example:
"hosting": {
// ...
"appAssociation": "AUTO",
"rewrites": [
{
"source": "/promos/**",
"dynamicLinks": true
},
{
"source": "/links/share/**",
"dynamicLinks": true
}
]
}
With the above conDguration, you can create Dynamic Links with URL
preDxes like the following examples:
https://your-domain/promos/link-suffix
https://your-domain/links/share/link-suffix
! Note: You can't use the same URL preDx for both Dynamic Links
and regular hosting. If you want to use the same branding for
both, consider using a path preDx (for example,
example.com/links) or subdomain (links.example.com/) in your
Dynamic Links URL preDx.
If you use this domain only for Dynamic Links, you can use a source path of
/** to create Dynamic Links with no path preDx:
{
"source": "/**",
"dynamicLinks": true
}
With the above rule, you can create Dynamic Links like the following example:
https://your-domain/link-suffix
(optional) You can check the deployed firebase.json content using the
Hosting REST API.
5. iOS only: In your Xcode project's Info.plist Dle, create a key called
FirebaseDynamicLinksCustomDomains and set it to your app's Dynamic
Links URL preDxes. For example:
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://example.com/promos</string>
<string>https://example.com/links/share</string>
</array>
Ensure that your Dynamic Links URL preDx doesn't conNict with higher priority
hosting conDgurations (for example, hosted static content always has priority
over rewrites).
Within the rewrites attribute, the Hosting response will obey the rule
speciDed by the (rst source glob that captures the requested path.
If you want to use the same branding for both Dynamic Links and Hosting, consider
one of the following options for your Dynamic Links URL preDx:
Set your source attribute to match a path preDx. For example, if you have a
custom domain of example.com , your rewrite rule could be:
// Domain is example.com
"rewrites": [ {
"source": "/links/**", // Dynamic Links start with
"https://example.com/links/"
"dynamicLinks": true
} ]
Set up a subdomain to use for Dynamic Links, then set your source
attribute to match that subdomain. For example, if you have a subdomain of
links.example.com , your rewrite rule could be:
// Domain is links.example.com
"rewrites": [ {
"source": "/**", // Dynamic Links start with
"https://links.example.com/"
"dynamicLinks": true
} ]
! Note: You can check the deployed firebase.json content using the
Hosting REST API.
Except as otherwise noted, the content of this page is licensed under the Creative
Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0
License. For details, see the Google Developers Site Policies. Java is a registered
trademark of Oracle and/or its aaliates.