当应用程序不在后台时无法识别 Firebase Dynamic Link (iOS)

Firebase Dynamic Link not recognized when app not in background (iOS)

当应用程序处于后台模式时(已安装并启动一次),单击动态 link 会调用 continueUserActivity 方法。

但是,当应用尚未启动(或未安装)时,应用似乎无法检测到动态 link。 application:openURL:options 永远不会被调用,application:userActivity:restorationHandler 只会在应用程序启动时调用。 我在 applicationDidFinishLaunchWithOptions 中遗漏了什么吗?

提前感谢您提供的所有帮助!

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

 //custom scheme is set to my bundleID as recommended
    [FIROptions defaultOptions].deepLinkURLScheme = MY_CUSTOM_SCHEME;
    [FIRApp configure]

 return YES
}


- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
  FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];


  if (dynamicLink) {
    if (dynamicLink.url) {
      // Handle the deep link. For example, show the deep-linked content,
      // apply a promotional offer to the user's account or show customized onboarding view.
      // ...
      NSLog(@"opened with dynamic link");
    } else {
      // Dynamic link has empty deep link. This situation will happens if
      // Firebase Dynamic Links iOS SDK tried to retrieve pending dynamic link,
      // but pending link is not available for this device/App combination.
      // At this point you may display default onboarding view.
      NSLog(@"not opened with dynamic link");
    }
    return YES;
  }
  return NO;
}

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray *))restorationHandler {

    NSLog(@"continueUserActivity called");
  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);
        }
        else {
            NSLog(@"dynamic link called: %@", dynamicLink.url);
        }
    }];
  return handled;
}

您使用的是哪个版本的 Firebase 动态链接 SDK?确保您更新到最新版本。还有 运行 方法 [FIRDynamicLinks performDiagnosticsWithCompletion:nil]; 并检查输出是否有任何错误。

您在哪个应用程序中点击动态 link?您是否继续点击 AppPreview 页面中的“打开”按钮?