Giter Club home page Giter Club logo

rn-qr-generator's Introduction

rn-qr-generator

https://www.npmjs.com/package/rn-qr-generator

Getting started

$ npm install rn-qr-generator --save

Mostly automatic installation

$ react-native link rn-qr-generator


Important:

Linking is not needed anymore. [email protected]+ 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 ../

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesrn-qr-generator and add RNQrGenerator.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNQrGenerator.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.gevorg.reactlibrary.RNQrGeneratorPackage; to the imports at the top of the file
  • Add new RNQrGeneratorPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/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')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
    dependencies {
    + compile project(':rn-qr-generator')
    }

Usage

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));

generate

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.

detect

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:

  • UPC-A and UPC-E
  • EAN-8 and EAN-13
  • Code 39
  • Code 93
  • Code 128
  • ITF
  • Codabar
  • RSS-14 (all variants)
  • QR Code
  • Data Matrix
  • Maxicode
  • Aztec ('beta' quality)
  • PDF 417 ('beta' quality)

example

Example of 2FA QR code with Time Based (TOTP) or Counter Based (HOTP)

RNQRGenerator.generate({
  ...
  value: 'otpauth://totp/Example:[email protected]?secret=HKSWY3RNEHPK3PXP&issuer=Issuer',
})

More information about totp can be found here.

This module uses Zxing library for encoding and decoding codes ( ios, Android).

Note

Some simulators may not generate qr code properly. Use real device if you get an error.

rn-qr-generator's People

Contributors

dependabot[bot] avatar gevgasparyan avatar muhamad-rizki avatar seancheung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rn-qr-generator's Issues

iOS detect got error crash

"react-native": "0.64.2"
"rn-qr-generator": "^1.2.0"

- (UIImage *)imageFromPath:(NSString *)path
{
    NSURL *imageURL = [NSURL URLWithString:path];
    NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
    return [UIImage imageWithData:imageData];
}

path __NSCFString * @"/private/var/mobile/Containers/Data/Application/1516CFE1-84D5-4CA4-BD6D-96FB06D36C02/tmp/react-native-image-crop-picker/7DC4C4CD-26F6-4A98-A9DE-70C1A550D38A.jpg"

imageData get nil

[iOS] object cannot be nil

Hey guys!

I get this error when use this image: https://i.imgur.com/QVcnOb7.png

ExceptionsManager.js:126 Exception '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil' was thrown while invoking detect on target RNQrGenerator with params ( { uri = "https://i.imgur.com/QVcnOb7.png"; }, 3580, 3581 ) callstack: ( 0 CoreFoundation 0x00007fff20420af6 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48 2 CoreFoundation 0x00007fff2049d77f _CFThrowFormattedException + 194 3 CoreFoundation 0x00007fff2049b656 -[__NSArrayM insertObject:atIndex:].cold.2 + 0 4 CoreFoundation 0x00007fff2031e678 -[__NSArrayM insertObject:atIndex:] + 1134 5 CarOCRApp 0x000000010ff263c1 __56-[RNQrGenerator detect:failureCallback:successCallback:]_block_invoke + 145 6 CoreFoundation 0x00007fff2039239f __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 7 7 CoreFoundation 0x00007fff2031ea34 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 224 8 CarOCRApp 0x000000010ff25fa0 -[RNQrGenerator detect:failureCallback:successCallback:] + 1728 9 CoreFoundation 0x00007fff204272fc __invoking___ + 140 10 CoreFoundation 0x00007fff204247b6 -[NSInvocation invoke] + 303 11 CoreFoundation 0x00007fff20424a47 -[NSInvocation invokeWithTarget:] + 70 12 CarOCRApp 0x000000011004d3b4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2660 13 CarOCRApp 0x000000011005155e _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 814 14 CarOCRApp 0x0000000110051026 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 134 15 CarOCRApp 0x0000000110050f8c ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28 16 libdispatch.dylib 0x00000001115c47ec _dispatch_call_block_and_release + 12 17 libdispatch.dylib 0x00000001115c59c8 _dispatch_client_callout + 8 18 libdispatch.dylib 0x00000001115d3e75 _dispatch_main_queue_callback_4CF + 1152 19 CoreFoundation 0x00007fff2038edbb __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 20 CoreFoundation 0x00007fff2038963e __CFRunLoopRun + 2685 21 CoreFoundation 0x00007fff203886d6 CFRunLoopRunSpecific + 567 22 GraphicsServices 0x00007fff2bededb3 GSEventRunModal + 139 23 UIKitCore 0x00007fff24690e0b -[UIApplication _run] + 912 24 UIKitCore 0x00007fff24695cbc UIApplicationMain + 101 25 CarOCRApp 0x000000010fe520c0 main + 112 26 libdyld.dylib 0x00007fff202593e9 start + 1 )

