react-native-qr-gallery
v1.0.11
Published
Library to select an image from image gallery and read QR code from it
Downloads
30
Readme
react-native-qr-gallery
Library to select an image from image gallery and read QR code from it
Getting started
$ npm install react-native-qr-gallery --save
Mostly automatic installation
$ react-native link react-native-qr-gallery
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-qr-gallery
and addRNQrGallery.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNQrGallery.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNQrGalleryPackage;
to the imports at the top of the file - Add
new RNQrGalleryPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-qr-gallery' project(':react-native-qr-gallery').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qr-gallery/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-qr-gallery')
Usage
import RNQrGallery from 'react-native-qr-gallery';
try {
const data = await RNQrGallery.readQRCode();
if (data === 'CANCEL') {
return;
}
alert(data);
} catch (e) {
console.log('onError', e);
}