Firebase Deep Link Web URL 查询为空 - iOS

Firebase Deep Link Web URL query is empty - iOS

我在接收带有新自定义 URL 的 Firebase 动态链接时遇到问题。我创建了一个 "abc0.page.link",我设置了所有内容以在应用程序的代码中创建它。

但是在接收时,我在 LOG 中收到此消息:

[Firebase/Analytics][I-ACS023000] Deep Link Web URL query is empty

没有任何反应,handled 为 false。

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:
 #if defined(__IPHONE_12_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0)
(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler {
#else
    (nonnull void (^)(NSArray *_Nullable))restorationHandler {
#endif  // __IPHONE_12_0
 //(void (^)(NSArray *))restorationHandler {

    NSLog(@"continueUserActivity called, withUser: %@, useractivity: %@, webpageurl: %@", self.user.uid, userActivity, userActivity.webpageURL);
  calledFromURL = YES;
  BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
                                                          completion:^(FIRDynamicLink * _Nullable dynamicLink,
                                                                       NSError * _Nullable error) {
        NSLog(@"continueUserActivity called");
        if (error) {
            NSLog(@"dynamic link error: %@", error.localizedDescription);
animated:YES completion:nil];
            }
            else {
}
}];
return handled;
}

这里有什么问题?提前致谢!

我在动态链接方面遇到了完全相同的问题。 我在我的 Podfile 中使用了这些行:

pod 'Firebase/DynamicLinks'
pod 'Firebase/Analytics'

就像订购的官方 Firebase 教程一样。

但是,我的应用程序当时仍然使用 pod 'Google/Analytics' pod,该 pod 已被弃用,应切换到 Firebase Analytics。

这个 Google analytics pod 与来自 Firebase 的 Pods 有一个共同的依赖关系(如果我没记错的话,"Firebase/Core")但是因为它是一个旧的,不推荐使用的版本,它的依赖关系是要求低于某个版本。 因此,即使我没有在我的 Podfile 中指定 DynamicLinks pod 版本,旧的依赖项只允许它达到某个版本,比 up-to-date 版本旧得多。当我尝试按照文档中的建议使用 self-diagnostic 工具 [0] 时,我发现了这一点,但我的代码找不到该工具。

所以我使用的解决方法是:

  • 从我的 Podfile 中删除 Google/Analytics pod。当我这样做并执行 pod update 时,所有与 Firebase 相关的 pods 都与 CocoaPods 网站 [1] 中的版本相同,即它们是 up-to-date.

  • 我仍然想使用旧的 Google Analytics 一段时间,因为我需要动态链接比切换到 Firebase Analytics 更快地工作,所以我 手动导入 Google Analytics (libGoogleAnalytics.a) 及其 headers 的静态库。那时它工作得很好。因为它不再在 Podfile 中,所以我不会自动获取更改,但是,我认为这不会成为已弃用的 Pod 的问题。

如果您的问题确实与此相关,我认为这不是建议的解决方案。您应该尽快使用 Firebase Analytics,因为 Google 移动版 Analytics 将于今年 10 月关闭。

我的猜测是 Firebase 函数曾经有不同的解析和翻译动态链接的方式,这些方式与今天控制台创建的链接不兼容,所以它 returns 是一个空的 URL查询。

[0]- https://firebase.google.com/docs/dynamic-links/debug

[1]- https://cocoapods.org/

您必须在 info.plist

中设置 FirebaseDynamicLinksCustomDomains

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

将这些行添加到您的 Info.plist 并确保 URL 必须没有前缀。例如您的 url 是 https://example.com/profile then you should use https://example.com

<key>FirebaseDynamicLinksCustomDomains</key>
    <array>
      <string>https://example.com</string>
    </array>

https://blog.devgenius.io/firebase-flutter-dynamic-links-step-by-step-guide-630402ee729b