react-native-google-code-scanner-android
v1.2.4
Published
React Native wrapper for Google Code Scanner API (Android only)
Readme
react-native-google-code-scanner-android
React Native wrapper for Google Code Scanner API (Android only)
⚠️ Recommendation: While this library is fully functional, I suggest using Expo Camera for most projects.
It supports code scanning with a similar approach, works on iOS, and is actively maintained with strong community support, making it the more reliable long‑term option.
Installation
npm install react-native-google-code-scanner-androidExclude platforms other than Android
// react-native.config.js
module.exports = {
dependencies: {
// ...
'react-native-google-code-scanner-android': {
platforms: {
ios: null,
// web: null,
// windows: null,
// macos: null,
},
},
},
};Usage
import {
initialize,
scan,
BarcodeFormat,
checkModuleAvailability,
installModule,
subscribeToInstallProgress,
} from 'react-native-google-code-scanner-android';
// ...
// initialize the api (needed before scan)
initialize({
barcodeFormats: [BarcodeFormat.FORMAT_ALL_FORMATS],
enableAutoZoom: true,
allowManualInput: true,
});
// ...
// scan for codes
await scan(
(barcode: string) => {
// on code available
setResult(barcode);
},
(error: string) => {
// on receiving error
console.error(error);
}
);
// ...
// check if the module is available
const isAvailable = await checkModuleAvailability();
if (!isAvailable) {
// install the module
const isInstalled = await installModule();
}
// ...
// subscribe to install progress
subscribeToInstallProgress((progress) => {
console.log(`Install progress: ${progress}%`);
});Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library
