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, verify that you specified your Team ID.

Add Firebase to your app

  1. Import the Firebase module:


    @import Firebase;


    import Firebase
  2. Then, in the didFinishLaunchingWithOptions: method, configure a FirebaseApp shared instance:


    - (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;


    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

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.


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

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

if (_dictionary[BundleID].text) {
  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;

  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) {
  FIRDynamicLinkAndroidParameters *androidParams = [FIRDynamicLinkAndroidParameters parametersWithPackageName: _dictionary[PackageName].text];
  androidParams.fallbackURL = [NSURL URLWithString:_dictionary[FallbackURL].text];
  androidParams.minimumVersion = (_dictionary[MinimumVersion].text).integerValue;
  components.androidParameters = androidParams;

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

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


  fatalError("Please update DYNAMIC_LINK_DOMAIN constant in your code from Firebase Console!")
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)

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 {
  let iOSParams = DynamicLinkIOSParameters(bundleID: bundleID)
  if let fallbackURL = dictionary[.fallbackURL]?.text {
    iOSParams.fallbackURL = URL(string: fallbackURL)
  iOSParams.minimumAppVersion = dictionary[.minimumAppVersion]?.text
  iOSParams.customScheme = dictionary[.customScheme]?.text
  iOSParams.iPadBundleID = dictionary[.iPadBundleID]?.text
  if let iPadFallbackURL = dictionary[.iPadFallbackURL]?.text {
    iOSParams.iPadFallbackURL = URL(string: iPadFallbackURL)
  iOSParams.appStoreID = dictionary[.appStoreID]?.text
  components.iOSParameters = iOSParams

  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 {
  let androidParams = DynamicLinkAndroidParameters(packageName: packageName)
  if let androidFallbackURL = dictionary[.androidFallbackURL]?.text {
    androidParams.fallbackURL = URL(string: androidFallbackURL)
  if let minimumVersion = dictionary[.minimumVersion]?.text, let intVersion = Int(minimumVersion) {
    androidParams.minimumVersion = intVersion
  components.androidParameters = androidParams

let socialParams = DynamicLinkSocialMetaTagParameters()
socialParams.title = dictionary[.title]?.text
socialParams.descriptionText = dictionary[.descriptionText]?.text
if let imageURL = dictionary[.imageURL]?.text {
  socialParams.imageURL = URL(string: imageURL)
components.socialMetaTagParameters = socialParams

longLink = components.url
print(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.


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


let options = DynamicLinkComponentsOptions()
options.pathLength = .unguessable
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 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);
  // ...


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

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.