GithubHelp home page GithubHelp logo

moaazsidat / react-native-qrcode-scanner Goto Github PK

View Code? Open in Web Editor NEW
2.0K 32.0 509.0 476 KB

A QR code scanner component for React Native.

License: MIT License

JavaScript 100.00%
react-native qrcode qrcode-scanner camera barcode

react-native-qrcode-scanner's People

Contributors

alexbowers avatar alexgurr avatar amurmurmur avatar andrelmlins avatar bitsmanent avatar calvin0x00 avatar dependabot[bot] avatar drews256 avatar ezerangel avatar fgiobergia avatar gie3d avatar himelbrand avatar j-nolan avatar janhesters avatar kristerkari avatar lcsvcn avatar mamodom avatar mjgallag avatar moaazsidat avatar monkeywithacupcake avatar pdavid0 avatar pichuchen avatar puremana avatar rekha110254 avatar renatobenks avatar sava-vidakovic avatar semantic-release-bot avatar simek avatar undermaken avatar victorwpbastos 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  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

react-native-qrcode-scanner's Issues

Not able to scan QRcode on android

I am learning to use React Native. I made all the setting changes as mentioned in the article and used the sample example in my index.android.js. However when I run the project I don't see anything on the emulator. Am I doing something wrong?

fullscreen support?

How can I show camera view on fullscreen?

below code not work

  _topContent(){
    return(
      <View style={{height:0}}></View>
    )
  }
  _bottomContent(){
    return(
      <View style={{height:0}}></View>
    )
  }
  _onRead(){
    console.log(123213123123213);
  }
  render(){
    return(
      <View style={styles.container}>
        <QRCodeScanner
          style={{flex:1}}
          topContent={this._topContent()}
          bottomContent={this._bottomContent()}
          onRead={() => this._onRead()}
        />
      </View>
    )
  }

Unnecessary marginTop

Hello,

Thank you for this project which is working perfectly.

I want to discuss about the hardcoded top margin line 138 in index.js:

  ...
  render() {
    return (
      <View style={{
          flex: 1,
          marginTop: 64, //               <-- this line
        }}>
        <View style={[styles.infoView, this.props.topViewStyle]}>
          {this._renderTopContent()}
        </View>
        {this._renderCamera()}
        <View style={[styles.infoView, this.props.bottomViewStyle]}>
          {this._renderBottomContent()}
        </View>
      </View>
    )
  }
  ...

This prevents me from making the camera fill the screen vertically, see this Android screenshot:

  <QRCodeScanner onRead={this.handleRead} />

image

I believe this property was added to compensate for the navigation bar. Since a navigation bar doesn't always have a height of 64, I would suggest removing this line and allow the parent component to manage the margin himself. This way, we could adapt the necessary margin depending on how we manage the navigation bar.

If that makes sense, I would be happy to make a PR for this.

Hello

Thanks for this useful plugin !

It is very easy to use but i just wonder why it vibrates so frequently even if when reactivateTimeout={2000} or reactive={false}

cant it vibrate once not everytime when it see qcode

Thanks in Advnace

Scanner still runs in background if you navigate to different screen!

I just realise that my app still able to scan QR code after even navigate from the scanning screen to home screen. Its just happening in iOS.

My code:

<NavigatorIOS
                        initialRoute={{
                            component: QRCodeScanner,
                            title: 'Scan Code',
                            navigationBarHidden: true,
                            passProps: {
                                onRead: this.onSuccess.bind(this),
                                topViewStyle: {flex: 0, height: 0},
                                bottomViewStyle: {flex: 1, padding: 0},
                                showMarker: true,
                                bottomContent: (
                                    <View>
                                        {this.state.statusContent}
                                    </View>
                                ),
                            },
                        }}
                        style={{flex: 1}}
                    />

Is it a bug in the scanner or I'm doing something wrong?

I'm using .navigate() to go back to home screen

Application crashing when using with TabNavigator

