A QR decode module for React Native.
npm install react-native-qr-decoder@latest --save
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-qr-decoder
and addreact-native-qr-decoder.xcodeproj
- In XCode, in the project navigator, select your project. Add
libreact-native-qr-decoder.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Click
react-native-qr-decoder.xcodeproj
in the project navigator and go theBuild Settings
tab. Make sure 'All' is toggled on (instead of 'Basic'). In theSearch Paths
section, look forHeader Search Paths
and make sure it contains both$(SRCROOT)/../../react-native/React
and$(SRCROOT)/../../../React
- mark both asrecursive
. - Run your project (
Cmd+R
)
All you need is to require
the react-native-qr-decoder
module
var QRDecoder = require('NativeModules').React_native_qr_decoder;
var path = "your qr code full path";
// From local File
QRDecoder.get(path, (error, qrcode) => {
console.log(qrcode);
if (error) {
console.log(error);
return
} else {
console.log(qrcode);
// this.setState({qrcode: qrcode});
}
});