@@ -150,25 +150,59 @@ - (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 =
178
+ ^(FIRDynamicLink *_Nullable dynamicLink, NSError *_Nullable error) {
179
+ if (!error && dynamicLink && dynamicLink.url ) {
180
+ [self onDeepLinkResult: dynamicLink error: nil ];
181
+ }
182
+ }
183
+ // Per Apple Tech Support, a network failure could occur when returning from background on
184
+ // iOS 12. https://github.com/AFNetworking/AFNetworking/issues/4279#issuecomment-447108981 So
185
+ // we'll retry the request once
186
+ if (error && !retried && [NSPOSIXErrorDomain isEqualToString: error.domain] &&
187
+ error.code == 53 ) {
188
+ retried = YES ;
189
+ [[FIRDynamicLinks dynamicLinks ] handleUniversalLink: userActivity.webpageURL
190
+ completion: completion];
191
+ }
192
+ // We could send this to Dart and maybe have a onDynamicLinkError stream but there's also
193
+ // a good chance the `userActivity.webpageURL` might not be for a Firebase dynamic link,
194
+ // which needs consideration - so we'll log this for now, logging will get picked up by
195
+ // Crashlytics automatically if its integrated.
196
+ if (error)
197
+ NSLog (@" FLTFirebaseDynamicLinks: Unknown error occurred when attempting to handle a universal "
198
+ @" link: %@ " ,
199
+ error);
200
+ };
201
+
202
+ [[FIRDynamicLinks dynamicLinks ] handleUniversalLink: userActivity.webpageURL completion: completion];
203
+
204
+ // results of this are ORed and NO doesn't affect other delegate interceptors' result
205
+ return NO ;
172
206
}
173
207
174
208
- (FIRDynamicLinkShortenerCompletion)createShortLinkCompletion : (FlutterResult)result {
0 commit comments