
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
rn-qr-generator
Advanced tools
https://www.npmjs.com/package/rn-qr-generator
$ npm install rn-qr-generator --save
$ react-native link rn-qr-generator
Linking is not needed anymore. react-native@0.60.0+
supports dependencies auto linking.
For iOS you also need additional step to install auto linked Pods (Cocoapods should be installed):
cd ios && pod install && cd ../
Libraries
➜ Add Files to [your project's name]
node_modules
➜ rn-qr-generator
and add RNQrGenerator.xcodeproj
libRNQrGenerator.a
to your project's Build Phases
➜ Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.gevorg.reactlibrary.RNQrGeneratorPackage;
to the imports at the top of the filenew RNQrGeneratorPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
rootProject.name = 'MyApp'
include ':app'
+ include ':rn-qr-generator'
+ project(':rn-qr-generator').projectDir = new File(rootProject.projectDir, '../node_modules/rn-qr-generator/android')
android/app/build.gradle
:
dependencies {
+ compile project(':rn-qr-generator')
}
import RNQRGenerator from 'rn-qr-generator';
RNQRGenerator.generate({
value: 'https://github.com/gevgasparyan/rn-qr-generator',
height: 100,
width: 100,
})
.then(response => {
const { uri, width, height, base64 } = response;
this.setState({ imageUri: uri });
})
.catch(error => console.log('Cannot create QR code', error));
// Detect QR code in image
RNQRGenerator.detect({
uri: PATH_TO_IMAGE
})
.then(response => {
const { values } = response; // Array of detected QR code values. Empty if nothing found.
})
.catch(error => console.log('Cannot detect QR code in image', error));
input properties
Property | Type | Description |
---|---|---|
value | string | Text value to be converted into QR image. (required) |
width | number | Width of the QR image to be generated. (required) |
height | number | Height of the QR image to be generated. (required) |
backgroundColor | string | Background color of the image. (white by default) |
color | string | Color of the image. (black by default) |
fileName | string | Name of the image file to store in FileSystem. (optional) |
correctionLevel | string | Data restoration rate for total codewords. Available values are 'L', 'M', 'Q' and 'H'. ('H' by default) |
base64 | boolean | If true will return base64 representation of the image. (optional, false by default) |
padding | Object | Padding params for the image to be generated: {top: number, left: number, bottom: number, right: number}. (default no padding) |
payload
Property | Type | Description |
---|---|---|
uri | string | Path of the generated image. |
width | number | Width of the generated image. |
height | number | Height of the generated image. |
base64 | boolean | Base64 encoded string of the image. |
input properties
Property | Type | Description |
---|---|---|
uri | string | Local path of the image. Can be skipped if base64 is passed. |
base64 | string | Base64 representation of the image to be scanned. If uri is passed this option will be skipped. |
payload
Property | Type | Description |
---|---|---|
values | string[] | Array of detected QR code values. Empty if nothing found. |
type | string | Type of detected code. |
The following barcode types are currently supported for decoding:
Example of 2FA QR code with Time Based (TOTP) or Counter Based (HOTP)
RNQRGenerator.generate({
...
value: 'otpauth://totp/Example:google@google.com?secret=HKSWY3RNEHPK3PXP&issuer=Issuer',
})
More information about totp can be found here.
This module uses Zxing
library for encoding and decoding codes ( ios, Android).
Some simulators may not generate qr code properly. Use real device if you get an error.
FAQs
React native QR Code generator / reader
The npm package rn-qr-generator receives a total of 10,099 weekly downloads. As such, rn-qr-generator popularity was classified as popular.
We found that rn-qr-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.