I have an application which uses TabNavigator from react-navigation in the main screen. One of the tabs is the one that contains the QRCodeScanner component. When the main screen is loading (with all tabs), the application crashes.

Versions in use:

"react-native-camera": "0.10.0",
"react-native-qrcode-scanner": "0.0.28",
"react-navigation": "^1.0.0-beta.22"

Add prettier

Let's add prettier. Would be nice to have consistent styling across the project using prettier/lint-staged/husky, without having to think about it too much.

white screen

scanning work, but showing white blank screen instead of showing camera view.
sometimes app is not response at all

Get error while scanning barcode

What's happening?

Get the below error when try to scan barcode.

How can it be reproduced?

I used example-code and it works but when try to scan barcode, it display error screen:
screenshot_20180321-185831

Screen of line no: 23,24

code

Chorme Debug mode screen:

console

Build details?

Node.js version:8.10.0
React Native version: 0.54.2
React Native version CLI: 2.0.1
React Native platform + platform version: Windows 10 pro, Android 7.0, etc

Close. Its working with QRcode but i was trying barcode. Closing issue.

Crash when navigating back to scanner

In my app the user scans a qr code, the returned data is then passed to another scene using a Navigator, when they navigate back to scan another code the app crashes.

I have other scenes in the app that can be navigated back and forth to but when returning to the scene with the scanner in it always crashes (without stack trace or errors)

It might be something like the scanner is still running in the background (the phone alerts me that this app is draining battery)

Any advice would be appreciated

Permissions

The app will crash if permissions are not give to the app.

My idea is to introduce:

  componentWillMount () {
    if (Platform.OS === 'ios') {
      Camera.checkVideoAuthorizationStatus().then(isAuthorised => {
        this.setState({ isAuthorised })
      })
    }
  }

Hope it helps.

error while run first

i have message error in first run. the react native camera and qr code has been installed, but i get the error message : Could not find com.github.react-native-community:cameraview:d5d9b0d925494ef451ce3eef3fdf14cc874d9baa.
Required by:
QRDemo:app:unspecified > QRDemo:react-native-camera:unspecified

can you help me to solve that

How Can i added Camera Permission in Android

How can i Add Camera Permission for android devices..?
I have added this..
permissionDialogTitle: "Info",
permissionDialogMessage: "Need camera permission",
checkAndroid6Permissions: false,
but not working..

How to reactivate QRCodeScanner after navigating back to screen/component containing it?

Hi,

Thank you for making this available to the community! I'm using the React Navigation library to navigate to another screen upon a successful QR code scan.

I have reactivate set to false (the default) so that the app isn't constantly vibrating/trying to scan another QR code while I'm on another "screen" of the app. However, when I navigate back to my screen/component that contains the QRCodeScanner component, render() must not be called again because I cannot scan another QR code.

Can you please tell me how I can get QRCodeScanner to scan again when navigating back to it? Thank you!

.reactivate is not a function

I'm trying to reactivate the camera after the user acknowledges that their last scan failed.

Alert.alert(
	"Didn't Work",
	"We couldn't find an event for this code.",
	[
		{
			text: "OK",
			onPress: () => {
				setTimeout(() => {
					qrCodeScanner.reactivate();
				} , 1000)
			}
		}
	]
);

In debugging I can see that qrCodeScanner is correctly set as my reference, but this call errors and tells me that reactivate is not a function.

react-native-qrcode-scanner cannot read property oneOftype undefined

I'm using react-native v0.49 and i have error when i run qrcode scanner.

cannot read property oneOftype undefined

import React, { Component } from 'react';
import {
    View,
    Text,
    TouchableOpacity,
    Linking,
    StyleSheet,
} from 'react-native';
import { style } from './style';
import { globalStyle } from '../../../assets/styles/globalStyle';

// redux
import { connect } from 'react-redux';
import * as actions from '../../../actions';


//third party library
import QRCodeScanner from 'react-native-qrcode-scanner';


class ScanPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            barcodeText: ''
        }

    }
    onSuccess(e) {
        this.setState({ barcodeText: e.data });
        console.log(e);
    }

    render() {
        const { } = style;


        return (
            <QRCodeScanner
                onRead={this.onSuccess.bind(this)}
                topContent={(
                    <Text style={styles.centerText}>
                        Go to <Text style={styles.textBold}>wikipedia.org/wiki/QR_code</Text> on your computer and scan the QR code.
          </Text>
                )}
                bottomContent={(
                    <TouchableOpacity style={styles.buttonTouchable}>
                        <Text style={styles.buttonText}>OK. Got it!</Text>
                    </TouchableOpacity>
                )}
            />
        );
    }
}

const mapStateToProps = () => {

}
const styles = StyleSheet.create({
    centerText: {
      flex: 1,
      fontSize: 18,
      padding: 32,
      color: '#777',
    },

    textBold: {
      fontWeight: '500',
      color: '#000',
    },

    buttonText: {
      fontSize: 21,
      color: 'rgb(0,122,255)',
    },

    buttonTouchable: {
      padding: 16,
    },
  });

export default connect(null, actions)(ScanPage);

I checked into the node_modules the react-native-qcode-scanner folder into examples and I did exaclty the example. in addition in index.js of this folder of the plugin I see the oneOfType property but I don't see any wrong from my side. t

Unmet Peer Dependency react-native-camera

First, I'm fairly new to RN development so if this is an easy issue I apologize for the dumb question.

When I go about installing I follow the instructions to install react-native-camera (including linking). Which installs [email protected]. When I run the react-native-qrcode-scanner I receive the error: UNMET PEER DEPENDENCY [email protected]. In the peer dependencies section of the package.json I see this: "react-native-camera": "^0.10.0". I don't know exactly what the ^ means, but wondering if that's causing a problem. I'm fine installing THAT version of camera but was hoping someone had a better idea.

Thanks!

customMarker doesn't show up

Hey guys, thanks for the great job you've done!
However, I am not able to custom the marker.
I just tried to pass your marker and change the color, but it doesn't show up

<QRCodeScanner cameraStyle={styles.cameraContainer}
onRead={() => console.warn('Success')}
customMarker={<CustomQrMarker />}
/>

custom Marker :

      <View style={styles.rectangleContainer}>
        <View style={styles.rectangle} />
      </View>

custom marker style :

rectangleContainer: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'transparent'
  },
  rectangle: {
    height: 250,
    width: 250,
    borderWidth: 2,
    borderColor: 'green',
    backgroundColor: 'transparent'
  }

thanks for helping

Any progress on android?

Hi! Thank you for this package.
Just use it for app, and don't want to use another package only for android.
Any progress on android?

help, when onRead() ,black screen and exit..

