Well, it took me all day, but I finally found a library that worked. If someone finds their way here and is looking for a barcode scanner to respond to their native one that works on android ... I am here to help.
https://github.com/ideacreation/react-native-barcodescanner
If you donβt have rnpm get it ... this is very useful! (npm install -g rnpm) ( https://github.com/rnpm/rnpm )
then run these commands in the project file:
npm install --save response-native-barcodescanner
rnpm link react-native-barcodescanner
at that moment I synchronized gradle and restarted the application from Android studios ... not sure if this is necessary (also sometimes the rnpm link forgets a new line character ... if you have an error message regarding the word include this is because it is. .. just find it in your setup.gradle file add a new line before the word is included)
Now it is ready to use.
import it:
import BarcodeScanner from 'react-native-barcodescanner';
then use it in the return status of the render function:
<BarcodeScanner onBarCodeRead={this._BarCodeRead} style={styles.preview} torchMode='off' cameraType='back' />
If you need more information, check out this link. Hope this helped someone avoid the torture that I went through the library after the old library, which didn't work.
Happy coding! :)
source share