1586130000
React Native Camera .A Camera component for React Native. Also supports barcode scanning!
The comprehensive camera module for React Native. Including photographs, videos, and barcode scanning!
npm i [[email protected]](/cdn-cgi/l/email-protection)
npm i [[email protected]](/cdn-cgi/l/email-protection)
To enable video recording
feature you have to add the following code to the AndroidManifest.xml
:
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<key>NSCameraUsageDescription</key>
<string>Your message to user when the camera is accessed for the first time</string>
<!-- Include this only if you are planning to use the camera roll -->
<key>NSPhotoLibraryUsageDescription</key>
<string>Your message to user when the photo library is accessed for the first time</string>
<!-- Include this only if you are planning to use the microphone for video recording -->
<key>NSMicrophoneUsageDescription</key>
<string>Your message to user when the microsphone is accessed for the first time</string>
On Android, you require buildToolsVersion
of 25.0.2+
. This should easily and automatically be downloaded by Android Studio’s SDK Manager.
On iOS 11 and later you need to add NSPhotoLibraryAddUsageDescription
key to the Info.plist. This key lets you describe the reason your app seeks write-only access to the user’s photo library. Info.plist can be found in ‘your_project/ios/your_project/Info.plist’. Add the following code:
<!-- Include this only if you are planning to use the camera roll -->
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Your message to user when the photo library is accessed for the first time</string>
NSPhotoLibraryAddUsageDescription
npm install react-native-camera --save
react-native link react-native-camera
npm install react-native-camera --save
pod 'react-native-camera', path: '../node_modules/react-native-camera'
pod install
npm install react-native-camera --save
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-camera
and add RCTCamera.xcodeproj
libRCTCamera.a
to your project’s Build Phases
➜ Link Binary With Libraries
RCTCamera.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
.Cmd+R
)npm install react-native-camera --save
import com.lwansbrough.RCTCamera.RCTCameraPackage;
to the imports at the top of the filenew RCTCameraPackage()
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
:
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
Insert the following lines inside the dependencies block in android/app/build.gradle
:
compile project(':react-native-camera')
Declare the permissions in your Android Manifest (required for video recording
feature)
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
All you need is to require
the react-native-camera
module and then use the
<Camera/>
tag.
'use strict';
import React, { Component } from 'react';
import {
AppRegistry,
Dimensions,
StyleSheet,
Text,
TouchableHighlight,
View
} from 'react-native';
import Camera from 'react-native-camera';
class BadInstagramCloneApp extends Component {
render() {
return (
<View style={styles.container}>
<Camera
ref={(cam) => {
this.camera = cam;
}}
style={styles.preview}
aspect={Camera.constants.Aspect.fill}>
<Text style={styles.capture} onPress={this.takePicture.bind(this)}>[CAPTURE]</Text>
</Camera>
</View>
);
}
takePicture() {
const options = {};
//options.location = ...
this.camera.capture({metadata: options})
.then((data) => console.log(data))
.catch(err => console.error(err));
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
},
preview: {
flex: 1,
justifyContent: 'flex-end',
alignItems: 'center'
},
capture: {
flex: 0,
backgroundColor: '#fff',
borderRadius: 5,
color: '#000',
padding: 10,
margin: 40
}
});
AppRegistry.registerComponent('BadInstagramCloneApp', () => BadInstagramCloneApp);
aspect
Values: Camera.constants.Aspect.fit
or "fit"
, Camera.constants.Aspect.fill
or "fill"
(default), Camera.constants.Aspect.stretch
or "stretch"
The aspect
property allows you to define how your viewfinder renders the camera’s view. For instance, if you have a square viewfinder and you want to fill it entirely, you have two options: "fill"
, where the aspect ratio of the camera’s view is preserved by cropping the view or "stretch"
, where the aspect ratio is skewed in order to fit the entire image inside the viewfinder. The other option is "fit"
, which ensures the camera’s entire view fits inside your viewfinder without altering the aspect ratio.
iOS
audio
Values: true
(Boolean), false
(default)
Applies to video capture mode only. Specifies whether or not audio should be captured with the video.
captureMode
Values: Camera.constants.CaptureMode.still
(default), Camera.constants.CaptureMode.video
The type of capture that will be performed by the camera - either a still image or video.
captureTarget
Values: Camera.constants.CaptureTarget.cameraRoll
(default), Camera.constants.CaptureTarget.disk
, Camera.constants.CaptureTarget.temp
, (deprecated),Camera.constants.CaptureTarget.memory
This property allows you to specify the target output of the captured image data. The disk output has been shown to improve capture response time, so that is the recommended value. When using the deprecated memory output, the image binary is sent back as a base64-encoded string.
captureQuality
Values: Camera.constants.CaptureQuality.high
or "high"
(default), Camera.constants.CaptureQuality.medium
or "medium"
, Camera.constants.CaptureQuality.low
or "low"
, Camera.constants.CaptureQuality.photo
or "photo"
, Camera.constants.CaptureQuality["1080p"]
or "1080p"
, Camera.constants.CaptureQuality["720p"]
or "720p"
, Camera.constants.CaptureQuality["480p"]
or "480p"
.
This property allows you to specify the quality output of the captured image or video. By default the quality is set to high.
When choosing more-specific quality settings (1080p, 720p, 480p), note that each platform and device supports different valid picture/video sizes, and actual resolution within each of these quality settings might differ. There should not be too much variance (if any) for iOS; 1080p should give 1920x1080, 720p should give 1280x720, and 480p should give 640x480 (note that iOS 480p therefore is NOT the typical 16:9 HD aspect ratio, and the typically-HD camera preview screen may differ greatly in aspect from what you actually record!!). For Android, expect more variance: on most Androids, 1080p should give 1920x1080 and 720p should give 1280x720; however, 480p will at “best” be 853x480 (16:9 HD aspect ratio), but falls back/down to 800x480, 720x480, or “worse”, depending on what is closest-but-less-than 853x480 and available on the actual device. If your application requires knowledge of the precise resolution of the output image/video, you might consider manually determine the actual resolution itself after capture has completed (particularly for 480p on Android).
Android also supports Camera.constants.CaptureQuality.preview
or "preview"
which matches the output image to the same one used in the preview
type
Values: Camera.constants.Type.front
or "front"
, Camera.constants.Type.back
or "back"
(default)
Use the type
property to specify which camera to use.
orientation
Values:
Camera.constants.Orientation.auto
or "auto"
(default),
Camera.constants.Orientation.landscapeLeft
or "landscapeLeft"
, Camera.constants.Orientation.landscapeRight
or "landscapeRight"
, Camera.constants.Orientation.portrait
or "portrait"
, Camera.constants.Orientation.portraitUpsideDown
or "portraitUpsideDown"
The orientation
property allows you to specify the current orientation of the phone to ensure the viewfinder is “the right way up.”
Android
playSoundOnCapture
Values: true
(default) or false
This property allows you to specify whether a shutter sound is played on capture. It is currently android only, pending a reasonable mute implementation in iOS.
onBarCodeRead
Will call the specified method when a barcode is detected in the camera’s view.
Event contains data
(the data in the barcode) and bounds
(the rectangle which outlines the barcode.)
The following barcode types can be recognised:
aztec
code128
code39
code39mod43
code93
ean13
ean8
pdf417
qr
upce
interleaved2of5
(when available)itf14
(when available)datamatrix
(when available)The barcode type is provided in the data
object.
barCodeTypes
An array of barcode types to search for. Defaults to all types listed above. No effect if onBarCodeRead
is undefined.
flashMode
Values:
Camera.constants.FlashMode.on
,
Camera.constants.FlashMode.off
,
Camera.constants.FlashMode.auto
Use the flashMode
property to specify the camera flash mode.
torchMode
Values:
Camera.constants.TorchMode.on
,
Camera.constants.TorchMode.off
,
Camera.constants.TorchMode.auto
Use the torchMode
property to specify the camera torch mode.
iOS
onFocusChanged: Event { nativeEvent: { touchPoint: { x, y } }
iOS: Called when a touch focus gesture has been made.
By default, onFocusChanged
is not defined and tap-to-focus is disabled.
Android: This callback is not yet implemented. However, Android will
automatically do tap-to-focus if the device supports auto-focus; there is
currently no way to manage this from javascript.
iOS
defaultOnFocusComponent
Values:
true
(default)
false
If defaultOnFocusComponent
set to false, default internal implementation of visual feedback for tap-to-focus gesture will be disabled.
iOS
onZoomChanged: Event { nativeEvent: { velocity, zoomFactor } }
iOS: Called when focus has changed.
By default, onZoomChanged
is not defined and pinch-to-zoom is disabled.
Android: This callback is not yet implemented. However, Android will
automatically handle pinch-to-zoom; there is currently no way to manage this
from javascript.
iOS
keepAwake
If set to true
, the device will not sleep while the camera preview is visible. This mimics the behavior of the default camera app, which keeps the device awake while open.
mirrorImage
If set to true
, the image returned will be mirrored.
fixOrientation
(deprecated)If set to true
, the image returned will be rotated to the right way up. WARNING: It uses a significant amount of memory and my cause your application to crash if the device cannot provide enough RAM to perform the rotation.
(If you find that you need to use this option because your images are incorrectly oriented by default,
could please submit a PR and include the make model of the device. We believe that it’s not
required functionality any more and would like to remove it.)
You can access component methods by adding a ref
(ie. ref="camera"
) prop to your <Camera>
element, then you can use this.refs.camera.capture(cb)
, etc. inside your component.
capture([options]): Promise
Captures data from the camera. What is captured is based on the captureMode
and captureTarget
props. captureMode
tells the camera whether you want a still image or video. captureTarget
allows you to specify how you want the data to be captured and sent back to you. See captureTarget
under Properties to see the available values.
Supported options:
audio
(See captureAudio
under Properties)mode
(See captureMode
under Properties)target
(See captureTarget
under Properties)metadata
This is metadata to be added to the captured image.
location
This is the object returned from navigator.geolocation.getCurrentPosition()
(React Native’s geolocation polyfill). It will add GPS metadata to the image.rotation
This will rotate the image by the number of degrees specified.jpegQuality
(integer between 1 and 100) This property is used to compress the output jpeg file with 100% meaning no jpeg compression will be applied.totalSeconds
This will limit video length by number of seconds specified. Only works in video capture mode.The promise will be fulfilled with an object with some of the following properties:
data
: Returns a base64-encoded string with the capture data (only returned with the deprecated Camera.constants.CaptureTarget.memory
)path
: Returns the path of the captured image or video file on diskwidth
: (currently iOS video only) returns the video file’s frame widthheight
: (currently iOS video only) returns the video file’s frame heightduration
: (currently iOS video only) video file durationsize
: (currently iOS video only) video file size (in bytes)iOS
getFOV(): Promise
Returns the camera’s current field of view.
hasFlash(): Promise
Returns whether or not the camera has flash capabilities.
stopCapture()
Ends the current capture session for video captures. Only applies when the current captureMode
is video
.
iOS
Camera.checkDeviceAuthorizationStatus(): Promise
Exposes the native API for checking if the device has authorized access to the camera (camera and microphone permissions). Can be used to call before loading the Camera component to ensure proper UX. The promise will be fulfilled with true
or false
depending on whether the device is authorized. Note, as of iOS 10, you will need to add NSCameraUsageDescription
and NSMicrophoneUsageDescription
to your XCode project’s Info.plist file or you might experience a crash.
iOS
Camera.checkVideoAuthorizationStatus(): Promise
The same as Camera.checkDeviceAuthorizationStatus()
but only checks the camera permission. Note, as of iOS 10, you will need to add NSCameraUsageDescription
to your XCode project’s Info.plist file or you might experience a crash.
iOS
Camera.checkAudioAuthorizationStatus(): Promise
The same as Camera.checkDeviceAuthorizationStatus()
but only checks the microphone permission. Note, as of iOS 10, you will need to add NSMicrophoneUsageDescription
to your XCode project’s Info.plist file or you might experience a crash.
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.
To see more of the react-native-camera
in action, you can check out the source in Example folder.
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.
Author: react-native-community
Live Demo: https://react-native-community.github.io/react-native-camera/
GitHub: https://github.com/react-native-community/react-native-camera
#react-native #programming
1598839687
If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?
In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.
Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.
React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.
Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.
Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.
The popularity of React Native comes from its advantages. Some of its advantages are as follows:
Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.
React Native is very close to native. Consider the following aspects as described on the React Native website:
Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.
#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native
1593420654
Have you ever thought of having your own app that runs smoothly over multiple platforms?
React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. Hire Dedicated React Native Developer from top React Native development company, HourlyDeveloper.io to design a spectacular React Native application for your business.
Consult with experts:- https://bit.ly/2A8L4vz
#hire dedicated react native developer #react native development company #react native development services #react native development #react native developer #react native
1616494982
Being one of the emerging frameworks for app development the need to develop react native apps has increased over the years.
Looking for a react native developer?
Worry not! WebClues infotech offers services to Hire React Native Developers for your app development needs. We at WebClues Infotech offer a wide range of Web & Mobile App Development services based o your business or Startup requirement for Android and iOS apps.
WebClues Infotech also has a flexible method of cost calculation for hiring react native developers such as Hourly, Weekly, or Project Basis.
Want to get your app idea into reality with a react native framework?
Get in touch with us.
Hire React Native Developer Now: https://www.webcluesinfotech.com/hire-react-native-app-developer/
For inquiry: https://www.webcluesinfotech.com/contact-us/
Email: sales@webcluesinfotech.com
#hire react native developers #hire dedicated react native developers #hire react native developer #hiring a react native developer #hire freelance react native developers #hire react native developers in 1 hour
1626928787
Want to develop app using React Native? Here are the tips that will help to reduce the cost of react native app development for you.
Cost is a major factor in helping entrepreneurs take decisions about investing in developing an app and the decision to hire react native app developers in USA can prove to be fruitful in the long run. Using react native for app development ensures a wide range of benefits to your business. Understanding your business and working on the aspects to strengthen business processes through a cost-efficient mobile app will be the key to success.
#best react native development companies from the us #top react native app development companies in usa #cost of hiring a react native developer in usa #top-notch react native developer in usa #best react native developers usa #react native
1623299374
React Native allows developers to develop mobile apps that have compatibility with Android, iOS & other operating systems. Due to the features like Native-like functionality and single code reusability and the access of various frameworks in the market, React Native has excelled as the most suitable framework for cross-platform mobile app development.
Why Do Businesses Prefer React Native App Development?
React Native is integrated with JS library that works as the fundamental for developing the app UI. Most businesses choose for developing React Native apps just due to their cross-platform & open-source features. A few further reasons why entrepreneurs & developers choose React Native app development include:
• Lowered Expedition Time
• Simple UI
• Cross-Platform and Code Sharing
• Lesser Workforce and Resources
• Community Assistance
• In-Built Elements and Reusable Codes
• Hot Reload
• JavaScript as Programming Language
• Easy to Execute Updates
Factors That Decide Cost of React Native App Development
If you are an entrepreneur or start-up and looking for cost-effective app development, React Native is one of the ideal options available out there.
• App’s UI/UX Design
• User Authorization
• App Complexity and Functionality
• App Development Team
• App Maintenance
• App Add-ons
• App Distribution
• Location of Development Company
• App Category
React Native cost depends widely on the complexity of a project or the app requirements. The price may also vary based on business requirements. React Native app development per hour can cost from $20 and $30 per hour in India. It can vary as per different locations.
Is React Native a good choice for mobile apps development?
Yes, React Native is the best choice for mobile app development as React apps are faster to develop and it offers better quality than hybrid apps. Additionally, React Native is a mature cross-platform framework.
Best React Native App Development Agency
AppClues Infotech is a leading React Native App Development Company in USA that build robust & innovative mobile app as per your specific business needs. They have a dedicated team of designers and programmers help to make a perfect mobile app.
If you have any mobile app development project in mind get in touch with AppClues Infotech and get the best solution for your business.
#react native app development cost #react native development company #best react native development company in usa #hire react native developers #hire dedicated react native developers & programmers #hire a react native development company