我在多个iOS应用程序中集成了Firebase Dynamic链接,这些链接在同一个firebase项目中,并且运行良好。但是,当我将两个应用程序安装在同一设备上时,动态链接未在设备上打开特定的应用程序。因此,我使用根目录中的自定义apple-app-site-association向firebase注册了一个自定义子域。但是我仍然遇到同样的问题。我想生成短动态链接,例如
https://apps.mybrand.co.id/partner/xXXx
公用文件夹中的文件
apple-app-site-association
{
"applinks": {
"apps": [],
"details": [
{
"appID": "XXXXX.com.XXXX.Customer",
"paths":[ "/customer/", "/brand/"]
},
{
"appID": "XXXXX.com.XXXX.Partner",
"paths": ["/partner/"]
}
]
}
}
Firebase.json
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"appAssociation": "AUTO",
"rewrites": [
{
"source": "/**",
"dynamicLinks": true
}
],
"headers": [
{
"source": "apple-app-site-association",
"headers": [{"key": "Content-Type", "value": "application/json"}]
}
]
}
}
我正在使用以下代码来生成链接
//在Firebase上注册的自定义域 让dynamicLink =“ apps.mybrand.co.id”
//create link url components
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = dynamicLink
urlComponents.path = "/data"
let queryItem = URLQueryItem(name: "myBrandReferCode", value: "60C38A")
urlComponents.queryItems = [queryItem]
// get the url from url component
guard let linkParameter = urlComponents.url else {
return
}
//print the url string for debugging
print("I am sharing \(linkParameter.absoluteString)")
// create dynamic link components with custom domain
guard let shareLink = DynamicLinkComponents.init(link: linkParameter, domainURIPrefix: "https://apps.mybrand.co.id/partner") else {
print("Unable to create FDL component.")
return
}
shareLink.iOSParameters = DynamicLinkIOSParameters(bundleID: "com.ranosys.DFM-BM")
//temporary app id of another app, same in firebase console app settings
shareLink.iOSParameters?.appStoreID = "359085099"
//call shorten method to get short dynamic link
shareLink.shorten { (shortURL, warnings, error) in
for warning in warnings ?? [String]() {
print(warning)
}
//remove wait view from the button
self.shareCodeButton.removeWaitView()
//if there is any error, print it
if let error = error {
print(error.localizedDescription)
return
}
//if dynamic link is successfully shortened
if let shortLink = shortURL {
//show the activity controller
self.showActivityCoontroller(shortLink)
}
}
但是我收到The operation couldn’t be completed. Your project does not own Dynamic Links domain: https://apps.mybrand.co.id
答案 0 :(得分:0)
考虑尝试以下两个修复程序:
yarn
文件应位于npm
目录下(注意点)。apple-app-site-association
文件。该文件可能会干扰自定义域验证