Skip to content

fix(dynamic-links): fix crash when building dynamic link with no internet #9942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,42 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
FLTFirebaseMethodCallErrorBlock errorBlock = ^(
NSString *_Nullable code, NSString *_Nullable message, NSDictionary *_Nullable details,
NSError *_Nullable error) {
NSMutableDictionary *temp;
if (code == nil) {
NSDictionary *errorDetails = getDictionaryFromNSError(error);
code = errorDetails[kCode];
message = errorDetails[kMessage];
details = errorDetails;

if (errorDetails[@"additionalData"] != nil) {
temp = [errorDetails[@"additionalData"] mutableCopy];
} else {
temp = [errorDetails mutableCopy];
}

// "NSErrorFailingURLStringKey" key does not work for removing this object. So we use our own
// String to retrieve
if (temp[@"NSErrorFailingURLKey"] != nil) {
[temp removeObjectForKey:@"NSErrorFailingURLKey"];
}
if (temp[NSUnderlyingErrorKey] != nil) {
[temp removeObjectForKey:NSUnderlyingErrorKey];
}

if ([errorDetails[kMessage] containsString:@"An unknown error has occurred"] &&
[temp[NSLocalizedDescriptionKey] containsString:@"The request timed out"]) {
message = temp[NSLocalizedDescriptionKey];
}

if (errorDetails[@"additionalData"][NSLocalizedFailureReasonErrorKey] != nil) {
// This stops an uncaught type cast exception in dart
NSMutableDictionary *temp = [errorDetails[@"additionalData"] mutableCopy];
[temp removeObjectForKey:NSLocalizedFailureReasonErrorKey];
details = temp;
// provides a useful message to the user. e.g. "Universal link URL could not be parsed".
if ([message containsString:@"unknown error"]) {
message = errorDetails[@"additionalData"][NSLocalizedFailureReasonErrorKey];
}
}

details = temp;
} else {
details = @{
kCode : code,
Expand Down