当动态 link 具有自定义子域时,Firebase 动态 link 无法在 iOS 上运行
Firebase dynamic links are not working on iOS when the dynamic link has the custom subdomain
我按照 source1, source2 中提到的指南在我的应用程序中集成了 firebase 动态 link。默认域的应用程序上的一切都按预期工作。
但是当我在 firebase 控制台上创建一个 并在 iOS 设备上使用它时,它没有按预期工作(即使安装了该应用程序)。我在我的 Xcode 项目。
下面是直接的场景:
1) 应用已安装在设备上。
2) 在电子邮件中点击动态 link(带有自定义子域)https://example.page.link/abcXYZ。
3) 它直接打开了应用程序,我的以下代码中的 linkHandled
始终是 false
并且从未调用 handleUniversalLink
函数中的 completion
。
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if let incomingURL = userActivity.webpageURL {
let linkHandled = FIRDynamicLinks.dynamicLinks()?.handleUniversalLink(incomingURL, completion: { (dynamiclink, error) in
if let dynamiclink = dynamiclink, let _ = dynamiclink.url {
self.handleIncomingDynamicLink(dynamiclink: dynamiclink)
}
})
return linkHandled
}
return false
}
但是对于由 firebase 创建的默认域,如 https://my328.app.goo.gl/abcXYZ 工作正常,linkHandled
始终为真,handleUniversalLink
中的 completion
被调用并且我正在接收completion
.
上的预期 Deep link
(在 firebase 控制台上配置)
关于为什么 Firebase 动态 link 无法在自定义子域的应用程序上运行的任何想法?我是否需要为自定义子域配置 link 中未提到的任何其他内容?
这是因为我使用的是旧的 FirebaseDynamicLinks 1.4.0。当我更新到 FDL 库 3.0.1 时,带有自定义子域的动态链接在应用程序中工作正常。
The reason why I believed that I was using the latest FDL library and
couldn't identify that I was using old FDL library is, CocoaPods(a
dependency manager for iOS projects, read more) couldn't get me
the latest version of FirebaseDynamicLinks for some reason, no matter
what I do like remove and reinstall FirebaseDynamicLinks from Pod file
or run pod update command. So, I have removed FirebaseDynamicLinks
from pod file and ran the command pod install, it removed that library
from my project and now I have downloaded FirebaseDynamicLinks
framework from firebase console and integrated it manually on my
project. Now with the new FirebaseDynamicLinks SDK, dynamic links with
custom subdomain are working fine in the app.
如果 custom 域不工作而 Google 域工作那么你需要添加 FirebaseDynamicLinksCustomDomains info.plist 键 iOS
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://custom-domain.com</string>
</array>
Ref: https://firebase.google.com/docs/dynamic-links/custom-domains
我按照 source1, source2 中提到的指南在我的应用程序中集成了 firebase 动态 link。默认域的应用程序上的一切都按预期工作。
但是当我在 firebase 控制台上创建一个
下面是直接的场景:
1) 应用已安装在设备上。
2) 在电子邮件中点击动态 link(带有自定义子域)https://example.page.link/abcXYZ。
3) 它直接打开了应用程序,我的以下代码中的 linkHandled
始终是 false
并且从未调用 handleUniversalLink
函数中的 completion
。
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if let incomingURL = userActivity.webpageURL {
let linkHandled = FIRDynamicLinks.dynamicLinks()?.handleUniversalLink(incomingURL, completion: { (dynamiclink, error) in
if let dynamiclink = dynamiclink, let _ = dynamiclink.url {
self.handleIncomingDynamicLink(dynamiclink: dynamiclink)
}
})
return linkHandled
}
return false
}
但是对于由 firebase 创建的默认域,如 https://my328.app.goo.gl/abcXYZ 工作正常,linkHandled
始终为真,handleUniversalLink
中的 completion
被调用并且我正在接收completion
.
Deep link
(在 firebase 控制台上配置)
关于为什么 Firebase 动态 link 无法在自定义子域的应用程序上运行的任何想法?我是否需要为自定义子域配置 link 中未提到的任何其他内容?
这是因为我使用的是旧的 FirebaseDynamicLinks 1.4.0。当我更新到 FDL 库 3.0.1 时,带有自定义子域的动态链接在应用程序中工作正常。
The reason why I believed that I was using the latest FDL library and couldn't identify that I was using old FDL library is, CocoaPods(a dependency manager for iOS projects, read more) couldn't get me the latest version of FirebaseDynamicLinks for some reason, no matter what I do like remove and reinstall FirebaseDynamicLinks from Pod file or run pod update command. So, I have removed FirebaseDynamicLinks from pod file and ran the command pod install, it removed that library from my project and now I have downloaded FirebaseDynamicLinks framework from firebase console and integrated it manually on my project. Now with the new FirebaseDynamicLinks SDK, dynamic links with custom subdomain are working fine in the app.
如果 custom 域不工作而 Google 域工作那么你需要添加 FirebaseDynamicLinksCustomDomains info.plist 键 iOS
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://custom-domain.com</string>
</array>
Ref: https://firebase.google.com/docs/dynamic-links/custom-domains