Additional Info: I think can't read :' ┐�c�J后山三三質撒撒燦惨'

Could not find image error for bigger data value

Hi there,

I get this error Could not find image file:///var/mobile/Containers/../QRCode/E90..A0.png if I use a Base64 string for a data content of 2 or more RS256 JWT tokens like that:

const data = {
  data: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.NHVaYe26MbtOYhSKkoKYdFVomg4i8ZJd8_-RU8VNbftc4TSMb4bXP3l3YlNWACwyXPGffz5aXHc6lty1Y2t4SWRqGteragsVdZufDn5BlnJl9pdR_kdVFUsra2rWKEofkZeIC4yWytE58sMIihvo9H1ScmmVwBcQP6XETqYd0aSHp1gOa9RdUPDvoXQ5oqygTqVtxaDr6wUFKrKItgBMzWIdNZ6y7O9E0DhEPTbE9rfBo6KTFsHAZnMg4k68CDp2woYIaXbmYTWcvbzIuHO7_37GT79XdIwkm95QJ7hYC9RiwrV7mesbY4PAahERJawntho0my942XheVLmGwLMBkQ',
  value: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.NHVaYe26MbtOYhSKkoKYdFVomg4i8ZJd8_-RU8VNbftc4TSMb4bXP3l3YlNWACwyXPGffz5aXHc6lty1Y2t4SWRqGteragsVdZufDn5BlnJl9pdR_kdVFUsra2rWKEofkZeIC4yWytE58sMIihvo9H1ScmmVwBcQP6XETqYd0aSHp1gOa9RdUPDvoXQ5oqygTqVtxaDr6wUFKrKItgBMzWIdNZ6y7O9E0DhEPTbE9rfBo6KTFsHAZnMg4k68CDp2woYIaXbmYTWcvbzIuHO7_37GT79XdIwkm95QJ7hYC9RiwrV7mesbY4PAahERJawntho0my942XheVLmGwLMBkQ'
}
const jsonString = JSON.stringify(data)
const base64String = base64.decode(jsonString)

RNQRGenerator.generate({
  value: base64String,
  height: 300,
  width: 300,
})
.then((response) => {
  const { uri, width, height, base64 } = response
  console.log(uri)
})
.catch((error) => console.log('Cannot create QR code', error))

In my case I want to store 3 JWT token.

`import`ing `RNQRGenerator` fails in `detox` e2e tests (which uses `jest`)

Q. Is this library usable in jest tests?

Setup: I have a React Native app (expo) with e2e testing using the detox library (which uses jest internally).

Scenario: When I try to import RNQRGenerator (using import and/or require) from inside a test file, I get the following error:

