react-native-qrcode-gen
v1.0.4
Published
RN library to generate Text encoded QRcodes
Downloads
7
Maintainers
Readme
react-native-qrcode-gen
On iOS, it uses CIQRCodeGenerator
as a CIFilter to generate a UIImage
On Android, it uses QRGenearator
, a wrapper library for ZXing
(Crossing-zebra)
$ npm install react-native-qrcode-gen --save
Prerequisite
If the iOS target does not already contain Swift classes
Build Settings > Library Search Path > $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
Build Settings > Build Options > Always Embed Swift Standard Libraries > YES
Mostly automatic installation
$ react-native link react-native-qrcode-gen
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-qrcode-gen
and addRNQrcodeGen.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNQrcodeGen.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.RNQrcodeGenPackage;
to the imports at the top of the file - Add
new RNQrcodeGenPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-qrcode-gen' project(':react-native-qrcode-gen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qrcode-gen/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-qrcode-gen')
Usage
import React from 'react';
import { StyleSheet } from 'react-native';
import QrcodeView from 'react-native-qrcode-gen';
const styles = StyleSheet.create({
qrcode: {
width: 320,
height: 320,
},
});
export default () => (
<QrcodeView
value={'string value to encode'}
style={styles.qrcode}
/>
);
Available Props
prop | type | default value
----------|----------------------|--------------
value
| string
| -