Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Dynamic Link leads to "Dynamic Link not found" when app not installed

I have a problem with DynamicLinks. If the app is installed, on an iPhone, the dynamic link opens the iOS app with the deep link and everything works fine. But if the app is not installed, instead of showing the app’s page in the Apple App Store, it shows a web page that says “Dynamic link not found”.

Here is the debug link: https://www.nomadflare.com/app/?ibi=com%2Enomadflare%2ENomadFlare&imv=1%2E0&ofl=https%3A%2F%2Fwww%2Enomadflare%2Ecom&link=https%3A%2F%2Fnomadflare%2Ecom%2Fapp%2F%3Finvitedby%3DdZ3I3pK0KzcOGhO8AoVbBnn8XsO2&d=1

And here is how I configured the whole thing. In my Firebase project settings, I set the App Store ID and the Team ID:

Project settings in Firebase console

In my Dynamic Links settings, I defined a new URL prefix with my custom domain and a subpath (I have a website at the root of my domain, hosted on Firebase Hosting):

Dynamic Links settings

With that I have the following on https://nomadflare.com/apple-app-site-association:

{"applinks":{"apps":[],"details":[{"appID":"HLAKBN9F84.com.nomadflare.NomadFlare","paths":["NOT /_/*","/*"]}]}}

Then in my XCode project, I enabled Associated Domains in Capabilities, and set a first associated domain to applinks:$(DYNAMIC_LINKS_DOMAIN), where DYNAMIC_LINKS_DOMAIN is a user-defined build setting that depends on the build configuration, but for prod is equal to nomadflare.com.

In Info/URL Types, the custom URL scheme is $(PRODUCT_BUNDLE_IDENTIFIER) (again, depends on the build configuration, but for prod it's com.nomadflare.NomadFlare.

And finally in my Swift code, I have the following function that is triggered when the user taps a Share button:

    func share() {
        guard let uid = Session.shared.authenticatedUser?.id else {
            return
        }

        guard let customDomains = Bundle.main.object(forInfoDictionaryKey: "FirebaseDynamicLinksCustomDomains") as? [String],
            let bundleIdentifier = Bundle.main.bundleIdentifier,
            let websiteUrlString = Bundle.main.object(forInfoDictionaryKey: "WebsiteUrl") as? String,
            let websiteUrl = URL(string: websiteUrlString),
            let appStoreID = Bundle.main.object(forInfoDictionaryKey: "AppStoreID") as? String else {
            return
        }

        let urlBase = customDomains[0]
        let link = URL(string: "\(urlBase)/?invitedby=\(uid)")
        let referralLink = DynamicLinkComponents(link: link!, domainURIPrefix: urlBase)

        referralLink?.iOSParameters = DynamicLinkIOSParameters(bundleID: bundleIdentifier)
        referralLink?.iOSParameters?.minimumAppVersion = "1.0.0"
        referralLink?.iOSParameters?.appStoreID = appStoreID

        referralLink?.otherPlatformParameters = DynamicLinkOtherPlatformParameters()
        referralLink?.otherPlatformParameters?.fallbackUrl = websiteUrl

        KRProgressHUD.show()
        referralLink?.shorten { (shortURL, warnings, error) in
            KRProgressHUD.dismiss()
            if let error = error {
                print(error.localizedDescription)
                return
            }
            let invitationUrl = shortURL
            let text = NSLocalizedString("Check out NomadFlare. It's a dating app for travellers and digital nomads.", comment: "")
            let shareAll = [text, invitationUrl!] as [Any]
            let activityViewController = UIActivityViewController(activityItems: shareAll, applicationActivities: nil)
            activityViewController.popoverPresentationController?.sourceView = self.view
            self.present(activityViewController, animated: true, completion: nil)
        }
    }

And here are the relevant keys in my Info.plist:

<key>FirebaseDynamicLinksCustomDomains</key>
<array>
    <string>https://$(DYNAMIC_LINKS_DOMAIN)/app</string>
</array>
<key>LSApplicationQueriesSchemes</key>
<key>WebsiteUrl</key>
<string>$(WEBSITE_URL)</string>
<key>AppStoreID</key>
<string>1474350816</string>

And WEBSITE_URL is yet another build-config-specific user-defined setting, whose value is https://www.nomadflare.com in production.

I'm really not sure about what I put in the link part of my referral link though.

like image 203
Sebastien Avatar asked Sep 18 '19 08:09

Sebastien


People also ask

What does it mean dynamic link not found?

Dynamic Link Server not being available is usually a permissions or security issue, So would you please turn off your security tool if you have any and then try to use it.

How does Firebase dynamic links work?

Dynamic Links are smart URLs that allow you to send existing and potential users to any location within your iOS or Android app. They survive the app install process, so even new users see the content they're looking for when they open the app for the first time. Dynamic Links are no-cost forever, for any scale.

Do Firebase dynamic links expire?

The created short Dynamic Link will not expire. Repeated calls with the same long Dynamic Link or Dynamic Link information will produce the same short Dynamic Link. The Dynamic Link domain in the request must be owned by requester's Firebase project.

Do Firebase dynamic links work on iOS?

In the Firebase console, open the Dynamic Links section. Accept the terms of service if you are prompted to do so. 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.


1 Answers

You also have to set the app store id of your app and iTunes parameter in dynamic link .Thank you

like image 130
Saifullah ilyas Avatar answered Nov 15 '22 09:11

Saifullah ilyas