Giter Site home page Giter Site logo

conan1150 / cordova-plugin-ml-barcode-scanner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from impacgroup/cordova-plugin-ml-barcode-scanner

0.0 0.0 0.0 193 KB

License: Apache License 2.0

JavaScript 1.79% Swift 37.18% Kotlin 34.12% Java 26.91%

cordova-plugin-ml-barcode-scanner's Introduction

README

An Cordova plugin for iOS and Android that allows to open a barcode scanner.

Note

These plugin uses Google MLKit for detection of the barcode or QR-Code.

Supported platforms

  • Android 7+
  • iOS 13+
  • Cordova iOS 6+
  • Cordova Android 10+

Install

cordova plugin add https://github.com/ImpacGroup/cordova-plugin-ml-barcode-scanner

Immplementation

For iOS you need to add this to your cordova config.xml

<edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
    <string>ENTER YOUR MESSAGE HERE</string>
</edit-config>

For android you need to make sure that koltin is acitvated in your cordova config.xml. To these add the following:

    <preference name="GradlePluginKotlinEnabled" value="true" />
    <preference name="GradlePluginKotlinCodeStyle" value="official" />
    <preference name="GradlePluginKotlinVersion" value="1.6.0-RC" />

Before you can open the scanner you should setup the scanner. First you should setup the info screen. Therefor you can set a ScannerInfo object for default or if the user declined the camera permissions (iOS only).

    // object definition for info. 
    export interface ScannerInfo {
        title: string;
        infoText: string;
        button: ScannerButton;
    }

    export interface ScannerButton {
        title: string;
        tintColor: string;
        backgroundColor: string;
        roundedCorners: boolean;
    }
    
    const button: ScannerButton = {
        title: translation.scanner.manuelImei,
        tintColor: "#FFFFFF",
        backgroundColor: "#FF0000",
        roundedCorners: true
    };
    const scannerInfo: ScannerInfo = {
        title: "Title,
        infoText: "Info text",
        button: button
    };
    
    // set info object
    window.plugins.barcodeScanner.setInfoScreen(JSON.stringify(scannerInfo), (error) => {
        console.log(error);
    });

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.