Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@diningcity/capacitor-qr-scanner

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diningcity/capacitor-qr-scanner

A Capacitor plug in to scan QR Codes

  • 0.6.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
234
increased by17.59%
Maintainers
0
Weekly downloads
 
Created
Source

Welcome to the Capacitor QR Code Scanner

This repository is a capacitor plug in for scanning QR Codes on Android and iOS.

Table of contents

  • Installation
  • Usage

Installation

To install from the command line:

npm i @diningcity/capacitor-qr-scanner;
npx cap sync;

or

npm i @diningcity/capacitor-qr-scanner;
ionic capacitor copy;
(https://ionicframework.com/docs/cli/commands/capacitor-copy)

NOTE: After install the plug-in, you should add some settings and code snippets into your navite project.

iOS

  1. Open the ios project with Xcode from your project and add camera usage description in info.plist as following
<key>NSCameraUsageDescription</key>
<string>{Your camera usage description}</string>

ex: App would like to use camera to scan QRCode.

or

You can add this directly without coding with Xcode as following

Screen shot

  1. That's all

Android

Usage

iOS

To import the following into your code

import { QrScanner } from '@diningcity/capacitor-qr-scanner';
import React from "react";

const Test = () => {
    async function scanQR() {
      const {camera} = await QrScanner.requestPermissions();
      if (camera == "granted") {
        const {result} = await QrScanner.scanQrCode();
        alert(result);
      } else {
        alert("You should allow camera permission.");
      }
    }
    return (
        <React.Fragment>
            <div onClick={() => scanQR()}>
            </div>
        </React.Fragment>
    );
};

Android

To import the following into your code

import { QrScanner } from '@diningcity/capacitor-qr-scanner';
import React from "react";
const Test = () => {
    const scanQrCode = async () => {
        const {result} = await QrScanner.scanQrCode();
        alert(result);
    }
    return (
        <React.Fragment>
            <div onClick={scanQrCode}>
            </div>
        </React.Fragment>
    );
};

After remove old android directory from the root director of the project, then run the following commands

npx cap add android
npx cap open android

After open the android project with Android Studio, then you should add the following dependency repository under the allprojects > repositories in the build.gradle of the project.

maven { url 'https://jitpack.io' }

android_–build_gradle__android

Keywords

FAQs

Package last updated on 07 Sep 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc