@@ -150,25 +150,55 @@ - (BOOL)checkForDynamicLink:(NSURL *)url {
150
150
- (BOOL )application : (UIApplication *)application
151
151
openURL : (NSURL *)url
152
152
options : (NSDictionary <UIApplicationOpenURLOptionsKey, id> *)options {
153
- return [self checkForDynamicLink: url];
153
+ [self checkForDynamicLink: url];
154
+ // results of this are ORed and NO doesn't affect other delegate interceptors' result
155
+ return NO ;
154
156
}
155
157
156
158
- (BOOL )application : (UIApplication *)application
157
159
openURL : (NSURL *)url
158
160
sourceApplication : (NSString *)sourceApplication
159
161
annotation : (id )annotation {
160
- return [self checkForDynamicLink: url];
162
+ [self checkForDynamicLink: url];
163
+ // results of this are ORed and NO doesn't affect other delegate interceptors' result
164
+ return NO ;
161
165
}
162
166
163
167
- (BOOL )application : (UIApplication *)application
164
168
continueUserActivity : (NSUserActivity *)userActivity
165
- restorationHandler : (void (^)(NSArray *))restorationHandler {
166
- BOOL handled = [[FIRDynamicLinks dynamicLinks ]
167
- handleUniversalLink: userActivity.webpageURL
168
- completion: ^(FIRDynamicLink *_Nullable dynamicLink, NSError *_Nullable error) {
169
- [self onDeepLinkResult: dynamicLink error: error];
170
- }];
171
- return handled;
169
+ restorationHandler :
170
+ #if defined(__IPHONE_12_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0)
171
+ (nonnull void (^)(NSArray <id <UIUserActivityRestoring>> *_Nullable))restorationHandler {
172
+ #else
173
+ (nonnull void (^)(NSArray *_Nullable))restorationHandler {
174
+ #endif // __IPHONE_12_0
175
+ __block BOOL retried = NO ;
176
+
177
+ id completion = ^(FIRDynamicLink *_Nullable dynamicLink, NSError *_Nullable error) {
178
+ if (!error && dynamicLink && dynamicLink.url ) {
179
+ [self onDeepLinkResult: dynamicLink error: nil ];
180
+ }
181
+ }
182
+ // Per Apple Tech Support, a network failure could occur when returning from background on
183
+ // iOS 12. https://github.com/AFNetworking/AFNetworking/issues/4279#issuecomment-447108981 So
184
+ // we'll retry the request once
185
+ if (error && !retried && [NSPOSIXErrorDomain isEqualToString: error.domain] &&
186
+ error.code == 53 ) {
187
+ retried = YES ;
188
+ [[FIRDynamicLinks dynamicLinks ] handleUniversalLink: userActivity.webpageURL
189
+ completion: completion];
190
+ }
191
+ // TODO: We could send this to Dart and maybe have a onDynamicLinkError listener but there's also a good chance the
192
+ // TODO: `userActivity.webpageURL` might not be for a Firebase dynamic link, which needs consideration - so we'll
193
+ // TODO: log this for now, logging will get picked up by Crashlytics automatically if its integrated.
194
+ if (error) NSLog (@" FLTFirebaseDynamicLinks: Unknown error occurred when attempting to handle a universal link: %@ " , error);
195
+ };
196
+
197
+ [[FIRDynamicLinks dynamicLinks ] handleUniversalLink: userActivity.webpageURL
198
+ completion: completion];
199
+
200
+ // results of this are ORed and NO doesn't affect other delegate interceptors' result
201
+ return NO ;
172
202
}
173
203
174
204
- (FIRDynamicLinkShortenerCompletion)createShortLinkCompletion : (FlutterResult)result {
0 commit comments