From 4c400a10c2c2fe6373eb42cf8e0c2cee1cacbeb0 Mon Sep 17 00:00:00 2001 From: Josh Carver Date: Wed, 13 Feb 2019 12:46:49 -0800 Subject: [PATCH] Make ImagePickerIOS.openCameraDialog work with video (fixes #17989) (#19170) Summary: Fixes #17989 Previously, `ImagePickerIOS.openCameraDialog` would not render a `Video` option when the camera screen opened. If you passed `ImagePickerIOS.openCameraDialog({ videoMode: true }, ...)` the app would crash with an error complaining about the proper mediaType(s) not being set (see issue: #17989 for full details). This is a 2 line change that sets the mediaTypes properly, so now users can capture videos in addition to photos. Pull Request resolved: https://github.com/facebook/react-native/pull/19170 Differential Revision: D14068078 Pulled By: hramos fbshipit-source-id: d04a3d267ca83ea58e88c880a85ac34ddd4744c8 --- Libraries/CameraRoll/RCTImagePickerManager.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libraries/CameraRoll/RCTImagePickerManager.m b/Libraries/CameraRoll/RCTImagePickerManager.m index b8e570cfcd7..ac6db9b8070 100644 --- a/Libraries/CameraRoll/RCTImagePickerManager.m +++ b/Libraries/CameraRoll/RCTImagePickerManager.m @@ -85,6 +85,8 @@ RCT_EXPORT_METHOD(openCameraDialog:(NSDictionary *)config RCTImagePickerController *imagePicker = [RCTImagePickerController new]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; + NSArray *availableMediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; + imagePicker.mediaTypes = availableMediaTypes; imagePicker.unmirrorFrontFacingCamera = [RCTConvert BOOL:config[@"unmirrorFrontFacingCamera"]]; if ([RCTConvert BOOL:config[@"videoMode"]]) {