Dynamic link firebase android

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:

    Читайте также:  Android для kia sorento prime

    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.

    Источник

    To receive the Firebase Dynamic Links that you created, you must include the Dynamic Links SDK in your app and call the FirebaseDynamicLinks.getDynamicLink() method when your app loads to get the data passed in the Dynamic Link.

    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.

  • In the Firebase console, open the Dynamic Links section. Accept the terms of service if you are prompted to do so.
  • As with plain deep links, you must add a new intent filter to the activity that handles deep links for your app. The intent filter should catch deep links of your domain, since the Dynamic Link will redirect to your domain if your app is installed. This is required for your app to receive the Dynamic Link data after it is installed/updated from the Play Store and one taps on Continue button. In AndroidManifest.xml :

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

    To receive the deep link, call the getDynamicLink() method:

    Kotlin+KTX

    You must call getDynamicLink() in every activity that might be launched by the link, even though the link might be available from the intent using getIntent().getData() . Calling getDynamicLink() retrieves the link and clears that data so it is only processed once by your app.

    You normally call getDynamicLink() in the main activity as well as any activities launched by intent filters that match the link.

    Record analytics

    The following events can be automatically tracked in Google Analytics and shown in the Firebase console.

    • dynamic_link_app_open
    • dynamic_link_first_open
    • dynamic_link_app_update

    In order to register these events, you need to configure Google Analytics before you retrieve the deep link. Check the following conditions are met:

    • Call FirebaseDynamicLinks.getDynamicLink() in your app entry points:
      • Launcher activities. e.g.: action=»android.intent.action.MAIN» , category=»android.intent.category.LAUNCHER» .
      • Activity entry points. e.g.: onStart() , onCreate() .
      • Deep link activities.
    • Set up and use Google Analytics:
      • Include the Google Analytics dependency. This is usually automatically added by the google-services Gradle plugin.
      • Include the google-services.json config file in your app.
      • Call FirebaseAnalytics.getInstance() before calling FirebaseDynamicLinks.getDynamicLink() .

    On Android 6.0 (API level 23) and higher, you can set up your app to handle Dynamic Links directly when your app is already installed by using Android App Links.

    Ensure that you have added the SHA256 certificate fingerprint for your app into your project in the Firebase console. Dynamic Links will handle setting up the App Links website association for your Dynamic Links domain.

    Add an auto-verified intent filter to the Activity that will handle the Dynamic Link, setting the host to your project’s Dynamic Links domain as found in the Firebase console. In the AndroidManifest.xml :

    Note that the android:host must be set to your Dynamic Links domain, and not the domain of your deep link.

    All autoVerify intent filters in your manifest must be registered in order for App Links to engage. Firebase handles this automatically for your Dynamic Links domains, but you can check this by opening the assetlinks.json file hosted on your Dynamic Links domain: All of your Firebase apps’ package names should be included.

    Dynamic Links will now be sent directly to your app. You will be able to get the deep link and other Dynamic Link data by calling getDynamicLink() in the Activity you added the App Links intent filter to (as described in Handle deep links).

    Note: Since invoking through App Links takes the user directly to the app, a Dynamic Link cannot honor the required minimum version. So once the app is opened, you need to compare the Dynamic Link’s minimum version ( getminimumappversion) against PackageInfo.versionCode and redirect the user to upgrade the app if required using getUpdateAppIntent.

    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.

    Источник

    Читайте также:  Видеорегистратор artway md 175 android 11 in 1 зеркало
    Оцените статью