iOS 11.3.1下Firebase Dynamic Links安装后参数丢失求助
Hey there, I’ve seen several other developers report this exact issue with Firebase Dynamic Links (FDL) on iOS 11.3.1—it’s definitely not just you! A lot of us noticed this broke after Apple pushed the 11.3.1 update, even though everything worked flawlessly on earlier iOS versions.
What’s Going On?
From what I’ve gathered, iOS 11.3.1 introduced changes to WebKit and Universal Link handling that mess with FDL’s ability to persist and retrieve parameters after an App Store install. The weak-match mechanism that FDL uses to link post-install opens back to the original link seems to fail on this specific iOS version, which is why you’re seeing those google/link/?match_type=none or is_weak_match=1 URLs instead of your actual deep link parameters.
Reproduction Steps (for reference)
- Tap a Firebase Dynamic Link
- Get redirected to the App Store
- Install the app
- Open the app
- No FDL parameters are passed to the app
Code Snippet Showing the Problem
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { // The returned URL looks like: // google/link/?match_type=none&match_message=该设备未匹配到预安装链接。 // OR // google/link/?dismiss=1&is_weak_match=1 }
Fixes That Worked for Other Developers
Here are the most reliable solutions we’ve found:
Upgrade to the Latest Firebase SDK
Firebase released patches specifically addressing this iOS 11.3.1 compatibility issue. Make sure you’re using the latest stable version of theFirebase/DynamicLinkspod (check your Podfile and runpod update Firebase/DynamicLinks). The team fixed the weak-match persistence logic in later SDK versions to account for iOS 11.3.1’s changes.Double-Check Your Universal Links Configuration
iOS 11.3.1 tightened up Universal Link validation rules. Verify that:- Your
apple-app-site-associationfile is hosted athttps://yourdomain.com/.well-known/apple-app-site-association(no redirects, HTTPS only) - The file’s JSON format is correct, with your app’s team ID and bundle ID properly listed
- You’ve enabled Associated Domains in your Xcode project and added the correct
applinks:yourdomain.comentry
- Your
Fix Your Link Handling Code
Ensure you’re handling both custom scheme URLs and Universal Links correctly. Here’s an updated version of your code that covers both cases:- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { // Try to parse the custom scheme URL with Firebase FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url]; if (dynamicLink && dynamicLink.url) { // Process your deep link parameters here NSLog(@"Received FDL params: %@", dynamicLink.url.query); return YES; } // Handle weak match fallback - trigger Firebase to recheck if ([url.scheme isEqualToString:@"google"] && [url.host isEqualToString:@"link"]) { // You can also check Keychain for stored params (Firebase uses this internally) return YES; } return NO; } // Don't forget to handle Universal Links! - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler { BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) { if (dynamicLink && dynamicLink.url) { NSLog(@"FDL from Universal Link: %@", dynamicLink.url.query); // Process params here } }]; return handled; }Disable Weak Match (Last Resort)
If upgrading the SDK doesn’t work, you can disable FDL’s weak match feature in the Firebase Console. This makes FDL rely solely on Universal Links, which are more reliable on iOS 11.3.1—though note this might reduce compatibility with older iOS versions.
内容的提问来源于stack exchange,提问作者ordinaryman09

