fix(ios): return copy of video when picking from gallery on iOS 13 (#580)

This commit is contained in:
jcesarmobile 2020-04-15 11:41:21 +02:00 committed by GitHub
parent 7611960ef2
commit bfa38fed2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -513,9 +513,22 @@ static NSString* toBase64(NSData* data) {
- (CDVPluginResult*)resultForVideo:(NSDictionary*)info
{
NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
// On iOS 13 the movie path becomes inaccessible, create and return a copy
if (IsAtLeastiOSVersion(@"13.0")) {
moviePath = [self createTmpVideo:[[info objectForKey:UIImagePickerControllerMediaURL] path]];
}
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath];
}
- (NSString *) createTmpVideo:(NSString *) moviePath {
NSString* moviePathExtension = [moviePath pathExtension];
NSString* copyMoviePath = [self tempFilePath:moviePathExtension];
NSFileManager* fileMgr = [[NSFileManager alloc] init];
NSError *error;
[fileMgr copyItemAtPath:moviePath toPath:copyMoviePath error:&error];
return [[NSURL fileURLWithPath:copyMoviePath] absoluteString];
}
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
__weak CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;