13:34:19.398 detox[7863] B jest --config e2e/jest.config.js e2e/qrCodeScreen.test.ts
 FAIL  e2e/qrCodeScreen.test.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    /Volumes/ExtDisk1/learning/docker/e2e-testing-demo/app/node_modules/rn-qr-generator/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import {NativeModules, Platform, processColor} from 'react-native';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      3 | import { swipeIntros } from './swipeIntroSlider'
      4 | import { getText, VISUAL_ELEMENTS_TIMEOUT } from '../components/helpers'
    > 5 | import RNQRGenerator from 'rn-qr-generator'
        | ^
      6 |
      7 | describe('QR Code Screen', () => {
      8 |   beforeAll(async () => {

      at Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1505:14)
      at Object.<anonymous> (e2e/qrCodeScreen.test.ts:5:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        5.997 s
Ran all test suites matching /e2e\/qrCodeScreen.test.ts/i.
13:34:26.158 detox[7863] E Command failed with exit code = 1:
jest --config e2e/jest.config.js e2e/qrCodeScreen.test.ts

I can import other libraries in test files (like axios) without any issues.

I can provide more context, if needed.

Detect not working on Android

Opening an QR code in iOS works fine but for Android less so; it's not able to find the QR code in the image. I've attached it for testing. This image is fake data and does not represent a real person. The image below comes in as base64 encoded which I pass into detect; Like I said above, iOS nails it 100% of the time so I believe my RN code to be valid.

image001

Got "IMAGE_NOT_FOUND" in RNQRGenerator.detect

Hi . When I'm trying the example

const onPick = () => { launchImageLibrary(options, (response) => { setDetectImageUri({uri: response.uri}); RNQRGenerator.detect({uri: response.uri}) .then((res) => { if (res.values.length === 0) { setDetectedValues(['QR code not found']); } else { setDetectedValues(res.values); } }) .catch((err) => { console.log('Cannot detect', err); }); }); };

the URI from launchImageLibrary is :

"content://com.easysandbox.imagepickerprovider/cacheDir/rn_image_picker_lib_temp_10ae8dce-7af8-4bca-b4f4-e7f50ece1157.jpg"

but when it RNQRGenerator.detect I got error like

Possible Unhandled Promise Rejection (id: 1): "IMAGE_NOT_FOUND"

Do you have any suggestions for my issue?

I'm using
react-native: 0.60.6
version of android is :10

Anyways thank you for creating such a good library it's easy to use and makes everything easier.

Android 6 crash

Android 6 crashes on runtime;

v1.3.1 -> Android 6 crashes on runtime
v1.2.1 -> working

Wrong characters in QR code generation

Hi guys,

First, thanks for the work done on this library, it is pretty straightforward and reliable.

Then, I ran in a very strange behavior today. I create an app where I need to generate a QR code with some data in it at some point, and scan it later to retrieve the data. The text, of course, must (and should) be the same at the creation and at the scan.

In the text, I separate data with special characters: § and µ
The problem is that these two characters are somehow replaced by the characters ァ and オ between creation and scan, but only with a short text. When the text is longer, § and µ are correctly retrieved. I can't find an explanation.

To reproduce:

First (short)

Original string : 1§Name§0µ10
Resulting QR code:
image

Resulting QR code scanned text : 1ァNameァ0オ10

Second (long)

Original string : 1§Name§0µ10|11|12|13|14|15|16|17|18|19|110|111|112|113
Resulting QR code:
image

Resulting QR code scanned text : 1§Name§0µ10|11|12|13|14|15|16|17|18|19|110|111|112|113

I generate the QR code in base64 with the following code:

const QRCodeImageSize = Dimensions.get('window').height * 0.4;
    RNQRGenerator.generate({
      value: QRCodeData, // as mentioned above
      height: QRCodeImageSize * 5,
      width: QRCodeImageSize * 5,
      base64: true,
      backgroundColor: Styles.COLORS.THEME_WHITE_DARKER,
      padding: {
        top: 0,
        bottom: 0,
        left: 0,
        right: 0,
      },
      correctionLevel: 'L',
    })

Any help will be appreciated.

nil string argument was thrown while invoking detect on target rnqrgenerator with params

hello!
I am trying to use qrcode detect.
It works fine on Android, but I get an error like the title on ios.
Could you help me?
Here's the code:
RNQRGenerator.detect({ uri: uri, }) .then(response => { const { values } = response;// Array of detected QR code values. Empty if nothing found. submit(values); }) .catch(error => { console.log(error) if(setNotFound) setNotFound(true) navigation.goBack() });

PhonePe QR detect is not working

PhonePe QR detection is not working. Getting empty response

const ScanQrCodeFromGallery = () => {
ImagePicker.openPicker({
width: 150,
height: 150,
cropping: false,
includeBase64: true,
})
.then(async (images) => {
const imagePath = images?.path;
const base64ImgId = await RNFS.readFile(imagePath, 'base64')
RNQRGenerator.detect({
base64: base64ImgId
})
.then(response => {
const { values } = response;
onSuccess(values?.[0]);
let galleryImage=true
setisQrFromGallery(galleryImage)
})
.catch(error => {
console.log("Your Scan QR is Invalid.")
});
})
.catch((error) => {
if ( JSON.stringify(error).includes('User cancelled image selection')){
return;
}
else {
console.log("Your Scan QR is Invalid.")
}
})
}

how to show QRCode in image

i am getting this in uri response file:///data/data/com.qrcode/cache/ad58bfa6-994b-48df-9b9a-c6b79d3ef498.png
how can i show with this uri in image i did {{uri:file:///data/data/com.qrcode/cache/ad58bfa6-994b-48df-9b9a-c6b79d3ef498.png}}
but nothing happend

Building Android fails on rn-qr-generator:verifyReleaseResources task

Hi there!

Thanks for doing this project. It's notably faster to render QRCode with it than with other SVG-based solutions I've tried.

I'm trying to add this module to my project and everything worked fine when running iOS' simulator. But when I tried running this on both an emulator and a real device, and the build failed with the message below.

Any tips on how to fix it, or how to debug the issue?

> Task :rn-qr-generator:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':rn-qr-generator:verifyReleaseResources'.
> 1 exception was raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
  error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:7: error: resource android:attr/colorError not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:11: error: resource android:attr/colorError not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2740: error: resource android:attr/fontStyle not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2741: error: resource android:attr/font not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2742: error: resource android:attr/fontWeight not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2743: error: resource android:attr/fontVariationSettings not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2744: error: resource android:attr/ttcIndex not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2908: error: resource android:attr/startX not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2911: error: resource android:attr/startY not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2914: error: resource android:attr/endX not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2917: error: resource android:attr/endY not found.
  myapp/node_modules/rn-qr-generator/android/build/intermediates/res/merged/release/values/values.xml:2925: error: resource android:attr/offset not found.
  error: failed linking references.
  


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 8m 27s
1311 actionable tasks: 1180 executed, 131 up-to-date
error Failed to build the app. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew build -x lint
    at makeError (myapp/node_modules/execa/index.js:174:9)
    at Function.module.exports.sync (myapp/node_modules/execa/index.js:338:15)
    at buildApk (myapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:190:22)
    at runOnSpecificDevice (myapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:171:7)
    at buildAndRun (myapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:156:12)
    at then.result (myapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Detection is not working on Android

We are trying to detect multiple QRCodes from a single image. On iOS everything works fine, but on Android it returns an empty array of values.

An example image we are trying to use is the following: https://github.com/gevgasparyan/rn-qr-generator/assets/6160324/9b6f506e-c636-4c6b-8668-b9f1ea9dd9f0

The online ZXing decoder works fine: https://zxing.org/w/decode?u=https%3A%2F%2Fgithub.com%2Fgevgasparyan%2Frn-qr-generator%2Fassets%2F6160324%2F9b6f506e-c636-4c6b-8668-b9f1ea9dd9f0

This issue does not appear to be related to device type or Android version, we see it on multiple Android devices.

QR Image not generated on iOS < 13

Thanks for a good package, it's works well.

However, I'm having some issues when using iOS 12 (also tried iOS 11) where the generated QR image is nil.

This is not an issue with iOS 13 - the library works as it should both in simulator and when building to a device when on iOS 13.

The issue seems to be this line (or at least it manifests itself there) https://github.com/gevgasparyan/rn-qr-generator/blob/master/ios/RNQrGenerator.m#L57

i.e. NSData *qrData = UIImagePNGRepresentation(image); - I've been debugging this and even though image is defined here, UIImagePNGRepresentation(image) returns nil so qrData is nil for the rest of the program.

This only happens in iOS 12 (both when using simulator and building to device) but not in iOS 13.

Do you have any ideas how this can be fixed?

Detect

How to read a DataMatrix, in my case return [] ( empty array )

Example QR

Captura de Tela 2021-10-11 às 00 45 21

Could not find module RNQRGenerato

Hello,

I got an issue that I dont find a way to resolve.
Juste tried this module on my expo app and can't make it work.

I've done :
$ npm install rn-qr-generator --save
and
cd ios && pod install && cd ../

But when my app is launch on the iOS simulator, I got this error :
Could not find module "RNQrGenerator".
Did you forget to run "pod install" ?
at node_modules/rn-qr-generator/index.js:6:8 in
at http://127.0.0.1:19000/index.bundle?platform=ios&dev=true&hot=false&minify=false:478471:57 in
at App.js:28:0 in
at index.js:3:0 in
at http://127.0.0.1:19000/index.bundle?platform=ios&dev=true&hot=false&minify=false:479139:3 in global code

Any help ?
Thanks

Detect not working on Android [QR on slip]

Hello!

I am trying to use qrcode detect.
It works fine on ios, but I get nothing on android, like this.

{"type": "", "values": []}

Could you help me?
Here's the code:

const openImageFromGallery = async () => {
    try {
      setIsCloseCamera(true)

      const image = await ImagePicker.openPicker({
        width: width,
        height: height,
        mediaType: 'photo',
      })

      const base64ImgId = await RNFS.readFile(image.path, 'base64')
      const response = await RNQRGenerator.detect({
        uri: image.path,
        base64: base64ImgId,
      })

      if (!_.isEmpty(response.values)) {
        setCode([{ displayValue: response.values[0] }])
      } else {
        setIsCloseCamera(false)
        setIsShowPopupQrInvalid(!isShowPopupQrInvalid)
      }
    } catch (error) {
      console.error('🚀 ~ openImageFromGallery ~ error', error)
      return
    }
  }

this QR code I scan

Screen Shot 2565-10-11 at 17 04 35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.