I had integrated Firebase Dynamic links in multiple iOS apps, which is in the same firebase project and it was working fine. But when I installed both apps on same device, the dynamic links were not opening specific app on the device. So, I registered a custom subdomain with firebase with a custom apple-app-site-association in the root directory. But still I am having the same issue. I want to generate short dynamic link like
https://apps.mybrand.co.id/partner/xXXx
Files in public folder
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"}]
}
]
}
}
I am using the following code to generate link
//custom domain registred on firebase let 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)
}
}
But I am getting error that The operation couldn’t be completed. Your project does not own Dynamic Links domain: https://apps.mybrand.co.id