Besfort Abazi
Besfort Abazi

Reputation: 383

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

When the app is in background mode (already installed and launched once), clicking on a dynamic link calls the continueUserActivity method.

However, when the app is not launched yet (or not installed), app doesn't seem to detect the dynamic link. application:openURL:options is never called, application:userActivity:restorationHandler is only called when application already launched. Am I missing something in applicationDidFinishLaunchWithOptions?

Thank you in advance for every help you can provide!

- (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;
}

Upvotes: 0

Views: 1195

Answers (1)

Oleksiy Ivanov
Oleksiy Ivanov

Reputation: 2514

What version of Firebase Dynamic Links SDK are you using? Ensure you updated to latest version. Also run method [FIRDynamicLinks performDiagnosticsWithCompletion:nil]; and check output for any errors.

In which App do you tapping on dynamic link? Do you proceed to tap on OPEN button in AppPreview page?

Upvotes: 1

Related Questions