0

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;
}
Besfort Abazi
  • 373
  • 3
  • 18

1 Answers1

1

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?

Oleksiy Ivanov
  • 2,454
  • 15
  • 21
  • Just updated the SDK today (1.4.0). I tap on the Notes App. On my device, if I click the link and the app is already running it calls the continueUserActivity and I can accordingly present the dynamic onboarding. But If the app is closed it just opens the app but doesn't call neither the continueUserActivity nor application:openURL:options: methods – Besfort Abazi Jan 04 '18 at 18:32
  • Latest version of FDL SDK is 2.3.1. See here https://github.com/CocoaPods/Specs/blob/master/Specs/6/e/5/FirebaseDynamicLinks/2.3.1/FirebaseDynamicLinks.podspec.json#L28 . Which version 1.4.0 you are referring to? The behavior you observing is not correct, in this case Universal Links are engaged, so you should see URL passed to continueUserActivity. Please open Firebase support case or share your code. – Oleksiy Ivanov Jan 04 '18 at 23:44
  • Using Firebase (3.17.0) Using FirebaseAnalytics (3.9.0) Using FirebaseAuth (3.1.1) Using FirebaseCore (3.6.0) Using FirebaseDatabase (3.1.2) Using FirebaseDynamicLinks (1.4.0) Using FirebaseInstanceID (1.0.10) Using FirebaseInvites (1.3.0) Using FirebaseMessaging (1.2.3) Using FirebaseStorage (1.1.0) this is an excerpt from my terminal after 'pod update' How do I get the 2.3.1 SDK which you are referring to? – Besfort Abazi Jan 06 '18 at 19:26
  • These are quite old version numbers. I suggest to update to recent Firebase version to ensure you are not seeing old bug that has been since fixed. Can you post your Podfile to clarify reason why pod update failed to update? Feel free to open Firebase support ticket or send me email at oleksiyi _at_ google.com to share privately. – Oleksiy Ivanov Jan 07 '18 at 22:42
  • Hello Oleksiy, I managed to update Firebase to the newest version, but I am getting another problem with the new version. I'll get back here as soon as the other problem gets resolved. – Besfort Abazi Jan 09 '18 at 14:12
  • alright I updated to the newest version, and it still won't work. is one of the methods maybe inadequate to iOS 11? is there a problem with the URL Scheme? or did I setup something defective within the Firebase Console? – Besfort Abazi Jan 09 '18 at 17:18
  • Please open Firebase support ticket/bug. Add output of the [FIRDynamicLinks performDiagnosticsWithCompletion:nil]; and your code to the ticket. – Oleksiy Ivanov Jan 11 '18 at 20:41