图像文件中的QR码解码器(本机反应)

时间:2018-08-19 19:11:45

标签: react-native qr-code expo

我正在寻找一种在React Native中(具体是iOS)从图像文件中解码二维码的方法...我知道expo提供了相机扫描仪解决方案...但是我需要文件解码器

非常感谢您的帮助。

4 个答案:

答案 0 :(得分:0)

您可以使用jsQR library从图像文件中读取QR码。要从存储中选择文件,您可以尝试React Native Image Picker library

答案 1 :(得分:0)

也许您可以使用此react-native-qrcode-local-image

答案 2 :(得分:0)

正在回答我自己的问题...

我详细发布了我提出的解决方案in this blog post

最后的代码是Available on Github

答案 3 :(得分:0)

您可以使用rn-qr-generator来解码图像中的QR码。

import RNQRGenerator from 'rn-qr-generator';

RNQRGenerator.detect({
  uri: PATH_TO_IMAGE, // local path of the image. Can be skipped if base64 is passed.
  base64: imageBase64String, // If uri is passed this option will be skipped.
})
  .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));

它将返回检测到的QR码值的数组 在iOS和Android平台上效果很好。

相关问题