🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-native-traxi-scanner

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-traxi-scanner

scanner barcode and qr code

0.1.1
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-traxi-scanner

scanner barcode and qr code

Installation

npm install react-native-traxi-scanner

Usage

import { scannerButton } from 'react-native-traxi-scanner';

// ...


Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Made with create-react-native-library

QR Reader

Min API Level = 21

Setup

Add the JitPack repository to your project level build.gradle:

allprojects {
 repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
 }
}

Add this to your app build.gradle:

dependencies {
	implementation 'com.github.murgupluoglu:qrreader-android:lastVersion'
}

Usage

This library using Camera permission. Please grant permission before start.

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

Step 1

Add QRReaderFragment to your XML like any other fragment.

<androidx.constraintlayout.widget.ConstraintLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

    <fragment
        android:id="@+id/qrCodeReaderFragment"
        android:layout_width="0dp"
        android:name="com.murgupluoglu.qrreader.QRReaderFragment"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Step 2

Define your fragment for access later

val qrCodeReader : QRReaderFragment by lazy {
    qrCodeReaderFragment as QRReaderFragment
}

Step 3

Add listener for returned qr code.

qrCodeReaderView.setListener(object : QRReaderListener{
    override fun onRead(barcode: FirebaseVisionBarcode, barcodes: List<FirebaseVisionBarcode>) {

  }

    override fun onError(exception: Exception) {

    }
})

Step 3

Start camera

qrCodeReaderView.startCamera(this@MainActivity)

Optional

Set configuration and enable torch

val qrOptions: BarcodeScannerOptions = BarcodeScannerOptions.Builder()
    .setBarcodeFormats(
        Barcode.FORMAT_QR_CODE,
        Barcode.FORMAT_AZTEC)
    .build()
val config = QRCameraConfiguration(lensFacing = CameraSelector.LENS_FACING_FRONT, options = qrOptions)

qrCodeReaderView.startCamera(this@MainActivity, config)

qrCodeReaderView.enableTorch(true)

Use Inside Your CameraX Setup

If you have CameraX setup in your code. You can use only QRAnalyzer class.

imageAnalyzer.setAnalyzer(mainExecutor, QRAnalyzer(rotation, config.options).apply {  
  onFrameAnalyzed { qrStatus, barcode, barcodes, exeption ->  
  
})

Keywords

react-native

FAQs

Package last updated on 25 Oct 2023

Did you know?

Socket

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.

Install

Related posts