Firebase Dynamic Links give you a single link that can send users either to your iOS or Android app, if they have it installed, or to the appropriate listing in the App Store or on Google Play, if they don't. Even better than that, Dynamic Links will deep link your users to the content they were looking for, even if they had to install the app in the process.

We've been working hard over the last year to make this experience smoother and more powerful for both developers and users, and we're happy to bring the latest set of improvements to developers in our iOS and Android SDKs.

Creating Dynamic Links through the Firebase Console was great for promotional campaigns, but we heard from our developers that they needed to be able to create user-to-user sharing campaigns programmatically from within their app.

To help you do just that, we've added support for generating both long and short dynamic links to the iOS and Android Firebase SDKs, which makes it quicker and easier to support these kind of use cases:

iOS:

guard let deepLink = URL(string: "https://mydomain.com/page?param=value") else { return }

let components = DynamicLinkComponents(link: deepLink, domain: domain)

let iOSParams = DynamicLinkIOSParameters(bundleID: bundleID)
iOSParams.minimumAppVersion = minVersion
components.iOSParameters = iOSParams

// Build the dynamic link
let link = components.url

// Or create a shortened dynamic link 
components.shorten { (shortURL, warnings, error) in
      if let error = error {
        print(error.localizedDescription)
        return
      }
      
    // TODO: Handle shortURL.
    }

Android:

String deepLink = "https://mydomain.com/page?param=value";

DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance()
        .createDynamicLink()
        .setDynamicLinkDomain(domain)
        .setAndroidParameters(new DynamicLink.AndroidParameters.Builder()
                .setMinimumVersion(minVersion)
                .build())
        .setLink(deepLink);

// Build the dynamic link
DynamicLink link = builder.buildDynamicLink();

// Or create a shortened dynamic link 
builder.buildShortDynamicLink()
        .addOnSuccessListener(new OnSuccessListener() {
            @Override
            public void onSuccess(ShortDynamicLink shortDynamicLink) {
                // 
            }
        }); 

New Android API

We've also rebuilt the Android API from the ground up to make it easier to handle incoming Dynamic Links into your app, with the new FirebaseDynamicLinks class. You can add the new library by adding the following to your build.gradle:

compile "com.google.firebase:firebase-dynamic-links:11.0.0"

Then processing an incoming Dynamic Link is easy in your launched activity:

FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
  .addOnSuccessListener(
    new OnSuccessListener() {
      @Override
      public void onSuccess(PendingDynamicLinkData data) {
      if (data == null || data.getLink() == null) {
        // No FDL pending for this app, don't do anything.
        return;
      }

      Intent launchIntent = data.getUpdateAppIntent(MainActivity.this);
      if (launchIntent != null) {
        startActivity(launchIntent); // launch upgrade flow.
      }

     Uri deepLink = dynamicLink.getLink();
     String myAppItemId = deepLink.getQueryParameter("myAppItemId");
     // TODO(developer): Display content for myAppItemId here! 
    }
});  

As always, if you have any questions or feedback on the new API, please reach out through any of the channels on our support page.