//this is scanPager

 import React, { Component } from 'react';

 import {
   AppRegistry,
   StyleSheet,
   NavigatorIOS,
   Dimensions,
   View,
   Text,
   TouchableHighlight
 } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
 import QRCodeScanner from 'react-native-qrcode-scanner';

 export default class WarehouseOutScan extends Component {
   static navigationOptions = ({navigation,screenProps}) => ({
       headerLeft:(
         <View style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center', width: 60,height: 40}}>
           <TouchableHighlight underlayColor='#EEEEF4' disabled={thes.state.disabled} onPress={() => {
             const { goBack } = navigation;
             goBack();
           }}>
             <View style={{marginRight: 20, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', width: 60, height: 40}}>
               <Icon name='angle-left' size={35} color='black' />
             </View>
           </TouchableHighlight>
         </View>
       ),
   });

   constructor(props) {
     super(props);
     this.onSuccess = this.onSuccess.bind(this);
   }

   onSuccess(e) {
     const { goBack } = this.props.navigation;
     this.props.data.navigation.state.params.callback(e.data);
     goBack();
   }

   render() {
     return (
        <QRCodeScanner
          onRead={()=>this.onSuccess(e)}
          fadeIn={false}
          cameraStyle={{height: DeviceHeight}}
          showMarker={true}
        />
     )
   }
 }

 const styles = StyleSheet.create({
   zeroContainer: {
     height: 0,
     flex: 0,
   },

   cameraContainer: {
     height: Dimensions.get('window').height,
   },
 });

AppRegistry.registerComponent('demo', () => WarehouseOutScan);

//this is usePage

      <View style={[styles.valueCell,{borderWidth: 1, borderStyle: 'dashed', borderColor: 'black', marginLeft: 20, width:((DeviceWidth-30)*(1/5)), height:(DeviceHeight/16)}]}>
        <TouchableHighlight underlayColor='gray' disabled={thes.state.disabled} onPress={() => {
          const { navigate } = this.props.navigation;
          navigate('WarehouseOutScan', {
            callback: (trackingNumber)=>{
              this.setState({trackingNumber: trackingNumber});
            }
          });
        }}>
          <View style={[styles.valueCell,{width:((DeviceWidth-30)*(1/5)), height:(DeviceHeight/16)}]}>
            <Image source={Scanner} resizeMode='stretch' style={{width: 30, height: 30}}/>
          </View>
        </TouchableHighlight>
      </View>

========================================================================
onSuccess(e) {
const { goBack } = this.props.navigation;
this.props.data.navigation.state.params.callback(e.data);
goBack();
}

question:
what's the structure of the return value (e);

QR scanner not showing Android 5 or under

I followed the instructions from this link:
#61
"Camera not authorize" message is gone but the screen is blank.
I turn the camera on and use the device built-in camera app to confirm that the camera works.
Then I restarted the android device, turn on the camera again and try the qr scanner but still see the white screen.
Can this be fixed?
Android 4.2.2, 4.2, 5.0 failed

Showing blank white screen on android

Hello @moaazsidat ,

I'm having similar issue as declare here

What's happening?

I integrate react-native-camera and also tried given example on react-native-camera page which you can show by clicking here.
It's working fine for me.
after that i integrate react-native-qrcode-scanner & it showing me totally blank screen.

How can it be reproduced?

after integrate react-native-qrcode-scanner it showing me blank screen

Build details?

I'm working on..
"react": "^16.3.0-alpha.1",
"react-native": "0.54.2",
"react-native-camera": "git+https://[email protected]/react-native-community/react-native-camera",
"react-navigation": "^1.5.7"

I'm using Android Nougat .
please check attached screen sort
556877186307482995

Never requested camera permission

I followed all the steps to install the lib and all seems works fine, but when I install the app in a real device, I got never see the camera permission request.

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />

I see "Camera not authorized" in the view.

Any help?

Can the dimensions of the camera scanner become smaller when in a smaller View?

I have added the QRCodeScanner inside a View which is around 1/3 of the page height (and almost 100% of the page width).

I noticed that the marker is still large and that the detection of the QR is better on a corner than in the middle. Also the scanner requires more space and makes the ScrollView have a scrollbar.

I added width, height props to cameraStyle, is this the correct approach? The marker is still very large (part of it shows out of the view). Is the QR detection depended on that?

Example on Usage should be updated.

I've got

undefined is not an object(evaluating 'NativeModule.CameraManager.Aspect')

Error on launching this,
but I've fixed this issue with this code.

npm install -g rnpm
rnpm link react-native-camera
rnpm link react-native-qrcode-scanner

However, there was Security Crash issue with iOS10, which enforces to add Message to info.plist(can be found at Xcode's project-info-Privacy - Camera Usage Description.
I have to add String words and then passed iOS's security crack.

Error message was:

The app’s Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

I hope someone can get solution on this.
Here's some info for this:
http://useyourloaf.com/blog/privacy-settings-in-ios-10/

Screenshot link broken

The link to the screenshot in the readme is broken. Could you please fix it so we can see what this will look like when implemented? Thanks.

Camera not authorized

I am getting Camera not authorized error on android 5.1 device. Camera loads well on emulator with android 6.

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.