0

I encounter a weird issue with long dynamic link base on FirebaseDynamicLinks (4.0.8):

Have tried refer to similar issues firebase/quickstart-ios/issues/380#issuecomment-343255857 and DynamicLinks.dynamicLinks().handleUniversalLink returns false

My long dynamic link format is alike that :

https://example.page.link/?link=https://app.tdservice/account?to=create&apn=com.testDynamicAndroid.service.app&isi=1234567890&ibi=com.TestDynamiciOS.service

And already confirm my real link is normal by appsearch-validation-tool

However, my implement of handleUniversalLink in AppDelegate without call back, cause the handled return NO....

- (BOOL)application:(UIApplication *)application
continueUserActivity:(nonnull 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
    if ([userActivity webpageURL] != nil) {
        NSString *incomingURL = [userActivity webpageURL].absoluteString;
        NSLog(@"Incoming URL is %@", incomingURL);

        BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
        completion:^(FIRDynamicLink * _Nullable dynamicLink,
        NSError * _Nullable error) {
            if (error != nil) {
                return NSLog(@"Found an error! %@", error.localizedDescription);
            }

            if (dynamicLink != nil && dynamicLink.url != nil) {
                [self handleIncomingDynamicLink:dynamicLink]; // additional declare
            } else {
                NSLog(@"This's weird. Dynamic link object has no url");
            }
        }];

        if (handled) { 
            return YES; 
        } else {
            // may do other things with incoming URL
            return NO;
        }

    } else { return NO; }
}
Joshpy
  • 560
  • 8
  • 21

1 Answers1

1
NSDictionary *FIRDLDictionaryFromQuery(NSString *queryString) {
    NSArray<NSString *> *keyValuePairs = [queryString componentsSeparatedByString:@"&"];

    NSMutableDictionary *queryDictionary = [NSMutableDictionary dictionaryWithCapacity:keyValuePairs.count];

    for (NSString *pair in keyValuePairs) {
        NSArray *keyValuePair = [pair componentsSeparatedByString:@"="];
        if (keyValuePair.count == 2) {
            NSString *key = keyValuePair[0];
            NSString *value = [keyValuePair[1] stringByRemovingPercentEncoding];
            [queryDictionary setObject:value forKey:key];
        }
    }
}

Then I tracking FIRDynamicLinks and found the root cause.

Dynamic link for iOS with filter char of @"&" and @"=" , according to the keyValuePair.count == 2, my params be dropped who the keyword of [link].

Due to my long dynamic link has two [=] symbol before first [&] symbol, keyValuePair.count is 3.

So that my dynamic link object hasn't link parameter and return nil

I think url have to refer to Manually constructing a Dynamic Link URL , and try to be the same.

Finally, I found to similar symptom Deep Link does not contain valid required params, link value have to percent encoded, solving my confuse and my issue.

But interesting, Android platform without this symptom, the same long dynamic link is workable.

Joshpy
  • 560
  • 8
  • 21