@asif-pindi/react-native-custom-camera
v1.0.4
Published
Camera
Readme
@asif-pindi/react-native-custom-camera
A custom React Native native module for opening the device camera.
Installation
Install the package in a React Native app:
npm install @asif-pindi/react-native-custom-cameraor:
yarn add @asif-pindi/react-native-custom-cameraAfter installing or updating a native module, rebuild the native app:
npx react-native run-androidUsage
Import and call openCamera:
import { openCamera } from '@asif-pindi/react-native-custom-camera';
openCamera();Button example:
import { Button, View } from 'react-native';
import { openCamera } from '@asif-pindi/react-native-custom-camera';
export default function App() {
return (
<View>
<Button title="Open Camera" onPress={() => void openCamera()} />
</View>
);
}Android Permission
The package declares the Android camera permission. Android will ask the user for camera permission the first time the camera opens.
If permission is denied, call openCamera() again after the user enables camera permission from app settings.
Platform Support
- Android: supported.
- iOS: native files are included, but camera opening behavior currently needs iOS implementation.
- Web: not supported.
openCamera()rejects with an unsupported-platform error.
Example App
Clone the repository and install dependencies:
git clone https://github.com/asifali741/react-native-custom-camera.git
cd react-native-custom-camera
yarn installStart Metro:
yarn example startRun the Android example:
yarn example androidUpdating The Package
When a new version is published, update it in your app:
npm install @asif-pindi/react-native-custom-camera@latestor:
yarn add @asif-pindi/react-native-custom-camera@latestThen rebuild the native app.
License
MIT
