我对DynamicLinks有问题。如果已安装该应用程序,则在iPhone上,动态链接会打开具有深层链接的iOS应用程序,并且一切正常。但是,如果未安装该应用程序,则不会显示在Apple App Store中该应用程序的页面,而是显示一个显示“找不到动态链接”的网页。

这是调试链接: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

这就是我配置整个事情的方式。
在Firebase项目设置中,我设置了App Store ID和Team ID:

ios - 未安装应用程序时,Firebase Dynamic Link会导致 "Dynamic Link not found"-LMLPHP

在“动态链接”设置中,我使用自定义域和一个子路径定义了一个新的URL前缀(我在域的根目录中有一个网站,该网站托管在Firebase Hosting上):

ios - 未安装应用程序时,Firebase Dynamic Link会导致 "Dynamic Link not found"-LMLPHP

有了这个我在https://nomadflare.com/apple-app-site-association上有以下内容:

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

然后在我的XCode项目中,我启用了“功能中的关联域”,并将第一个关联域设置为applinks:$(DYNAMIC_LINKS_DOMAIN),其中DYNAMIC_LINKS_DOMAIN是用户定义的build设置,取决于构建配置,但prod等于nomadflare.com

在“信息/URL类型”中,自定义URL方案为$(PRODUCT_BUNDLE_IDENTIFIER)(同样,取决于构建配置,但对于prod,它为com.nomadflare.NomadFlare

最后,在我的Swift代码中,我具有以下功能,当用户点击“共享”按钮时会触发该功能:

    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)
        }
    }

这是我的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>
WEBSITE_URL是另一个特定于构建配置的用户定义设置,其值在生产中为https://www.nomadflare.com

我真的不确定我在引荐链接的link部分中输入了什么。

最佳答案

您还必须在动态链接中设置应用程序的应用程序商店ID和iTunes参数。谢谢

关于ios - 未安装应用程序时,Firebase Dynamic Link会导致 "Dynamic Link not found",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57988757/

10-12 20:35