iOS Dynamic Link Builder explanation?

firebase, firebase-dynamic-links

Solution

The Firebase Dynamic Links documentation is really awful. I understood how it works by diving into the Firebase public API.

P.S here is the whole starter project where this snippet is cut from.

Explanation of the important fields

The link is a URL object containing the link you want to pass through with the parameters. Watch for more information.

The domain is a string containing your dynamic linking domain that can be found in the firebase console. (It's the link with app.goo.gl)

bundleID is your application's bundle id. It can be found in your Xcode project.

fallback urls are set only if you want a custom URL to be opened when the app is not installed instead of the app store page.

minimum app version From the API documentation:

The the minimum version of your app that can open the link. If the installed app is an older version, the user is taken to the AppStore to upgrade the app. Note: It is app's developer responsibility to open AppStore when received link declares higher minimunAppVersion than currently installed.

custom scheme Quoting the API documentation again:

The target app's custom URL scheme, if defined to be something other than the app's bundle ID.

iPad bundle id and iPad fallback URL are set if you have a different application for the iPad.

All of the appStoreParams should be found in your itunes connect page.

Set the androidParams if you also have an Android app.

Also, this part was very vague in the documentation:

FIROptions.default().deepLinkURLScheme 

This field should be set to the scheme you set in the Xcode project in the Info section under URL Types.

Problem

I'm trying to figure out how to use Firebase's Dynamic Links for iOS to send custom deeplinks to people from my iOS application. However, the documentation doesn't have any comments and I'm a bit confused as to what the long piece of code given under Create a long link from parameters does. There's about 30 lines in a row without a single comment. ``` guard let linkString = dictionary[.link]?.text else { return } guard let link = URL(string: linkString) else { return } guard let domain = dictionary[.domain]?.text else { return } let components = FIRDynamicLinkComponents(link: link, domain: domain) let analyticsParams = FIRDynamicLinkGoogleAnalyticsParameters( 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 = FIRDynamicLinkIOSParameters(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 = FIRDynamicLinkItunesConnectAnalyticsParameters() 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 = FIRDynamicLinkAndroidParameters(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 = FIRDynamicLinkSocialMetaTagParameters() 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 ?? "") ``` Where exactly this `dictionary` at the top is coming from and what do the other parts accomplish?

Original source