我的动态链接大部分都在工作,并且所有这些都是以编程方式完成的:
但是我想补充一点,如果用户没有安装我的应用程序,那么我希望将其重定向到App Store,以显示我的应用程序。
如何以编程方式添加?我知道我可以在链接前缀下创建一个动态链接,它将按照我想要的方式运行 - 但我想以编程方式进行,因为我已经以编程方式构造了链接的行为。
多谢你们。
这是我的代码,用户可以在其中共享其链接:
@IBAction func shareFirstButton(_ sender: UIButton) {
if let uid = Auth.auth().currentUser?.uid {
guard let link = URL(string: "https://www.testApp123.com/uid=" + uid) else {
return
}
let dynamicLinksDomain = "testApp123.page.link"
let linkBuilder = DynamicLinkComponents(link: link, domain: dynamicLinksDomain)
linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.burgertralla.myTestApp")
linkBuilder.shorten { (url, _, _) in
if let url = url {
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)
}
}
}
}
确保在应用程序的设置中指定了应用程序的App Store ID和App ID前缀。要查看和编辑应用的设置,请转到Firebase项目的“设置”页面,然后选择您的iOS应用。
通过打开动态链接域上托管的apple-app-site-association文件,确认您的Firebase项目已正确配置为在iOS应用中使用动态链接。例如:
https://example.page.link/apple-app-site-association
如果您的应用已连接,则apple-app-site-association文件包含对您应用的App Store ID和捆绑ID的引用。例如:
{"applinks":{"apps":[],"details":[{"appID":"1234567890.com.example.ios","paths":["/*"]}]}}
如果details属性为空,请仔细检查您是否指定了应用程序ID前缀。请注意,您的App ID前缀可能与您的团队ID不同。