Share Content Between Users

One of the most effective ways to get new users to install your app is by enabling your users to share content from your app with their friends. With Dynamic Links, you can create a great user-to-user sharing experience: users who receive content recommendations from their friends can click a link and be taken directly to the shared content in your app, even if they have to go to the App Store or Google Play Store to install your app first.

Key benefits

  • New users opening your app for the first time get a first-run experience that you customize for them. For example, you can display the content that was shared with them, or automatically connect them with the friend that invited them.
  • Makes it easy for users to share content with their friends across platforms and whether or not their friends have your app installed.

Here's how to get started!

Set up Firebase and the Dynamic Links SDK

Set up a new Firebase project and install the Dynamic Links SDK into your app. (iOS, Android, C++, Unity). Installing the Dynamic Links SDK allows Firebase to pass along data about the Dynamic Link to the app, including after the user installs the app. Without the SDK, there's no way to connect a post-install user with a pre-install click.

Create Dynamic Links

Now it's time to set up the links that users can send to their friends. Don't worry if your users' friends don't have the app installed yet; Dynamic Links can take care of that for you.

For each element of content you want to be shareable, generate a Dynamic Link.

When you create the Dynamic Link, you'll need to provide an HTTP or HTTPS URL as the link parameter that will be used to identify the content you're sharing. If you have a website with equivalent content, you should use your website's URLs. This will ensure that these links render correctly on a platform that doesn't support Dynamic Links, such as a desktop browser. For example:

You can also send a data payload—for example, to indicate that the link is intended for a particular person, such as in a game invitation—by adding URL-encoded parameters to the URL.

Before you share these links, you might want to use the Firebase Dynamic Links URL shortener API to generate friendlier-looking URLs. A short Dynamic Link looks like the following example:

Whatever you send the full link or a shortened link, when users open the Dynamic Link on their device, if the app specified by the apn parameter (on Android) or the ibi and isi parameters (on iOS) isn't installed, users are taken to the Play Store or App Store to install the app. Then, the app opens, and the URL specified in the link parameter is passed to it.

Add "Share" buttons that send Dynamic Links

Next, add "Share" buttons to your app's content that send Dynamic Links to your user's friends using the app of your user's choice. The recipient of the user's suggestion can open the Dynamic Link and see the shared content, possibly after installing the app first.


On iOS, your "Share" button might present a UIActivityViewController:


NSString *myDynamicLink = LINK_TO_SHARE;
NSString *msg = [NSString stringWithFormat:@"Hey, check this out: %@", myDynamicLink];
UIActivityViewController *shareSheet =
    [[UIActivityViewController alloc] initWithActivityItems:@[ msg ]
[shareSheet popoverPresentationController].sourceView = self.view
[self presentViewController:shareSheet animated:YES completion:nil];


let myDynamicLink = LINK_TO_SHARE;
let msg = "Hey, check this out: " + myDynamicLink
let shareSheet = UIActivityViewController(activityItems: [ msg ], applicationActivities: nil)
shareSheet.popoverPresentationController?.sourceView = self.view
self.presentViewController(shareSheet, animated: true, completion: nil)


On Android, your "Share" button starts an activity with the ACTION_SEND intent:

Intent sendIntent = new Intent();
String msg = "Hey, check this out: " + myDynamicLink;
sendIntent.putExtra(Intent.EXTRA_TEXT, msg);

Open the linked content in your app

Finally, you need to receive the link that's passed to your app so you can display the linked content to the recipient. This is easy using the Dynamic Links SDK:


On iOS, you receive the Dynamic Link by implementing the application:continueUserActivity:restorationHandler: method. In the restoration handler, you can get the Dynamic Link by calling handleUniversalLink:completion:. If a Dynamic Link was passed to your app, you can get it from the url property of the FIRDynamicLink. For example:


[[FIRDynamicLinks dynamicLinks]
             completion:^(FIRDynamicLink * _Nullable dynamicLink,
                          NSError * _Nullable error) {
      NSString *link = dynamicLink.url;
      BOOL strongMatch = dynamicLink.matchConfidence == FIRDynamicLinkMatchConfidenceStrong;
      // ...


FIRDynamicLinks.dynamicLinks()?.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
    let link = dynamicLink.url
    let strongMatch = dynamicLink.matchConfidence == FIRDynamicLinkMatchConfidenceStrong
    // ...

Additionally, you must call dynamicLinkFromCustomSchemeURL: in the application:openURL:options: method to receive Dynamic Links passed to your app as custom scheme URLs. For example:


FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
if (dynamicLink) {
  NSString *link = dynamicLink.url;
  BOOL strongMatch = dynamicLink.matchConfidence == FIRDynamicLinkMatchConfidenceStrong;
  // ...
  return YES;


let dynamicLink = FIRDynamicLinks.dynamicLinks()?.dynamicLinkFromCustomSchemeURL(url)
if let dynamicLink = dynamicLink {
  let link = dynamicLink.url
  let strongMatch = dynamicLink.matchConfidence == FIRDynamicLinkMatchConfidenceStrong
  // ...
  return true

Now that you have the value of the link parameter, you can display the linked content to the recipient, or process the data specified by the parameter in some other way. A URL-routing library such as JLRoutes can help with this task.

If you're receiving a link intended for a specific recipient, ensure that the Dynamic Link's match confidence is strong before running any user-specific logic.


On Android, you use the getInvitation() method to get data from the Dynamic Link:

        .addOnCompleteListener(new OnCompleteListener<PendingDynamicLinkData>() {
            public void onComplete(@NonNull Task<PendingDynamicLinkData> task) {
                if (!task.isSuccessful()) {
                    // Handle error
                    // ...

                FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(task.getResult());
                if (invite != null) {
                    // Handle invite
                    // ...

Then, in the callback, you can get the data passed in the Dynamic Links link parameter by calling the getDeepLink() method:

String link = AppInviteReferral.getDeepLink(intent);

Now that you have the value of the link parameter, you can display the linked content to the recipient, or process the data specified by the parameter in some other way. A URL-routing library can help with this task.

Send feedback about...

Need help? Visit our support page.