Skip to content

Commit

Permalink
fix(videos): videos not working on iOS 13 and throwing a fatal crash …
Browse files Browse the repository at this point in the history
…when selected (#1904)

* Fix GH-1742: Additional error check for nil around copying video and adds error message handling to prevent hard crash.
* Fix GH-1742: Lower case "nil" in conditional check
  • Loading branch information
tdbrian committed Dec 28, 2021
1 parent 3f77e40 commit e45c862
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ios/ImagePickerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ -(NSMutableDictionary *)mapVideoToAsset:(NSURL *)url phAsset:(PHAsset * _Nullabl
[fileManager copyItemAtURL:url toURL:videoDestinationURL error:error];
}

if (error) {
if (error && *error) {
return nil;
}
}
Expand Down Expand Up @@ -352,8 +352,11 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
} else {
NSError *error;
NSDictionary *videoAsset = [self mapVideoToAsset:info[UIImagePickerControllerMediaURL] phAsset:asset error:&error];

if (videoAsset == nil) {
self.callback(@[@{@"errorCode": errOthers, @"errorMessage": error.localizedFailureReason}]);
NSString *errorMessage = error.localizedFailureReason;
if (errorMessage == nil) errorMessage = @"Video asset not found";
self.callback(@[@{@"errorCode": errOthers, @"errorMessage": errorMessage}]);
return;
}
[assets addObject:videoAsset];
Expand Down

0 comments on commit e45c862

Please sign in to comment.