Create Dynamic Links on iOS

To create Firebase Dynamic Links, include the Dynamic Links SDK in your app and use the FIRDynamicLinkComponents.url parameter.


Firebase Dynamic Links requires iOS 8 or newer. You can target iOS 7 in your app, but Firebase Dynamic Links SDK calls only function on apps running iOS 8 or newer.

Set up Firebase and the Dynamic Links SDK

  1. Add Firebase to your iOS project. Include the following pod in your Podfile:
        pod 'Firebase/DynamicLinks'
  2. Run pod install and open the created .xcworkspace file.
  3. In the Firebase console, open the Dynamic Links section.
    1. Accept the terms of service if you are prompted to do so.
    2. Take note of your project's Dynamic Links domain, which is displayed at the top of the Dynamic Links page. You need your project's Dynamic Links domain to programmatically create Dynamic Links. A Dynamic Links domain looks like this:

  4. Ensure that your app's App Store ID and your App ID prefix is specified in your app's settings. To view and edit your app's settings, go to your Firebase project's Settings page and select your iOS app.

    Confirm that your Firebase project is properly configured to use Dynamic Links in your iOS app by opening the following URL:

    If your app is connected, the apple-app-site-association file contains a reference to your app's App Store ID and bundle ID. For example:


    If the details field is empty, double-check that you specified your App ID prefix. Note that your App ID prefix may not be the same as your Team ID.

Add Firebase to your app

  1. Import the Firebase module in your UIApplicationDelegate:


    import Firebase


    @import Firebase;
  2. Configure a FirebaseApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:


    // Use Firebase library to configure APIs


    // Use Firebase library to configure APIs
    [FIRApp configure];

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 to would be to visit the Firebase console and create one manually following the step-by-step form.

Use the iOS Builder API

You can create short or long Dynamic Links with the Firebase Dynamic Links iOS Builder API. This API accepts either a long Dynamic Link or an object containing Dynamic Link parameters, and returns a URL like the following example:

Create a long link from parameters

You can create a Dynamic Link programmatically by setting the following parameters and getting the FIRDynamicLinkComponents.url parameter.


