keepcalculator

06 Numbers and Powers

Deferred Deep Links React Native Firebase Complete Guide

Card No. 06·82319 · Updated · Standard formula, shown below

Deferred deep links in React Native let you send a user to a specific screen in your app even if the app isn’t installed yet, by remembering the link and opening it right after the first launch. This guide explains how to set them up with Firebase Dynamic Links (now part of Firebase App Links), what the limitations are, and how to handle them correctly in both iOS and Android.

What Are Deferred Deep Links and Why They Matter

A normal deep link only works if the app is already installed. If a user taps a link on a mobile browser and the app is missing, they get a 404 or the App Store page. A deferred deep link solves this by storing the destination URL on a server, then delivering it to the app the first time it opens after installation. This is the standard pattern for referral campaigns, invite flows, and onboarding that expects the user to take a specific action.

For example, a friend sends you a link to a specific product in a shopping app. You don’t have the app, so you see the store listing. After you install and open it, the app should show that product, not the home screen. The deferred link makes that possible by persisting the link data on Firebase’s servers until the app calls for it.

How Firebase Dynamic Links Handle Deferred Links

Firebase Dynamic Links (FDL) are managed links that live under your own domain (like your.page.link). When a user taps one, Firebase checks whether your app is installed using the iOS Universal Links or Android App Links mechanism. If it is installed, the link opens the app directly. If not, the user is sent to the App Store or Play Store. The key part is that the link data is stored on Firebase’s servers, and when the app first launches, it retrieves that stored link and passes it to your code.

This works because the dynamic link itself contains a unique identifier. When the app opens for the first time, the Firebase SDK calls the getInitialLink() method (or the equivalent in the React Native wrapper) to fetch the pending link. The SDK then deletes it from the server so it doesn’t fire again on the next launch.

Complete Integration Steps for React Native

Here is the step-by-step process for adding deferred deep link support to a React Native app using Firebase Dynamic Links. The setup assumes you already have a Firebase project and a React Native project (0.60 or newer, with autolinking).

  1. Install the library: Run npm install @react-native-firebase/app @react-native-firebase/dynamic-links (or yarn add). For iOS, run pod install in the ios folder.
  2. Create a Dynamic Link in the Firebase Console: Go to Dynamic Links in your Firebase project, create a link with your own domain or the default yourproject.page.link. Set the deep link URL to a custom scheme or universal link that your app handles (e.g., myapp://product/123). For deferred behavior, make sure the link is set to “Open the deep link in your app” and that the iOS and Android bundle IDs are correct.
  3. Configure iOS: In Xcode, add the associated domain for your dynamic link domain (e.g., applinks:yourproject.page.link). Also add the custom URL scheme to Info.plist if you use one. The Firebase SDK will register the dynamic link domain automatically, but you need to ensure your app is set to handle Universal Links.
  4. Configure Android: Add the dynamic link domain to your AndroidManifest.xml inside an intent filter for the VIEW action, as per Firebase docs. Also add the com.google.firebase.dynamiclinks.DYNAMIC_LINK_DOMAIN meta-data tag with your domain.
  5. Handle the link in JavaScript: Use the dynamicLinks().getInitialLink() method to get the link that opened the app (this is the deferred link after a fresh install). Also subscribe to dynamicLinks().onLink() to handle links that arrive while the app is running.
  6. Test the deferred flow: Use the Firebase console to send a test link to a device that doesn’t have the app. Install the app from the store (or via a development build) and check that the getInitialLink() returns the correct URL.

Handling the Link in Your React Native Code

Once you have the link, you need to parse it and navigate to the right screen. The getInitialLink() returns a DynamicLink object with a url property. That URL is the deep link you set (e.g., myapp://product/123). You can parse it with a library like query-string or a custom parser.

Here is a typical pattern:

import dynamicLinks from '@react-native-firebase/dynamic-links';

async function handleInitialLink() {
  const link = await dynamicLinks().getInitialLink();
  if (link) {
    // e.g., link.url = 'myapp://product/123'
    navigateToScreen(link.url);
  }
}

For the onLink subscription, you need to add the listener in a useEffect and remove it on unmount. The key point is that getInitialLink only returns a link once, and it is the deferred link if the app was just installed.

Common Problems and How to Fix Them

  • Deferred link not firing on iOS: The most common cause is that the associated domain is not set correctly, or the app is not configured to handle Universal Links. Double-check that the apple-app-site-association file is being served by Firebase (it is automatic) and that the bundle ID matches.
  • Link opens the App Store instead of the app after installation: This often happens when the dynamic link is not marked as “deferred” in the console. In the Firebase console, under “Advanced options”, make sure “Link is a deferred deep link” is checked. Without that, the link is not stored for later.
  • getInitialLink returns null on Android: If the app was already running (e.g., the user opened it from the recent apps), the link may be handled by onLink instead. Also, ensure you have the correct intent filter and that the dynamic link domain is added to the manifest.
  • Link works only after a cold start: That is expected. Deferred links only fire on a cold start after installation. For subsequent opens, use onLink.
  • Testing on iOS simulator: Deferred links do not work on simulators because the App Store is not available. Use a physical device.

Comparing Firebase Dynamic Links with Alternatives

Firebase Dynamic Links are the most popular solution because they are free and deeply integrated with Firebase Analytics. However, they have been deprecated by Google in favor of Firebase App Links (the underlying technology), and there are third-party alternatives like Branch, AppsFlyer, and Adjust that offer more advanced attribution features (e.g., tracking installs from specific ad campaigns).

If you only need simple deferred deep linking without attribution, Firebase is sufficient. If you need to measure marketing campaigns, you might want a dedicated platform. The integration with React Native is similar for all of them, but the SDKs differ.

Cost and Limitations

Firebase Dynamic Links are free, but they are subject to Firebase’s project quotas. The main limitation is that they are being deprecated: Google has announced that Dynamic Links will be shut down in 2025, and existing links will stop working. This is a critical consideration for new projects. You should plan to migrate to Firebase App Links or a third-party service.

Another limitation is that deferred links only work if the app is installed from the store (not from a development build). For testing, you need to use a production build or a TestFlight build.

Frequently Asked Questions

What is the difference between a deep link and a deferred deep link?

A deep link opens a specific screen in an already-installed app. A deferred deep link does the same but also works when the app is not installed: it stores the link and delivers it after the first launch.

How do I test a deferred deep link in development?

You cannot test the full deferred flow on a simulator. Use a physical device, build a release or TestFlight version, and tap a link that points to the App Store or Play Store. After installing, the app should receive the link via getInitialLink().

Can I use deferred deep links with React Native Navigation?

Yes. After getting the link, you can use any navigation library (React Navigation, etc.) to navigate to the screen based on the URL. The key is to call getInitialLink() before the navigation container renders, or store the link and process it after mount.

Why does my dynamic link not work after the app is updated?

If the app is already installed, the link should open directly via onLink. If it doesn’t, check that the app’s associated domains are still configured, and that the dynamic link is not expired.

Is Firebase Dynamic Links still supported?

As of 2024, Firebase Dynamic Links are in maintenance mode and will be shut down in 2025. Google recommends migrating to Firebase App Links or using a third-party service. Existing links will stop working after the shutdown.

What should I use instead of Firebase Dynamic Links?

For simple deferred deep linking, you can use the native Universal Links (iOS) and App Links (Android) with a custom server that stores the link. For attribution and campaign tracking, consider Branch, AppsFlyer, or Adjust.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →