New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

capacitor-plugin-barcodescanner

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capacitor-plugin-barcodescanner

Capacitor Plugin to add barcode scanner capabilities

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-92.86%
Maintainers
1
Weekly downloads
 
Created
Source

capacitor-plugin-barcodescanner

Capacitor Plugin to add barcode scanner capabilities to your capacitor app.

Note it only supports the android platform at the moment.

Installation

Install the plugin package by calling

npm install capacitor-plugin-barcodescanner

then call

npx cap update

to update the android platfrom.

Android

Open the android project and the MainActivity.java to register the plugin

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(BarcodeScanner.class);
    }});

    // some other code
  }

Usage

In your web app, to consume the plugin you have to register for a barcode scanner notifications:

import { Plugins, Capacitor } from '@capacitor/core';
import {
  BarcodeScannerPlugin,
  EVENT_BARCODE_SCANNED,
  IBarcodeScannerEventPayload,
} from 'capacitor-plugin-barcodescanner';

// can be used later to remove BarcodeScanner listener
let removeScannerHandler?: (() => void) = undefined;

const barcodeScanned = (state: IBarcodeScannerEventPayload): void => {
  console.log("BarcodeScanned - ",state.cancelled, state.barcode, state.error)
}
// Get the BarcodeScanner plugin
    const BarcodeScanner = Plugins.BarcodeScanner as BarcodeScannerPlugin;
// Register listener
    removeScannerHandler = BarcodeScanner.addListener(
      EVENT_BARCODE_SCANNED,
      barcodeScanned
    ).remove;

// call to start scanning....
BarcodeScanner.scan();
// this will call the plugin's scan method which starts scanning activity, after finishing the `EVENT_BARCODE_SCANNED` will be issued.


// when not needed
if(removeScannerHandler) {
  removeScannerHandler();
  removeScannerHandler = undefined;
}

Keywords

FAQs

Package last updated on 11 Jun 2020

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