简体   繁体   English

当动态链接具有自定义子域时,Firebase动态链接无法在iOS上运行

[英]Firebase dynamic links are not working on iOS when the dynamic link has the custom subdomain

I have integrated firebase dynamic links in my app as per the guidelines mentioned in source1 , source2 . 我在我的应用程序集成火力动态链接按中提到的准则来源1源2 Everything is working as expected on the app for the default domains. 一切都在默认域的应用程序上按预期工作。

But when I create a custom subdomain on firebase console and use it on the iOS device it's not working as expected(Even when the app is installed). 但是当我在firebase控制台上创建一个自定义子域并在iOS设备上使用它时,它没有按预期工作(即使安装了应用程序)。 I have added the new subdomain like applinks:example.page.link on Capabilities=>Associated Domains on my Xcode project. 我在我的Xcode项目的Capabilities => Associated Domains上添加了新的子域名,如applinks:example.page.link

Below is the straight scenario: 以下是直线情景:

1) App is installed on the device. 1)应用程序安装在设备上。

2) Tapped on the dynamic link(with custom subdomain) https://example.page.link/abcXYZ on email. 2)在电子邮件上点击动态链接(使用自定义子域) https://example.page.link/abcXYZ

3) It directly opened the app and linkHandled on my following code is always false and completion from handleUniversalLink function is never called. 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
  }

But for the default domains created by firebase like https://my328.app.goo.gl/abcXYZ are working fine, linkHandled is always true, completion from handleUniversalLink is called and I'm receiving the expected Deep link (which is configured on firebase console) on completion . 但是对于linkHandled创建的默认域(如https://my328.app.goo.gl/abcXYZ)工作正常, linkHandled始终为true,调用handleUniversalLink completion并且我收到了预期的Deep link (在firebase控制台) completion

Any thoughts on why Firebase dynamic links are not working on the app for custom subdomains? 有关为什么Firebase动态链接无法在自定义子域的应用程序上运行的任何想法? Do I need to configure anything additional than mentioned on the link for custom subdomains? 我是否需要配置自定义子域名链接上提到的其他内容?

It's because I was using FirebaseDynamicLinks 1.4.0 which is old. 这是因为我使用的FirebaseDynamicLinks 1.4.0已经过时了。 When I update to FDL library 3.0.1, dynamic links with custom subdomain are working fine in the app. 当我更新到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. 我之所以认为我使用最新的FDL库并且无法确定我使用的是旧的FDL库,是因为CocoaPods(iOS项目的依赖管理器, 阅读更多 )无法获得最新版本的FirebaseDynamicLinks for某些原因,无论我喜欢从Pod文件中删除并重新安装FirebaseDynamicLinks或运行pod update命令。 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. 因此,我从pod文件中删除了FirebaseDynamicLinks并运行命令pod install,它从我的项目中删除了该库,现在我从firebase控制台下载了FirebaseDynamicLinks框架并将其手动集成到我的项目中。 Now with the new FirebaseDynamicLinks SDK, dynamic links with custom subdomain are working fine in the app. 现在有了新的FirebaseDynamicLinks SDK,带有自定义子域的动态链接在应用程序中运行良好。

If custom domain not working and Google domain working then you need to add FirebaseDynamicLinksCustomDomains key to the info.plist for iOS 如果自定义域无效且Google域正常运行,则需要将FirebaseDynamicLinksCustomDomains键添加到适用于iOS的info.plist

<key>FirebaseDynamicLinksCustomDomains</key>
<array>
  <string>https://custom-domain.com</string>
</array>

Ref: https://firebase.google.com/docs/dynamic-links/custom-domains 参考: https//firebase.google.com/docs/dynamic-links/custom-domains

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM