Android firebase dynamic links

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.

How does it work?

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 specific 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.

Or, if you don’t have a domain for your app, you can use a free custom page.link subdomain:

Create your free subdomain in the Firebase console.

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

Set up Firebase and the Dynamic Links SDK Enable Firebase Dynamic Links for your Firebase project in the Firebase console. Then, include the Dynamic Links SDK in your app.
Create Dynamic Links You can create Dynamic Links programmatically or by using the Firebase console.
Handle Dynamic Links in your app When your app opens, use the Dynamic Links SDK to check if a Dynamic Link was passed to it. If so, get the deep link from the Dynamic Link data and handle the deep link as necessary.
View analytics data Track the performance of your Dynamic Links in the Firebase console.

Next steps

  • Learn about some of Firebase Dynamic Links’ most common use cases and how to implement them.
  • Learn how to create Dynamic Links and then receive them in your iOS, Android, Unity, and C++ apps.
  • Use your own custom domain for Dynamic Links.
  • Understand your Dynamic Links’s performance with two analytics tools.

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 affiliates.

Источник

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.

When you register your app, specify your SHA-1 signing key. If you use App Links, also specify your SHA-256 key.

Using the Firebase Android BoM, declare the dependency for the Dynamic Links Android library in your module (app-level) Gradle file (usually app/build.gradle ).

For an optimal experience with Dynamic Links, we recommend enabling Google Analytics in your Firebase project and adding the Firebase SDK for Google Analytics to your app.

By using the Firebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.

(Alternative) Declare Firebase library dependencies without using the BoM

If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

Note that if you use multiple Firebase libraries in your app, we highly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

Kotlin+KTX

By using the Firebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.

Читайте также:  Kotor savegame editor android

(Alternative) Declare Firebase library dependencies without using the BoM

If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

Note that if you use multiple Firebase libraries in your app, we highly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

