Installation
This document is split into two main sections:
- Required installation steps for basic usage of react-native-camera
- Additional installation steps for usage of Face Detection/Text Recognition/BarCode with MLKit
Required installation steps
These steps assume installation for iOS/Android. To install it with Windows, see Windows below
Mostly automatic install with autolinking (RN > 0.60)
- npm install react-native-camera —save
- Run cd ios && pod install && cd ..
Mostly automatic install with react-native link (RN npm install react-native-camera —save
Manual install — iOS (not recommended)
- npm install react-native-camera —save
- In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project’s name]
- Go to node_modules ➜ react-native-camera and add RNCamera.xcodeproj
- Expand the RNCamera.xcodeproj ➜ Products folder
- In XCode, in the project navigator, select your project. Add libRNCamera.a to your project’s Build Phases ➜ Link Binary With Libraries
- Click RNCamera.xcodeproj in the project navigator and go the Build Settings tab. Make sure ‘All’ is toggled on (instead of ‘Basic’). In the Search Paths section, look for Header Search Paths and make sure it contains both $(SRCROOT)/../../react-native/React and $(SRCROOT)/../../../React — mark both as recursive .
Manual install — Android (not recommended)
- npm install react-native-camera —save
- Open up android/app/src/main/java/[. ]/MainApplication.java
- Add import org.reactnative.camera.RNCameraPackage; to the imports at the top of the file
- Add new RNCameraPackage() to the list returned by the getPackages() method. Add a comma to the previous item if there’s already something there.
- Append the following lines to android/settings.gradle :
- Insert the following lines in android/app/build.gradle inside the dependencies block:
iOS — other required steps
Add permissions with usage descriptions to your app Info.plist :
Additional information in case of problems
You might need to adjust your Podfile following the example below:
Android — other required steps
Add permissions to your app android/app/src/main/AndroidManifest.xml file:
Insert the following lines in android/app/build.gradle :
Additional information in case of problems
Make sure you use JDK >= 1.7 and your buildToolsVersion >= 25.0.2
Make sure you have jitpack added in android/build.gradle
Additional installation steps
Follow these optional steps if you want to use Face Detection/Text Recognition/BarCode with MLKit.
If you want any of these optional features, you will need to use CocoaPods.
MLKit for iOS runs on arm64/x86_64 devices only; armv7/x86 is not supported
Add dependency towards react-native-camera in your Podfile with subspecs using one of the following:
- For Face Detection:
- For Text Recognition:
- For BarCode Recognition:
- For all possible detections:
Then run cd ios && pod install && cd ..
Additional information in case of problems
- If you see build errors like ld: symbol(s) not found for architecture armv7 you will need to exclude armv7 arch in your Xcode (Xcode -> Build Setting -> Excluded Architectures -> Add ‘armv7’ for ‘Any iOS SDK’ ).
Modify the following lines in android/app/build.gradle :
Setting up MLKit
If you don’t use any other Firebase component in your project
- Add the folowing to project level build.gradle :
- add to the bottom of android/app/build.gradle file
If you have Firebase integrated already
- Add the folowing to project level build.gradle :
- add to the bottom of android/app/build.gradle file
Additional information in case of problems The current Android library defaults to the below values for the Google SDK and Libraries,
You can override this settings by adding a Project-wide gradle configuration properties for use by all modules in your ReactNative project by adding the below to android/build.gradle file,
The above settings in the ReactNative project over-rides the values present in the react-native-camera module. For your reference please check android/build.gradle file of the module.
Mostly automatic install with autolinking (RNW >= 0.63)
- npm install react-native-camera —save
- See Additional steps — Windows below
Manual install — Windows (RNW 0.62)
- npm install react-native-camera —save
- Link the library as described below:
- Add the ReactNativeCameraCPP project to your solution (eg. windows\yourapp.sln )
- Open your solution in Visual Studio 2019
- Right-click Solution icon in Solution Explorer > Add > Existing Project.
- Select node_modules\react-native-camera\windows\ReactNativeCameraCPP\ReactNativeCameraCPP.vcxproj
- Add a reference to ReactNativeCameraCPP to your main application project (eg. windows\yourapp\yourapp.vcxproj )
- Open your solution in Visual Studio 2019
- Right-click main application project > Add > Reference.
- Check ReactNativeCameraCPP from Solution Projects
- Add the ReactNativeCameraCPP project to your solution (eg. windows\yourapp.sln )
- Modify files below to add the package providers to your main application project
- pch.h
- Add #include «winrt/ReactNativeCameraCPP.h»
- App.cpp
- Add PackageProviders().Append(winrt::ReactNativeCameraCPP::ReactPackageProvider()); before InitializeComponent();
- pch.h
- See Additional steps — Windows below
Manual install — Windows (RNW 0.61)
Follow Manual install — Windows (RNW 0.62) above, but for step 2 substitute ReactNativeCameraCPP61 for ReactNativeCameraCPP.
Additional steps — Windows
You need to declare that your app wants to access the camera:
- Add the capabilities (permissions) for the webcam and microphone as described here: Add capability declarations to the app manifest
- If you plan on capturing images to the Pictures Library, or videos to the Videos Library, be sure to enable those capabilities too
Follow the Q & A section if you are having compilation issues.
Источник
RNCamera
All you need is to import < RNCamera >from the react-native-camera module and then use the tag.
FaCC (Function as Child Components)
*You can also use it with Facc.
It’s the RNCamera’s reference
One of RNCamera.Constants.CameraStatus
‘READY’ | ‘PENDING_AUTHORIZATION’ | ‘NOT_AUTHORIZED’
One of RNCamera.Constants.RecordAudioPermissionStatus .
‘AUTHORIZED’ | ‘NOT_AUTHORIZED’ | ‘PENDING_AUTHORIZATION’
Values: RNCamera.Constants.AutoFocus.on (default) or RNCamera.Constants.AutoFocus.off
Most cameras have a Auto Focus feature. It adjusts your camera lens position automatically depending on the pixels seen by your camera.
Use the autoFocus property to specify the auto focus setting of your camera. RNCamera.Constants.AutoFocus.on turns it ON, RNCamera.Constants.AutoFocus.off turns it OFF.
Setting this property causes the auto focus feature of the camera to attempt to focus on the part of the image at this coordinate.
Coordinates values are measured as floats from 0 to 1.0 . < x: 0, y: 0 >will focus on the top left of the image, < x: 1, y: 1 >will be the bottom right. Values are based on landscape mode with the home button on the right—this applies even if the device is in portrait mode.
On iOS, focusing will not change the exposure automatically unless autoExposure is also set to true.
Hint: for portrait orientation, apply 90° clockwise rotation + translation: Example
if autoFocusPointOfInterest is set, this event will be fired when a substancial change is detected with the following object: < nativeEvent: < prevPoint: < x: number; y: number; >> >
Values: boolean true (default) | false
Specifies if audio recording permissions should be requested. Make sure to follow README instructions for audio recording permissions here.
Values: boolean true | false (false)
(iOS Only) When the camera is unmounted, it will release any audio session it acquired (if captureAudio=true ) so other media can continue playing. However, this might not be always desirable (e.g., if video is played afterwards) and can be disabled by setting it to true . Setting this to true , means your app will not release the audio session. Note: other apps might still «steal» the audio session from your app.
Values: RNCamera.Constants.FlashMode.off (default), RNCamera.Constants.FlashMode.on , RNCamera.Constants.FlashMode.auto or RNCamera.Constants.FlashMode.torch .
Specifies the flash mode of your camera.
RNCamera.Constants.FlashMode.off turns it off.
RNCamera.Constants.FlashMode.on means camera will use flash in all photos taken.
RNCamera.Constants.FlashMode.auto leaves your phone to decide when to use flash when taking photos, based on the lightning conditions that the camera observes.
RNCamera.Constants.FlashMode.torch turns on torch mode, meaning the flash light will be turned on all the time (even before taking photo) just like a flashlight.
Value: float from 0 to 1.0
Manually set camera focus. Only works with autoFocus off. The value 0 is minimum focus depth, 1 is maximum focus depth. For a medium focus depth, for example, you could use 0.5.
A string representing the camera ratio in the format ‘height:width’. Default is «4:3» .
Use getSupportedRatiosAsync method to get ratio strings supported by your camera on Android.
Values: RNCamera.Constants.Type.front or RNCamera.Constants.Type.back (default)
Use the type property to specify which camera to use.
Overrides the type property and uses the camera given by cameraId. Use getCameraIds to get the list of available IDs.
A common use case for this is to provide a «switch camera» button that loops through all available cameras.
Note: Variables such as flash might need to be resetted due to the camera not reporting an error when those values are not supported.
Values: RNCamera.Constants.WhiteBalance.sunny , RNCamera.Constants.WhiteBalance.cloudy , RNCamera.Constants.WhiteBalance.shadow , RNCamera.Constants.WhiteBalance.incandescent , RNCamera.Constants.WhiteBalance.fluorescent or RNCamera.Constants.WhiteBalance.auto (default)
A camera’s white balance setting allows you to control the color temperature in your photos by cooling down or warming up the colors.
The idea is that you select the appropriate white balance setting for the type of light that you’re shooting in, and then your camera automatically adjusts the colors to eliminate any warm or cool color casts from your light source.
Use the whiteBalance property to specify which white balance setting the camera should use.
On iOS it’s also possible to specify custom temperature, tint and rgb offset values instead of using one of the presets (auto, sunny, . ):
The rgb offset values are applied to the calculated device specific white balance gains for the given temperature and tint values.
Value: float from 0 to 1.0 , or -1 (default) for auto.
Sets the camera’s exposure value.
Boolean to turn on native pinch to zoom. Works with the maxZoom property on iOS.
Warning: The Android Touch-Event-System causes childviews to catch the touch events. Therefore avoid using screenfilling touchables inside of the cameraview.
Value: float from 0 to 1.0
Specifies the zoom of your camera. The value 0 is no zoom, 1 is maximum zoom. For a medium zoom, for example, you could pass 0.5 .
Value: optional float greater than 1.0 used to enforce a maximum zoom value on the camera. Setting a value to less than 1 (default) will make the camera use its own max zoom property.
Specifies the max zoom value used in zoom calculations. This is specifically useful for iOS where it reports arbitrary high values and using a 0 to 1 value as the zoom factor is not appropriate.
Android permissionDialogTitle — Deprecated
Starting on android M individual permissions must be granted for certain services, the camera is one of them, you can use this to change the title of the dialog prompt requesting permissions.
Android permissionDialogMessage — Deprecated
Starting on android M individual permissions must be granted for certain services, the camera is one of them, you can use this to change the content of the dialog prompt requesting permissions.
Configuration options for permissions request for recording audio. It will be passed as rationale parameter to PermissionsAndroid.request . This replaces and deprecates old permissionDialogTitle and permissionDialogMessage parameters.
Configuration options for permissions request for camera. It will be passed as rationale parameter to PermissionsAndroid.request . This replaces and deprecates old permissionDialogTitle and permissionDialogMessage parameters.
By default a Camera not authorized message will be displayed when access to the camera has been denied, if set displays the passed react element instead of the default one.
An
Note: Must also provide cameraViewDimensions prop for Android device
An
Boolean to turn on or off the camera’s shutter sound (default false). Note that in some countries, the shutter sound cannot be turned off.
Boolean to turn on or off the camera’s record sound (default false)
The video stabilization mode used for a video recording. The possible values are:
- RNCamera.Constants.VideoStabilization[‘off’]
- RNCamera.Constants.VideoStabilization[‘standard’]
- RNCamera.Constants.VideoStabilization[‘cinematic’]
- RNCamera.Constants.VideoStabilization[‘auto’]
This option specifies the quality of the video to be taken. The possible values are:
- RNCamera.Constants.VideoQuality.2160p .
- ios Specifies capture settings suitable for 2160p (also called UHD or 4K) quality (3840×2160 pixel) video output.
- android Quality level corresponding to the 2160p (3840×2160) resolution. (Android Lollipop and above only!).
- RNCamera.Constants.VideoQuality.1080p .
- ios Specifies capture settings suitable for 1080p quality (1920×1080 pixel) video output.
- android Quality level corresponding to the 1080p (1920 x 1080) resolution.
- RNCamera.Constants.VideoQuality.720p .
- ios Specifies capture settings suitable for 720p quality (1280×720 pixel) video output.
- android Quality level corresponding to the 720p (1280 x 720) resolution.
- RNCamera.Constants.VideoQuality.480p .
- ios Specifies capture settings suitable for VGA quality (640×480 pixel) video output.
- android Quality level corresponding to the 480p (720 x 480) resolution.
- RNCamera.Constants.VideoQuality.4:3 .
- ios Specifies capture settings suitable for VGA quality (640×480 pixel) video output. (Same as RNCamera.Constants.VideoQuality.480p).
- android Quality level corresponding to the 480p (720 x 480) resolution but with video frame width set to 640.
- RNCamera.Constants.VideoQuality.288p .
- ios Specifies capture settings suitable for CIF quality (352×288 pixel) video output.
- android Not supported.
If nothing is passed the device’s highest camera quality will be used as default. Note: This solve the flicker video recording issue for iOS
This prop has a different behaviour for Android and iOS and should rarely be set.
For Android, this prop attempts to control the camera sensor capture resolution, similar to how ratio behaves. This is useful for cases where a low resolution image is required, and makes further resizing less intensive on the device’s memory. The list of possible values can be requested with getAvailablePictureSizes , and the value should be set in the format of x . Internally, the native code will attempt to get the best suited resolution for the given pictureSize value if the provided value is invalid, and will default to the highest resolution available.
For iOS, this prop controls the internal camera preset value and should rarely be changed. However, this value can be set to setup the sensor to match the video recording’s quality in order to prevent flickering. The list of valid values can be gathered from https://developer.apple.com/documentation/avfoundation/avcapturesessionpreset and can also be requested with getAvailablePictureSizes .
Native Event callbacks props
Function to be called when native code emit onCameraReady event, when camera is ready. This event will also fire when changing cameras (by type or cameraId ).
Function to be called when native code emit onMountError event, when there is a problem mounting the camera.
Function to be called when native code emits status changes in relation to authorization changes.
Event contains the following fields:
- cameraStatus — one of the CameraStatus values
- recordAudioPermissionStatus — one of the RecordAudioPermissionStatus values
iOS only. Function to be called when the camera audio session is interrupted or fails to start for any reason (e.g., in use or not authorized). For example, this might happen due to another app taking exclusive control over the microphone (e.g., a phone call) if captureAudio=
iOS only. Function to be called when the camera audio session is connected. This will be fired the first time the camera is mounted with captureAudio=
Function to be called when native code emit onPictureTaken event, when camera has taken a picture, but before all extra processing happens. This can be useful to allow the UI to take other pictures while the processing of the current picture is still taking place.
Function to be called when native code actually starts video recording. Note that video recording might take a few miliseconds to setup depending on the camera settings and hardware features. Use this event to detect when video is actually being recorded. Event will contain the following fields:
- uri — Video file URI, as returned by recordAsync
- videoOrientation — Video orientation, as returned by recordAsync
- deviceOrientation — Video orientation, as returned by recordAsync
Function to be called when native code stops recording video, but before all video processing takes place. This event will only fire after a successful video recording, and it will not fire if video recording fails (use the error returned from recordAsync instead).
Function to be called when a touch within the camera view is recognized. The function is also called on the first touch of double tap. Event will contain the following fields:
Function to be called when a double touch within the camera view is recognized. Event will contain the following fields:
Bar Code Related props
Will call the specified method when a barcode is detected in the camera’s view.
Event contains the following fields
data — a textual representation of the barcode, if available
rawData — The raw data encoded in the barcode, if available
uri : (iOS only) string representing the path to the image saved on your app’s cache directory. Applicable only for onGoogleVisionBarcodesDetected .
type — the type of the barcode detected
onAndroid: the ResultPoint[] ( bounds.origin ) is returned for scanned barcode origins. The number of ResultPoint returned depends on the type of Barcode.
The following barcode types can be recognised:
- aztec
- code128
- code39
- code39mod43
- code93
- ean13 ( iOS converts upca barcodes to ean13 by adding a leading 0)
- ean8
- pdf417
- qr
- upce
- interleaved2of5 (when available)
- itf14 (when available)
- datamatrix (when available)
An array of barcode types to search for. Defaults to all types listed above. No effect if onBarCodeRead is undefined. Example:
Like onBarCodeRead , but using Firebase MLKit to scan barcodes. More info can be found here Note: If you already set onBarCodeRead , this will be invalid.
Like barCodeTypes , but applies to the Firebase MLKit barcode detector. Example: Available settings:
Change the mode in order to scan «inverted» barcodes. You can either change it to alternate , which will inverted the image data every second screen and be able to read both normal and inverted barcodes, or inverted , which will only read inverted barcodes. Default is normal , which only reads «normal» barcodes. Note: this property only applies to the Google Vision barcode detector. Example:
When detectedImageInEvent is false (default), onBarCodeRead / onBarcodesDetected only gives metadata, but not the image (bytes/base64) itself.
When detectedImageInEvent is true , onBarCodeRead / onGoogleVisionBarcodesDetected will fill the image field inside the object given to the callback handler. It contains raw image bytes in JPEG format (quality 100) as Base64-encoded string.
Face Detection Related props
RNCamera uses the Firebase MLKit for Face Detection, you can read more about it here.
Method to be called when face is detected. Receives a Faces Detected Event object. The interesting value of this object is the faces value, which is an array of Face objects. You can find more details about the possible values of these objects here
Method to be called if there was an Face Detection Error, receives an object with the isOperational property set to false if Face Detector is NOT operational and true if it is.
Values: RNCamera.Constants.FaceDetection.Mode.fast (default) or RNCamera.Constants.FaceDetection.Mode.accurate
Specifies the face detection mode of the Face Detection API.
Use RNCamera.Constants.FaceDetection.Mode.accurate if you want slower but more accurate results.
Values: RNCamera.Constants.FaceDetection.Landmarks.all or RNCamera.Constants.FaceDetection.Landmarks.none (default)
A landmark is a point of interest within a face. The left eye, right eye, and nose base are all examples of landmarks. The Face API provides the ability to find landmarks on a detected face.
Values: RNCamera.Constants.FaceDetection.Classifications.all or RNCamera.Constants.FaceDetection.Classifications.none (default)
Classification is determining whether a certain facial characteristic is present. For example, a face can be classified with regards to whether its eyes are open or closed. Another example is whether the face is smiling or not.
Text Recognition Related props
RNCamera uses the Firebase MLKit for Text Recognition, you can read more info about it here.
Method to be called when text is detected. Receives a Text Recognized Event object. The interesting value of this object is the textBlocks value, which is an array of TextBlock objects.
Component instance methods
Takes a picture, saves in your app’s cache directory and returns a promise. Note: additional image processing, such as mirror, orientation, and width, can be significantly slow on Android.
width (integer). This property allows to specify the width that the returned image should have, image ratio will not be affected. If no value is specified the maximum image size is used (capture may take longer).
quality (float between 0 to 1.0). This property is used to compress the output jpeg file with 1 meaning no jpeg compression will be applied. If no value is specified quality:1 is used.
base64 (boolean true or false) Use this with true if you want a base64 representation of the picture taken on the return data of your promise. If no value is specified base64:false is used.
mirrorImage (boolean true or false). Use this with true if you want the resulting rendered picture to be mirrored (inverted in the vertical axis). If no value is specified mirrorImage:false is used.
writeExif : (boolean or object, defaults to true). Setting this to a boolean indicates if the image exif should be preserved after capture, or removed. Setting it to an object, merges any data with the final exif output. This is useful, for example, to add GPS metadata (note that GPS info is correctly translated from double values to the EXIF format, so there’s no need to read the EXIF protocol).
exif (boolean true or false) Use this with true if you want a exif data map of the picture taken on the return data of your promise. If no value is specified exif:false is used.
fixOrientation (android only, boolean true or false) Use this with true if you want to fix incorrect image orientation (can take up to 5 seconds on some devices). Do not provide this if you only need EXIF based orientation.
forceUpOrientation (iOS only, boolean true or false). This property allows to force portrait orientation based on actual data instead of exif data.
imageType (iOS only, ImageType ‘jpg’ or ‘png’). This property allows setting the output image format to PNG or JPEG (default).
doNotSave (boolean true or false). Use this with true if you do not want the picture to be saved as a file to cache. If no value is specified doNotSave:false is used. If you only need the base64 for the image, you can use this with base64:true and avoid having to save the file.
pauseAfterCapture (boolean true or false). If true, pause the preview layer immediately after capturing the image. You will need to call cameraRef.resumePreview() before using the camera again. If no value is specified pauseAfterCapture:false is used.
orientation (string or number). Specifies the orientation that us used for taking the picture. Possible values: «portrait» , «portraitUpsideDown» , «landscapeLeft» or «landscapeRight» .
path (file path on disk). Specifies the path on disk to save picture to.
The promise will be fulfilled with an object with some of the following properties:
- width : returns the image’s width (taking image orientation into account)
- height : returns the image’s height (taking image orientation into account)
- uri : (string) the path to the image saved on your app’s cache directory.
- base64 : (string?) the base64 representation of the image if required.
- exif : returns an exif map of the image if required.
- pictureOrientation : (number) the orientation of the picture
- deviceOrientation : (number) the orientation of the device
Records a video, saves it in your app’s cache directory and returns a promise when stopRecording is called or either maxDuration or maxFileSize specified are reached.
quality . This option specifies the quality of the video to be taken. The possible values are:
- RNCamera.Constants.VideoQuality.2160p .
- ios Specifies capture settings suitable for 2160p (also called UHD or 4K) quality (3840×2160 pixel) video output.
- android Quality level corresponding to the 2160p (3840×2160) resolution. (Android Lollipop and above only!).
- RNCamera.Constants.VideoQuality.1080p .
- ios Specifies capture settings suitable for 1080p quality (1920×1080 pixel) video output.
- android Quality level corresponding to the 1080p (1920 x 1080) resolution.
- RNCamera.Constants.VideoQuality.720p .
- ios Specifies capture settings suitable for 720p quality (1280×720 pixel) video output.
- android Quality level corresponding to the 720p (1280 x 720) resolution.
- RNCamera.Constants.VideoQuality.480p .
- ios Specifies capture settings suitable for VGA quality (640×480 pixel) video output.
- android Quality level corresponding to the 480p (720 x 480) resolution.
- RNCamera.Constants.VideoQuality.4:3 .
- ios Specifies capture settings suitable for VGA quality (640×480 pixel) video output. (Same as RNCamera.Constants.VideoQuality.480p).
- android Quality level corresponding to the 480p (720 x 480) resolution but with video frame width set to 640.
- RNCamera.Constants.VideoQuality.288p .
- ios Specifies capture settings suitable for CIF quality (352×288 pixel) video output.
- android Not supported.
videoBitrate . (int greater than 0) This option specifies a desired video bitrate. For example, 5*1000*1000 would be 5Mbps.
- ios Supported however requires that the codec key is also set.
- android Supported.
orientation (string or number). Specifies the orientation that us used for recording the video. Possible values: «portrait» , «portraitUpsideDown» , «landscapeLeft» or «landscapeRight» .
If nothing is passed the device’s highest camera quality will be used as default.
iOS codec . This option specifies the codec of the output video. Setting the codec is only supported on iOS >= 10 . The possible values are:
- RNCamera.Constants.VideoCodec[‘H264’]
- RNCamera.Constants.VideoCodec[‘JPEG’]
- RNCamera.Constants.VideoCodec[‘HVEC’] ( iOS >= 11 )
- RNCamera.Constants.VideoCodec[‘AppleProRes422’] ( iOS >= 11 )
- RNCamera.Constants.VideoCodec[‘AppleProRes4444’] ( iOS >= 11 )
mirrorVideo (boolean true or false). Use this with true if you want the resulting video to be mirrored (inverted in the vertical axis). If no value is specified mirrorVideo:false is used.
maxDuration (float greater than 0). Specifies the maximum duration of the video to be recorded in seconds. If nothing is specified, no time limit will be used.
maxFileSize (int greater than 0). Specifies the maximum file size, in bytes, of the video to be recorded. For 1mb, for example, use 1*1024*1024. If nothing is specified, no size limit will be used.
mute (any value). (This value will automatically be set to true if the captureAudio has not been passed to the Camera component) If this flag is given in the option with any value, the video to be recorded will be mute. If nothing is specified, video will NOT be muted. Note: The recommended way of recording audio without sound passing captureAudio: false to the Camera component. The mute parameter is likely to become deprecated in the near future.
path (file path on disk). Specifies the path on disk to record the video to. You can use the same uri returned to continue recording across start/stops
The promise will be fulfilled with an object with some of the following properties:
uri : (string) the path to the video saved on your app’s cache directory.
videoOrientation : (number) orientation of the video
deviceOrientation : (number) orientation of the device
iOS codec : the codec of the recorded video. One of RNCamera.Constants.VideoCodec
isRecordingInterrupted : (boolean) whether the app has been minimized while recording
Allows to make RNCamera check Permissions again and set status accordingly. Making it possible to refresh status of RNCamera after user initially rejected the permissions.
Should be called after recordAsync() to make the promise be fulfilled and get the video uri.
Pauses the preview. The preview can be resumed again by using resumePreview().
Resumes the preview after pausePreview() has been called.
Android getSupportedRatiosAsync(): Promise
Android only. Returns a promise. The promise will be fulfilled with an object with an array containing strings with all camera aspect ratios supported by the device.
Android checkIfVideoIsValid(path): Promise
Static method and Android only. Returns a promise. The promise will be fulfilled with a boolean indicating if the given path contains a valid (non corrupted) video file. Useful for some android devices that may store corrupted files from time to time. Note: make sure to not include file:// since not all android implementations support URI strings (use /path/to/file/instead).
Returns a promise. The promise will be fulfilled with an array containing objects with all camera IDs and type supported by the device.
The promise will be fulfilled with an array containing objects with some of the following properties:
id : (string) the ID of the camera.
type : One of RNCamera.Constants.Type.front | RNCamera.Constants.Type.back
deviceType : iOS 10+ only. Returns the internal device string type used by the OS. Useful to identify camera types (e.g., wide). Constants match iOS’ string values: AVCaptureDeviceTypeBuiltInWideAngleCamera , AVCaptureDeviceTypeBuiltInTelephotoCamera , AVCaptureDeviceTypeBuiltInUltraWideCamera . More info can be found at Apple Docs
Note: iOS also allows for virtual cameras (e.g., a camera made of multiple cameras). However, only physical non-virtual cameras are returned by this method since advanced features (such as depth maps or auto switching on camera zoom) are not supported.
iOS isRecording(): Promise
iOS only. Returns a promise. The promise will be fulfilled with a boolean indicating if currently recording is started or stopped.
This component supports subviews, so if you wish to use the camera view as a background or if you want to layout buttons/images/etc. inside the camera then you can do that.
Example subview:
A Barcode and QR code UI mask which can be use to render a scanning layout on camera with customizable styling.
A rewritten version of react-native-barcode-mask using Hooks and Reanimated . If you’re already using react-native-reanimated ( react-navigation dependency) then you might benefit from this rewritten component.
- Customizable
- Provide custom hook to «scan barcode within finder area»
To learn about how to test components which uses RNCamera check its documentation about testing.
To see more of the RNCamera in action you can check out the RNCamera examples directory. Firebase MLKit-base features (such as Text, Face and Barcode detection) can be found in the mlkit example.
We are just beginning a funding campaign for react-native-camera. Contributions are greatly appreciated. When we gain more than $250 we will begin distributing funds to core maintainers in a fully transparent manner. Feedback for this process is welcomed, we will continue to evolve the strategy as we grow and learn more.
Support us with a monthly donation and help us continue our activities. [Become a backer]
Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]
Thanks to Brent Vatne (@brentvatne) for the react-native-video module which provided me with a great example of how to set up this module.
Источник