All Projects → watanabeyu → react-native-qrimage-decoder

watanabeyu / react-native-qrimage-decoder

Licence: MIT license
QR image decoder for React Native

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to react-native-qrimage-decoder

Qrcode
qrcode scanner ( decoder ) by golang 二维码扫描识别
Stars: ✭ 233 (+1692.31%)
Mutual labels:  qrcode
react-native-todo
Todo-List app using react-native SwipeView and redux.js with ES6 standards
Stars: ✭ 77 (+492.31%)
Mutual labels:  expo
kanban-board-app
Kanban style task management board app
Stars: ✭ 118 (+807.69%)
Mutual labels:  qrcode
Qrcodereader
Barcode and QR code reader built in Swift
Stars: ✭ 237 (+1723.08%)
Mutual labels:  qrcode
DCC-green-pass-decoder
A simple web app to decode EU Digital Covid Certificate/Green Pass QR codes.
Stars: ✭ 42 (+223.08%)
Mutual labels:  qrcode
ZZYQRCode
a scanner for QRCode barCode 最好用的ios二维码、条形码,扫描、生成框架,支持闪光灯,从相册获取,扫描音效等,高仿微信,微博
Stars: ✭ 124 (+853.85%)
Mutual labels:  qrcode
Instascan
HTML5 QR code scanner using your webcam
Stars: ✭ 2,657 (+20338.46%)
Mutual labels:  qrcode
Secure-QR-Reader
Privacy Focused and Secure QR Reader
Stars: ✭ 32 (+146.15%)
Mutual labels:  qrcode
tasit-apps
Native mobile Ethereum dapps for mainstream users
Stars: ✭ 35 (+169.23%)
Mutual labels:  expo
photos
"Fx Fotos" is an opensource gallery app in react native with the same smoothness and features of Google Photos and Apple Photos. It is backend gnostic and connects to decentralized backends like "box", "Dfinity", "Filecoin" and "Crust".
Stars: ✭ 620 (+4669.23%)
Mutual labels:  expo
taro-code
Taro Barcode & QRCode
Stars: ✭ 88 (+576.92%)
Mutual labels:  qrcode
expo-video-player
Customizable Video Player controls for Expo
Stars: ✭ 174 (+1238.46%)
Mutual labels:  expo
4noobs-mobile
App mobile do 4Noobs
Stars: ✭ 69 (+430.77%)
Mutual labels:  expo
Oneqrcode
📱 微信、支付宝、QQ 三合一收款二维码(单文件版)
Stars: ✭ 233 (+1692.31%)
Mutual labels:  qrcode
expo-push-notification-helper
💬🔥This package helps you make expo push notification for React Native easy to use.
Stars: ✭ 32 (+146.15%)
Mutual labels:  expo
Vue
Make Vue greater with RxTS.
Stars: ✭ 228 (+1653.85%)
Mutual labels:  qrcode
expo-file-manager
A file manager app made with React Native & Expo
Stars: ✭ 110 (+746.15%)
Mutual labels:  expo
markets-react
📈 Check the stock market, from your phone!
Stars: ✭ 47 (+261.54%)
Mutual labels:  expo
php-qrcode
在线生成二维码
Stars: ✭ 80 (+515.38%)
Mutual labels:  qrcode
qr-pirate
crawl QR-codes from search engines and look for bitcoin private keys
Stars: ✭ 58 (+346.15%)
Mutual labels:  qrcode

react-native-qrimage-decoder

QR image decoder libraries require linking...
So this library does not require linking.
But now still require Expo on Android.
I will response as soon as possible not require Expo on Android.

Instration

npm install react-native-qrimage-decoder --save

Usage

import React from 'react';
import {
  StyleSheet,
  Text,
  View,
  TouchableOpacity,
  Alert,
  WebView,
} from 'react-native';
import { ImagePicker, Constants, FileSystem } from 'expo';

import QRdecoder from 'react-native-qrimage-decoder';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    justifyContent: 'center',
    alignItems: 'center',
  },
  button: {
    width: '100%',
    backgroundColor: Constants.manifest.primaryColor,
    paddingVertical: 20,
    paddingHorizontal: 40,
    marginVertical: 20,
    marginHorizontal: 20,
  },
  buttonText: {
    color: '#fff',
    fontWeight: 'bold',
    textAlign: 'center',
  },
});

export default class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      src: null,
    };
  }

  onPressPath = async (e) => {
    try {
      const image = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: 'Images',
      });

      this.setState({
        src: image.uri,
      });
    } catch (err) {
      console.log(err);
    }
  }

  onPressBase64 = async (e) => {
    try {
      const image = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: 'Images',
        allowsEditing: true,
        aspect: [1, 1],
        base64: true,
      });

      if (image.uri.lastIndexOf('.') > 0) {
        let mimetype;
        const ext = image.uri.substr(image.uri.lastIndexOf('.')).toLowerCase();

        if (ext === '.jpg' || ext === '.jpeg' || ext === '.jpe') {
          mimetype = 'image/jpeg';
        } else if (ext === '.png') {
          mimetype = 'image/png';
        } else if (ext === '.gif') {
          mimetype = 'image/gif';
        }

        if (mimetype) {
          this.setState({
            src: `data:${mimetype};base64,${image.base64}`,
          });
        }
      }
    } catch (err) {
      console.log(err);
    }
  }

  onSuccess = (data) => {
    Alert.alert('成功', data);
  }

  onError = (data) => {
    Alert.alert('エラー', data);
  }

  render() {
    return (
      <View style={styles.container}>
        <TouchableOpacity style={styles.button} onPress={this.onPressPath}>
          <Text style={styles.buttonText}>画像を選択{'\n'}return image uri(path)</Text>
        </TouchableOpacity>
        <TouchableOpacity style={styles.button} onPress={this.onPressBase64}>
          <Text style={styles.buttonText}>画像を選択{'\n'}return image base64</Text>
        </TouchableOpacity>
        <QRdecoder src={this.state.src} onSuccess={this.onSuccess} onError={this.onError} />
      </View>
    );
  }
}

Checkout example.

QRdecoder API

Name Type Default Description
src string null Image path(file:///xxxxxx or https://xxxxx or http://xxxxx) or data:${mimetype};base64,${image.base64}
onSuccess func (data) => {} Called when qr decode success.
onError func (data) => {} Called when qr decode error.

onError, return data(string) is below.

  • QR code not found : error decoding QR Code
  • Image load failed : Failed to load the image

Note : dataURL suppoert is iOS only.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].