If you have not already accepted the terms of service and set a domain for your Dynamic Links, do so when prompted.

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: 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. See Allow specific URL patterns.
  • Use the Firebase console

    If you want to generate a single Dynamic Link, either for testing purposes, or for your marketing team to easily create a link that can be used in something like a social media post, the simplest way would be to visit the Firebase console and create one manually following the step-by-step form.

    To create a Dynamic Link, create a new DynamicLink object with its Builder, specifying the Dynamic Link parameters with the Builder methods. Then, call buildDynamicLink or buildShortDynamicLink .

    The following minimal example creates a long Dynamic Link to https://www.example.com/ that opens with your Android app on Android and the app com.example.ios on iOS:

    Kotlin+KTX

    To create a short Dynamic Link, build a DynamicLink the same way, and then call buildShortDynamicLink . Building a short link requires a network call, so instead of directly returning the link, buildShortDynamicLink returns a Task , which makes the short link available when the request completes. For example:

    Kotlin+KTX

    By default, short Dynamic Links are generated with 17-character link suffixes that make it extremely unlikely that someone can guess a valid Dynamic Link. If, for your use case, there’s no harm in someone successfully guessing a short link, you might prefer to generate suffixes that are only as long as necessary to be unique, which you can do by passing ShortDynamicLink.Suffix.SHORT to the buildShortDynamicLink method:

    Kotlin+KTX

    You can use the Dynamic Link Builder API to create Dynamic Links with any of the supported parameters. See the API reference for details.

    The following example creates a Dynamic Link with several common parameters set:

    Kotlin+KTX

    You can set Dynamic Link parameters with the following methods:

    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.

    When users open a Dynamic Link on a desktop web browser, they will load this URL (unless the ofl parameter is specified). If you don’t have a web equivalent to the linked content, the URL doesn’t need to point to a valid web resource. In this situation, you should set up a redirect from this URL to, for example, your home page.

    DynamicLink parameters
    setLink
    setDomainUriPrefix Your Dynamic Link URL prefix, which you can find in the Firebase console. A Dynamic Link domain looks like the following examples:
    AndroidParameters
    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.
    IosParameters
    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.
    NavigationInfoParameters
    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.
    SocialMetaTagParameters
    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 300×200 px, and less than 300 KB.
    GoogleAnalyticsParameters
    setSource
    setMedium
    setCampaign
    setTerm
    setContent
    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.
    ItunesConnectAnalyticsParameters
    setProviderToken
    setAffiliateToken
    setCampaignToken
    iTunes Connect analytics parameters. These parameters ( pt , at , ct ) are passed to the App Store.

    To shorten a long Dynamic Link, specify the URL of the Dynamic Link using setLongLink instead of setting parameters with the other builder methods:

    Kotlin+KTX

    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 affiliates.

    Источник

    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.

    When you register your app, specify your SHA-1 signing key. If you use App Links, also specify your SHA-256 key.

    Using the Firebase Android BoM, declare the dependency for the Dynamic Links Android library in your module (app-level) Gradle file (usually app/build.gradle ).

    For an optimal experience with Dynamic Links, we recommend enabling Google Analytics in your Firebase project and adding the Firebase SDK for Google Analytics to your app.

    By using the Firebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.

    (Alternative) Declare Firebase library dependencies without using the BoM

    If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

    Note that if you use multiple Firebase libraries in your app, we highly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

    Kotlin+KTX

    By using the Firebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.

    (Alternative) Declare Firebase library dependencies without using the BoM

    If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

    Note that if you use multiple Firebase libraries in your app, we highly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

    If you have not already accepted the terms of service and set a domain for your Dynamic Links, do so when prompted.

    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: 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. See Allow specific URL patterns.
  • Use the Firebase console

    If you want to generate a single Dynamic Link, either for testing purposes, or for your marketing team to easily create a link that can be used in something like a social media post, the simplest way would be to visit the Firebase console and create one manually following the step-by-step form.

    To create a Dynamic Link, create a new DynamicLink object with its Builder, specifying the Dynamic Link parameters with the Builder methods. Then, call buildDynamicLink or buildShortDynamicLink .

    The following minimal example creates a long Dynamic Link to https://www.example.com/ that opens with your Android app on Android and the app com.example.ios on iOS:

    Kotlin+KTX

    To create a short Dynamic Link, build a DynamicLink the same way, and then call buildShortDynamicLink . Building a short link requires a network call, so instead of directly returning the link, buildShortDynamicLink returns a Task , which makes the short link available when the request completes. For example:

    Kotlin+KTX

    By default, short Dynamic Links are generated with 17-character link suffixes that make it extremely unlikely that someone can guess a valid Dynamic Link. If, for your use case, there’s no harm in someone successfully guessing a short link, you might prefer to generate suffixes that are only as long as necessary to be unique, which you can do by passing ShortDynamicLink.Suffix.SHORT to the buildShortDynamicLink method:

    Kotlin+KTX

    You can use the Dynamic Link Builder API to create Dynamic Links with any of the supported parameters. See the API reference for details.

    The following example creates a Dynamic Link with several common parameters set:

    Kotlin+KTX

    You can set Dynamic Link parameters with the following methods:

    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.

    When users open a Dynamic Link on a desktop web browser, they will load this URL (unless the ofl parameter is specified). If you don’t have a web equivalent to the linked content, the URL doesn’t need to point to a valid web resource. In this situation, you should set up a redirect from this URL to, for example, your home page.

    DynamicLink parameters
    setLink
    setDomainUriPrefix Your Dynamic Link URL prefix, which you can find in the Firebase console. A Dynamic Link domain looks like the following examples:
    AndroidParameters
    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.
    IosParameters
    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.
    NavigationInfoParameters
    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.
    SocialMetaTagParameters
    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 300×200 px, and less than 300 KB.
    GoogleAnalyticsParameters
    setSource
    setMedium
    setCampaign
    setTerm
    setContent
    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.
    ItunesConnectAnalyticsParameters
    setProviderToken
    setAffiliateToken
    setCampaignToken
    iTunes Connect analytics parameters. These parameters ( pt , at , ct ) are passed to the App Store.

    To shorten a long Dynamic Link, specify the URL of the Dynamic Link using setLongLink instead of setting parameters with the other builder methods:

    Kotlin+KTX

    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 affiliates.

    Источник

    Читайте также:  Лучшие блокировщики рекламы для андроид самсунг
    Оцените статью