我对DynamicLinks有问题。如果已安装该应用程序,则在iPhone上,动态链接会打开带有深层链接的iOS应用程序,并且一切正常。但是,如果未安装该应用程序,则不会显示在Apple App Store中该应用程序的页面,而是显示一个显示“找不到动态链接”的网页。
这是我配置整个事情的方式。 在Firebase项目设置中,我设置了App Store ID和Team ID:
在“动态链接”设置中,我定义了带有自定义域和子路径的新URL前缀(我在域的根目录中有一个网站,托管在Firebase托管上)
因此,我在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是用户定义的构建设置,取决于构建配置,但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
部分中输入的内容。
答案 0 :(得分:1)
还必须在动态链接中设置应用程序的应用商店ID和iTunes参数。谢谢