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