2

I read up on all the posts I could find and am still getting a nil URL when launching the app for the first time after tapping a dynamic link pasted into the Notes app on iOS. Actually I followed the video:
https://www.youtube.com/watch?v=sFPo296OQqk

Universal Links work fine and as expected through application(_:continue:restorationHandler:). When coming through application(_:open:options:) (formerly application:openURL:options:) however, the URL comes in as <my-scheme-name>://google/link/?is_weak_match=1. No matter how I configure my project/app, the URL is always nil. Also, application(_:open:options:) is called on every first launch of the app regardless of whether a dynamic link was tapped before the app was installed or not. Is that to be expected?

Configuration:

  • apple-app-site-association file is set up and looks good for Universal Links.
  • Custom URL scheme set up in Info.plist.
  • Using latest GoogleService-Info.plist
  • Not in Safari 'Private' Mode
  • Calling in didFinishLaunchingWithOptions

    [FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME;
    [FIRApp configure];
    
    
    
    
    - (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
         sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    
            FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks dynamicLinkFromCustomSchemeURL:url];
    
            if (dynamicLink) {
                  // Handle the deep link. For example, show the deep-linked content or
                  // apply a promotional offer to the user's account.
                  // [START_EXCLUDE]
                  // In this sample, we just open an alert.
    
                NSString *message = [self      generateDynamicLinkMessage:dynamicLink];
               [self showDeepLinkAlertViewWithMessage:message];
               // [END_EXCLUDE]
               return YES;
            }
    
             // [START_EXCLUDE silent]
             // Show the deep link that the app was called with.
             [self showDeepLinkAlertViewWithMessage:[NSString stringWithFormat:@"openURL:\n%@", url]];
             // [END_EXCLUDE]
            return NO;
       }
          // [END openurl]
    
    
    
          // [START continueuseractivity]
        - (BOOL)application:(UIApplication *)application
            continueUserActivity:(NSUserActivity *)userActivity
             restorationHandler:(void (^)(NSArray *))restorationHandler    
    
          {
    
                 // [START_EXCLUDE silent]
                   NSLog(@"%@", userActivity.webpageURL);
                   __weak AppDelegate *weakSelf = self;
    
                 // [END_EXCLUDE]
    
                 BOOL handled = [[FIRDynamicLinks dynamicLinks]
                  handleUniversalLink:userActivity.webpageURL
                  completion:^(FIRDynamicLink * _Nullable dynamicLink,
                          NSError * _Nullable error) {
    
                           // [START_EXCLUDE]
                           AppDelegate *strongSelf = weakSelf;
                           NSString *message = [strongSelf       generateDynamicLinkMessage:dynamicLink];
                           [strongSelf   showDeepLinkAlertViewWithMessage:message];
    
                           // [END_EXCLUDE]
    
                         }];
    
                  // [START_EXCLUDE silent]
                    if (!handled) {
                      // Show the deep link URL from userActivity.
                      NSString *message =
                     [NSString stringWithFormat:@"continueUserActivity webPageURL:\n%@", userActivity.webpageURL];
                     [self showDeepLinkAlertViewWithMessage:message];
                   }
                  // [END_EXCLUDE]
    
                return handled;
       }
         // [END continueuseractivity]
    
    
        - (NSString *)generateDynamicLinkMessage:(FIRDynamicLink *)dynamicLink {
    
            NSString *matchConfidence;
            if (dynamicLink.matchConfidence == FIRDynamicLinkMatchConfidenceStrong) {
              matchConfidence = @"strong";
            } else {
              matchConfidence = @"weak";
            }
    
               NSString *msg = [NSString stringWithFormat:@"App URL: %@\n"
                       @"Match Confidence: %@\n",
                       dynamicLink.url, matchConfidence];
        return msg;
       }
    
       - (void)showDeepLinkAlertViewWithMessage:(NSString *)message {
    
             UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK"
                                                  style:UIAlertActionStyleDefault
                                                   handler:^(UIAlertAction *action) {
             NSLog(@"OK");                                               }];
    
        UIAlertController *alertController =
        [UIAlertController alertControllerWithTitle:@"Deep-link Data"
         message:message                                        
         preferredStyle:UIAlertControllerStyleAlert];
    
         [alertController addAction:okAction];
    
         [self.window.rootViewController presentViewController:alertController animated:YES completion:nil];
    
       }
    

Setup:

  • Xcode 8.3
  • Deployment target: iOS 10.3.3
  • Objective-C

1 Answers1

0

Please try to connect to Cellular and WiFi and repeat the experiment. Also connecting to different WiFi networks may help to figure out the issue. If your WiFi has small number of public facing IP addresses than retrieving pending dynamic link may fail. Also see suggestions in this answer Firebase Dynamic Links not survive installation

If that does not work, I suggest opening support ticket with Firebase.

About link <my-scheme-name>://google/link/?is_weak_match=1 you are receiving: this link being sent by FDL iOS SDK to communicate the event that pending dynamic link is not available. You will receive this link only after first launch of the application. If we found pending dynamic link, we will pass that dynamic link instead.

Oleksiy Ivanov
  • 2,454
  • 15
  • 21