ImagePickerIOS
Note
This API will be removed from React Native as part of the Lean Core effort. Please refer to the community package if you wish to use this component.
However note that more current packages such as •
react-native-image-picker
for which bindings are
available, or •
expo-image-picker are
recommended instead.
Before you may use this API, you need to link the RCTCameraRoll library to
your app and provide a description for your use of the Photo Library.
- you need to add
RCTCameraRoll.xcodeproj(located in thenode_modules/react-native/Libraries/CameraRollsubdirectory of your app) to your project's Libraries tree in XCode, then - you need to specify
libRCTCameraRoll.aunder Link Binary with Libraries in your app's Build Phases tab. - you also need to set the Privacy - Photo Library Usage Description (or NSPhotoLibraryUsageDescription) key under Custom iOS Target Properties in your apps' Info tab.
Types
imageUri
An alias for the string type
type imageUri = string
cameraDialogConfig
An abstract type which can be created using the constructor of the same name.
You may call the constructor as cameraDialogConfig() to use the default
values.
cameraDialogConfig: (~videoMode: bool=?, unit) => cameraDialogConfig
selectDialogConfig
An abstract type which can be created using the constructor of the same name.
You may call the constructor as selectDialogConfig() to use the default
values.
selectDialogConfig:
(~showImages: bool=?, ~showVideos: bool=?, unit) => selectDialogConfig
Methods
canUseCamera
Method to check whether the app has permissions to use the camera, takes a
callback of type bool => unit.
canUseCamera: (bool => unit) => unit
canRecordVideos
Method to check whether the app has permissions to record videos, takes a
callback of type bool => unit.
canRecordVideos: (bool => unit) => unit
openCameraDialog
Method to request the Camera dialog given a config (of type
cameraDialogConfig) to specify whether the camera is
launched in video mode. When an image or video is captured, onSuccess callback
is passed the returned imageUri, height and width; onError callback is
applied otherwise. As'error is an abstract type
openCameraDialog:
(
~config: cameraDialogConfig,
~onSuccess: (imageUri, ~height: float, ~width: float, unit) => unit,
~onError: 'error => unit
) =>
unit
openSelectDialog
Method to request the Image Gallery given a config (of type
openSelectDialog) to specify whether images and/or videos
should be listed. When an image or video is selected, onSuccess callback is
passed the returned imageUri, height and width; onError callback is
executed otherwise. As'error is an abstract type
openSelectDialog:
(
~config: selectDialogConfig,
~onSuccess: (imageUri, ~height: float, ~width: float, unit) => unit,
~onError: 'error => unit
) =>
unit