react-native-google-code-scanner-android
v1.0.6
Published
React Native wrapper for Google Code Scanner API (Android only)
Downloads
47
Readme
react-native-google-code-scanner-android
React Native wrapper for Google Code Scanner API (Android only)
Installation
npm install react-native-google-code-scanner-android
Exclude 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,
} 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);
}
);
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