// general link params
guard let linkString = dictionary[.link]?.text else {
  print("Link can not be empty!")

guard let link = URL(string: linkString) else { return }
let components = DynamicLinkComponents(link: link, domain: ViewController.DYNAMIC_LINK_DOMAIN)

// analytics params
let analyticsParams = DynamicLinkGoogleAnalyticsParameters(
    source: dictionary[.source]?.text ?? "", medium: dictionary[.medium]?.text ?? "",
    campaign: dictionary[.campaign]?.text ?? "")
analyticsParams.term = dictionary[.term]?.text
analyticsParams.content = dictionary[.content]?.text
components.analyticsParameters = analyticsParams

if let bundleID = dictionary[.bundleID]?.text {
  // iOS params
  let iOSParams = DynamicLinkIOSParameters(bundleID: bundleID)
  iOSParams.fallbackURL = dictionary[.fallbackURL]?.text.flatMap(URL.init)
  iOSParams.minimumAppVersion = dictionary[.minimumAppVersion]?.text
  iOSParams.customScheme = dictionary[.customScheme]?.text
  iOSParams.iPadBundleID = dictionary[.iPadBundleID]?.text
  iOSParams.iPadFallbackURL = dictionary[.iPadFallbackURL]?.text.flatMap(URL.init)
  iOSParams.appStoreID = dictionary[.appStoreID]?.text
  components.iOSParameters = iOSParams

  // iTunesConnect params
  let appStoreParams = DynamicLinkItunesConnectAnalyticsParameters()
  appStoreParams.affiliateToken = dictionary[.affiliateToken]?.text
  appStoreParams.campaignToken = dictionary[.campaignToken]?.text
  appStoreParams.providerToken = dictionary[.providerToken]?.text
  components.iTunesConnectParameters = appStoreParams

if let packageName = dictionary[.packageName]?.text {
  // Android params
  let androidParams = DynamicLinkAndroidParameters(packageName: packageName)
  androidParams.fallbackURL = dictionary[.androidFallbackURL]?.text.flatMap(URL.init)
  androidParams.minimumVersion = dictionary[.minimumVersion]?.text.flatMap {Int($0)} ?? 0
  components.androidParameters = androidParams

// social tag params
let socialParams = DynamicLinkSocialMetaTagParameters()
socialParams.title = dictionary[.title]?.text
socialParams.descriptionText = dictionary[.descriptionText]?.text
socialParams.imageURL = dictionary[.imageURL]?.text.flatMap(URL.init)
components.socialMetaTagParameters = socialParams

// OtherPlatform params
let otherPlatformParams = DynamicLinkOtherPlatformParameters()
otherPlatformParams.fallbackUrl = dictionary[.otherFallbackURL]?.text.flatMap(URL.init)
components.otherPlatformParameters = otherPlatformParams

longLink = components.url
print(longLink?.absoluteString ?? "")


// general link params
if (_dictionary[Link].text == nil) {
  NSLog(@"%@", @"Link can not be empty!");

NSURL *link = [NSURL URLWithString:_dictionary[Link].text];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link

// analytics params
FIRDynamicLinkGoogleAnalyticsParameters *analyticsParams =
[FIRDynamicLinkGoogleAnalyticsParameters parametersWithSource:_dictionary[Source].text
analyticsParams.term = _dictionary[Term].text;
analyticsParams.content = _dictionary[Content].text;
components.analyticsParameters = analyticsParams;

if (_dictionary[BundleID].text) {
  // iOS params
  FIRDynamicLinkIOSParameters *iOSParams = [FIRDynamicLinkIOSParameters parametersWithBundleID:_dictionary[BundleID].text];
  iOSParams.fallbackURL = [NSURL URLWithString:_dictionary[FallbackURL].text];
  iOSParams.minimumAppVersion = _dictionary[MinimumAppVersion].text;
  iOSParams.customScheme = _dictionary[CustomScheme].text;
  iOSParams.iPadBundleID = _dictionary[IPadBundleID].text;
  iOSParams.iPadFallbackURL = [NSURL URLWithString:_dictionary[IPadFallbackURL].text];
  iOSParams.appStoreID = _dictionary[AppStoreID].text;
  components.iOSParameters = iOSParams;

  // iTunesConnect params
  FIRDynamicLinkItunesConnectAnalyticsParameters *appStoreParams = [FIRDynamicLinkItunesConnectAnalyticsParameters parameters];
  appStoreParams.affiliateToken = _dictionary[AffiliateToken].text;
  appStoreParams.campaignToken = _dictionary[CampaignToken].text;
  appStoreParams.providerToken = _dictionary[ProviderToken].text;
  components.iTunesConnectParameters = appStoreParams;

if (_dictionary[PackageName].text) {
  // Android params
  FIRDynamicLinkAndroidParameters *androidParams = [FIRDynamicLinkAndroidParameters parametersWithPackageName: _dictionary[PackageName].text];
  androidParams.fallbackURL = [NSURL URLWithString:_dictionary[FallbackURL].text];
  androidParams.minimumVersion = (_dictionary[MinimumVersion].text).integerValue;
  components.androidParameters = androidParams;

// social tag params
FIRDynamicLinkSocialMetaTagParameters *socialParams = [FIRDynamicLinkSocialMetaTagParameters parameters];
socialParams.title = _dictionary[Title].text;
socialParams.descriptionText = _dictionary[DescriptionText].text;
socialParams.imageURL = [NSURL URLWithString:_dictionary[ImageURL].text];
components.socialMetaTagParameters = socialParams;

// OtherPlatform params
FIRDynamicLinkOtherPlatformParameters *otherPlatformParams =
[FIRDynamicLinkOtherPlatformParameters parameters];
otherPlatformParams.fallbackUrl = [NSURL URLWithString:_dictionary[OtherFallbackURL].text];
components.otherPlatformParameters = otherPlatformParams;

_longLink = components.url;
NSLog(@"Long URL: %@", _longLink.absoluteString);

Set the length of a short Dynamic Link

You can also set the pathLength parameter to specify how the path component of the short Dynamic Link is generated.


let options = DynamicLinkComponentsOptions()
options.pathLength = .unguessable
components.options = options


FIRDynamicLinkComponentsOptions *options = [FIRDynamicLinkComponentsOptions options];
options.pathLength = FIRShortDynamicLinkPathLengthUnguessable;
components.options = options;

By default, or if you set the parameter to "UNGUESSABLE", the path component will be a 17-character string, like in the following example:

Such strings are created by base62-encoding randomly generated 96-bit numbers. Use this setting to prevent your Dynamic Links URLs from being guessed and crawled, which can potentially expose sensitive information to unintended recipients.

If you set the parameter to "SHORT", the path component will be a string that is only as long as needed to be unique, with a minimum length of 4 characters.

Use this method if sensitive information would not be exposed if a short Dynamic Link URL were guessed.

Create a short link from a long link

You can use the Firebase Dynamic Links API to shorten a long Dynamic Link. To do so, call


components.shorten { (shortURL, warnings, error) in
  // Handle shortURL.
  if let error = error {
  self.shortLink = shortURL
  print(self.shortLink?.absoluteString ?? "")
  // ...


[components shortenWithCompletion:^(NSURL *_Nullable shortURL,
                                    NSArray *_Nullable warnings,
                                    NSError *_Nullable error) {
  // Handle shortURL or error.
  if (error) {
    NSLog(@"Error generating short link: %@", error.description);
  _shortLink = shortURL;
  NSLog(@"Short URL: %@", _shortLink.absoluteString);
  // ...

Specifying a custom URL scheme for Dynamic Links

By default, Dynamic Links uses your app's bundle identifier as the URL scheme needed to open up your application. We recommend staying with this default value to keep your implementation simple.

However, developers who are already using a custom URL scheme for other purposes may wish to use this same custom URL scheme for their Dynamic Links as well. If you are in this situation, you can specify a different URL scheme for your Firebase Dynamic Links by following these steps:

  1. When setting up your app, make sure you specify the default URL scheme to be used by your application before configuring your FirebaseApp shared instance:


    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      // Set deepLinkURLScheme to the custom URL scheme you defined in your
      // Xcode project.
      FirebaseOptions.defaultOptions()?.deepLinkURLScheme = self.customURLScheme
      return true


    - (BOOL)application:(UIApplication *)application
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      // Set deepLinkURLScheme to the custom URL scheme you defined in your
      // Xcode project.
      [FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME;
      [FIRApp configure];
      return YES;
  2. Whenever you create any Dynamic Link, you will need to specify the custom URL scheme that your app uses. You can do this through the Firebase console, setting the customScheme in the Builder API, specifying the ius parameter in your URL, or sending the iosCustomScheme parameter to the REST API

Next steps

Now that you've created Dynamic Links, you need to set up your app to receive Dynamic Links and send users to the right place in your app after a user opens them.

To receive Dynamic Links in your app, see the documentation for iOS, Android, C++, and Unity.

Send feedback about...

Need help? Visit our support page.