Giter Site home page Giter Site logo

eddyverbruggen / nativescript-barcodescanner Goto Github PK

View Code? Open in Web Editor NEW
292.0 292.0 76.0 15.79 MB

🔎 NativeScript QR / barcode (bulk)scanner plugin

License: MIT License

Objective-C 29.28% TypeScript 62.59% Shell 2.02% Vue 5.94% SCSS 0.16%
barcode barcode-scanner ean13 ean8 nativescript nativescript-plugin qr-code

nativescript-barcodescanner's Introduction

NativeScript BarcodeScanner

Build Status NPM version Downloads Twitter Follow

💡 Plugin version 4.0.0+ is compatible with NativeScript 7+. If you need to target older NativeScript versions, please stick to plugin version 3.4.2.

⚠️ With 4.1.0+ you can use beepOnScan on iOS again (it used to crash in older 4.x versions).

Want a quick demo?

Note that running this only makes sense on a real device.

git clone https://github.com/EddyVerbruggen/nativescript-barcodescanner barcodedemo
cd barcodedemo/src

Fullscreen, programmatically (iOS and Android)

npm run demo.android (or demo.ios / demo.ios.device)

Embedded (iOS only)

npm run demo.ios

Supported barcode types

iOS and Android

  • CODE_39
  • CODE_93
  • CODE_128
  • DATA_MATRIX
  • EAN_8
  • EAN_13
  • ITF (also known as ITF14)
  • PDF_417 (on Android only when passed in explicity via formats)
  • QR_CODE
  • UPC_A
  • UPC_E

Android only

  • CODABAR
  • MAXICODE
  • RSS_14

iOS only

  • AZTEC
  • CODE_39_MOD_43
  • INTERLEAVED_2_OF_5

A note about UPC_A and EAN_13

When either (or both) of these are specified, both can be returned. You can check the actual type by inspecting the format property of the result object. For details, see #176.

Installation

From the command prompt go to your app's root folder and execute:

tns plugin add nativescript-barcodescanner

Embedding the scanner (iOS)

If you need to embed the scanner for Android as well, please consider using the Machine Learning powered Barcode scanner I've added to the ML Kit feature of the NativeScript Firebase plugin!

As you can see, you can style the view any way you like, and even overlay it with an image or button. To recreate the layout above, look at these lines in the demo app.

💡 TIP: If you don't destroy the component/page which embed the scanner (but instead show a modal, or navigate "forward") you can "pause" the scanner (since plugin version 3.4.0). Simply set that pause property to true when applicable.

XML

<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:Barcode="nativescript-barcodescanner">

Here's an example tag, showing all currently supported options. The property defaults are equal to the scan function.

<iOS>
    <Barcode:BarcodeScannerView
      class="scanner-round"
      formats="QR_CODE, EAN_13"
      beepOnScan="true"
      reportDuplicates="true"
      preferFrontCamera="false"
      pause="{{ pause }}"
      scanResult="{{ onScanResult }}" />
</iOS>

Embedding in Angular

Component / Module:

import { registerElement } from "nativescript-angular/element-registry";
registerElement("BarcodeScanner", () => require("nativescript-barcodescanner").BarcodeScannerView);

View:

<BarcodeScanner
      class="scanner-round"
      formats="QR_CODE, EAN_13"
      beepOnScan="true"
      reportDuplicates="true"
      preferFrontCamera="false"
      [pause]="pause"
      (scanResult)="onScanResult($event)">
</BarcodeScanner>

Embedding in Vue

main.ts:

Vue.registerElement('BarcodeScanner', () => require('nativescript-barcodescanner').BarcodeScannerView)

View:

<BarcodeScanner
    row="1"
    height="300"
    formats="QR_CODE, EAN_13, UPC_A"
    beepOnScan="true"
    reportDuplicates="true"
    preferFrontCamera="false"
    :pause="pause"
    @scanResult="onScanResult"
    v-if="isIOS">
</BarcodeScanner>

See 'demo-vue' for details.

iOS runtime permission reason

You've probably seen a permission popup like this before (this plugin will trigger one as well, automatically):

iOS 10+ requires not only this popup, but also a reason. In this case it's "We'd like to use the Camera ..".

You can provide your own reason for accessing the camera by adding something like this to app/App_Resources/ios/Info.plist:

  <key>NSCameraUsageDescription</key>
  <string>My reason justifying fooling around with your camera</string>

To not crash your app in case you forgot to provide the reason this plugin adds an empty reason to the .plist during build. This value gets overridden by anything you specify yourself.

Usage

Tip: during a scan you can use the volume up/down buttons to toggle the torch.

function: scan (single mode)

TypeScript

  import { BarcodeScanner } from "nativescript-barcodescanner";
  let barcodescanner = new BarcodeScanner();

  barcodescanner.scan({
    formats: "QR_CODE, EAN_13",
    cancelLabel: "EXIT. Also, try the volume buttons!", // iOS only, default 'Close'
    cancelLabelBackgroundColor: "#333333", // iOS only, default '#000000' (black)
    message: "Use the volume buttons for extra light", // Android only, default is 'Place a barcode inside the viewfinder rectangle to scan it.'
    showFlipCameraButton: true,   // default false
    preferFrontCamera: false,     // default false
    showTorchButton: true,        // default false
    beepOnScan: true,             // Play or Suppress beep on scan (default true)
    fullScreen: true,             // Currently only used on iOS; with iOS 13 modals are no longer shown fullScreen by default, which may be actually preferred. But to use the old fullScreen appearance, set this to 'true'. Default 'false'.
    torchOn: false,               // launch with the flashlight on (default false)
    closeCallback: () => { console.log("Scanner closed")}, // invoked when the scanner was closed (success or abort)
    resultDisplayDuration: 500,   // Android only, default 1500 (ms), set to 0 to disable echoing the scanned text
    orientation: orientation,     // Android only, default undefined (sensor-driven orientation), other options: portrait|landscape
    openSettingsIfPermissionWasPreviouslyDenied: true, // On iOS you can send the user to the settings app if access was previously denied
    presentInRootViewController: true // iOS-only; If you're sure you're not presenting the (non embedded) scanner in a modal, or are experiencing issues with fi. the navigationbar, set this to 'true' and see if it works better for your app (default false).
  }).then((result) => {
      // Note that this Promise is never invoked when a 'continuousScanCallback' function is provided
      alert({
        title: "Scan result",
        message: "Format: " + result.format + ",\nValue: " + result.text,
        okButtonText: "OK"
      });
    }, (errorMessage) => {
      console.log("No scan. " + errorMessage);
    }
  );

Note that result.format above is one of these.

JavaScript

  var BarcodeScanner = require("nativescript-barcodescanner").BarcodeScanner;
  var barcodescanner = new BarcodeScanner();

  barcodescanner.scan({
    formats: "QR_CODE,PDF_417",   // Pass in of you want to restrict scanning to certain types
    cancelLabel: "EXIT. Also, try the volume buttons!", // iOS only, default 'Close'
    cancelLabelBackgroundColor: "#333333", // iOS only, default '#000000' (black)
    message: "Use the volume buttons for extra light", // Android only, default is 'Place a barcode inside the viewfinder rectangle to scan it.'
    showFlipCameraButton: true,   // default false
    preferFrontCamera: false,     // default false
    showTorchButton: true,        // default false
    beepOnScan: true,             // Play or Suppress beep on scan (default true)
    fullScreen: true,             // Currently only used on iOS; with iOS 13 modals are no longer shown fullScreen by default, which may be actually preferred. But to use the old fullScreen appearance, set this to 'true'. Default 'false'.
    torchOn: false,               // launch with the flashlight on (default false)
    closeCallback: function () { console.log("Scanner closed"); }, // invoked when the scanner was closed (success or abort)
    resultDisplayDuration: 500,   // Android only, default 1500 (ms), set to 0 to disable echoing the scanned text
    orientation: "landscape",     // Android only, optionally lock the orientation to either "portrait" or "landscape"
    openSettingsIfPermissionWasPreviouslyDenied: true // On iOS you can send the user to the settings app if access was previously denied
  }).then(
      function(result) {
        console.log("Scan format: " + result.format);
        console.log("Scan text:   " + result.text);
      },
      function(error) {
        console.log("No scan: " + error);
      }
  );

function: scan (bulk / continuous mode)

In this mode the scanner will continuously report scanned codes back to your code, but it will only be dismissed if the user tells it to, or you call stop programmatically.

The plugin handles duplicates for you so don't worry about checking those; every result withing the same scan session is unique unless you set reportDuplicates to true.

Here's an example of scanning 3 unique QR codes and then stopping scanning programmatically. You'll notice that the Promise will no longer receive the result as there may be many results:

JavaScript

  var count = 0;
  barcodescanner.scan({
    formats: "QR_CODE",
    // this callback will be invoked for every unique scan in realtime!
    continuousScanCallback: function (result) {
      count++;
      console.log(result.format + ": " + result.text + " (count: " + count + ")");
      if (count === 3) {
        barcodescanner.stop();
      }
    },
    closeCallback: function () { console.log("Scanner closed"); }, // invoked when the scanner was closed
    reportDuplicates: false // which is the default
  }).then(
      function() {
        console.log("We're now reporting scan results in 'continuousScanCallback'");
      },
      function(error) {
        console.log("No scan: " + error);
      }
  );

function: available

Note that the iOS implementation will always return true at the moment, on Android we actually check for a camera to be available.

JavaScript

  var barcodescanner = require("nativescript-barcodescanner");

  barcodescanner.available().then(
      function(avail) {
        console.log("Available? " + avail);
      }
  );

function: hasCameraPermission / requestCameraPermission

On Android 6+ you need to request permission to use the camera at runtime when targeting API level 23+. Even if the uses-permission tag for the Camera is present in AndroidManifest.xml.

On iOS 10+ there's something similar going on.

Since version 1.5.0 you can let the plugin handle this for you (if need be a prompt will be shown to the user when the scanner launches), but if for some reason you want to handle permissions yourself you can use these functions.

JavaScript

  barcodescanner.hasCameraPermission().then(
      function(granted) {
        // if this is 'false' you probably want to call 'requestCameraPermission' now
        console.log("Has Camera Permission? " + result);
      }
  );

  // if no permission was granted previously this wil open a user consent screen
  barcodescanner.requestCameraPermission().then(
      function() {
        console.log("Camera permission requested");
      }
  );

Usage with nativescript-angular

You may have injected the BarcodeScanner class in your component constructor in the past, but please don't do that anymore because in release builds you may experience a crash.

So instead of:

// my-component.ts
import { Component, Inject } from '@angular/core';
import { BarcodeScanner } from 'nativescript-barcodescanner';

@Component({ ... })
  export class MyComponent {
    constructor(private barcodeScanner: BarcodeScanner) {
  }

  //use the barcodescanner wherever you need it. See general usage above.
  scanBarcode() {
    this.barcodeScanner.scan({ ... });
  }
}

Simply do:

// my-component.ts
import { Component, Inject } from '@angular/core';
import { BarcodeScanner } from 'nativescript-barcodescanner';

@Component({ ... })
  //use the barcodescanner wherever you need it. See general usage above.
  scanBarcode() {
    new BarcodeScanner().scan({ ... });
  }
}

Webpack usage

If you run into an error when Webpacking, open app.module.ts and add this:

import { BarcodeScanner } from "nativescript-barcodescanner";

export function createBarcodeScanner() {
  return new BarcodeScanner();
}

providers: [
  { provide: BarcodeScanner, useFactory: (createBarcodeScanner) }
]

Troubleshooting

If you get the error TypeError: Cannot read property 'zxing' of undefined on android, try the following steps:

  1. Delete the app from your device
  2. Remove the folder platforms/android. This triggers a complete rebuild
  3. run tns run android

Dependencies / Related Projects

This plugin wraps libaries for Android and iOS to make the barcode scanner easily accessible via a unified API. The Libraries used are:

iOS

Custom Framework to access iOS APIs: https://github.com/EddyVerbruggen/ios-framework-barcodescanner

Android

ZXing: https://github.com/zxing/zxing/releases

As using that library as a direct dependency was not practical, there is a library-project that adopts the sources from ZXing and copiles them into a AAR for usage on android: https://github.com/EddyVerbruggen/barcodescanner-lib-aar/

nativescript-barcodescanner's People

Contributors

absolutehype avatar caferrari avatar dependabot[bot] avatar eddyverbruggen avatar harrinsonmb avatar hdeshev avatar hugoserrana avatar jasonlcrane avatar kielsoft avatar madmas avatar mobilemindtec avatar myso-kr avatar nathanwalker avatar peterstaev avatar sean-nicholas avatar sis0k0 avatar steinerj 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

nativescript-barcodescanner's Issues

continuous scanning progress

I am wondering if there is a possibility to have a message visible while using continuous scanning. The message would represent a progress. I.e "4/10 items scanned". The message would get updated in continuousScanCallback (5/10, 6/10 and so on).

What do you think?

No callbacks . the component re-render itself without any callbacks after the scannanig !

I'm using nativescript-angular and there's not any callback after scaning . the component just re-render itself !

// module file

@NgModule({
  providers: [
    <ValueProvider>{ provide: BARCODE_SCANNER, useValue: barcodescanner }
  ],

// barcodescaner

import { OpaqueToken } from '@angular/core';
import * as scanner from 'nativescript-barcodescanner';

export const BARCODE_SCANNER = new OpaqueToken('barcodescanner');

export const barcodescanner = new scanner.BarcodeScanner();
export type BarcodeScanner = scanner.BarcodeScanner;
export type ScanOptions = scanner.ScanOptions;
export type IosScanOptions = scanner.IOS;
export type AndroidScanOptions = scanner.Android;

// component file

import { BARCODE_SCANNER, BarcodeScanner } from './barcodescanner';

scan(){
    this.barcodeScanner.scan({
      formats: "QR_CODE",
      message: "Place a barcode inside the viewfinder rectangle to scan it",
      preferFrontCamera: true,
      showFlipCameraButton: false,
      orientation: "landscape"
    })
    .then((result) => {
       this.login(result);
    },
    (error) => {
      this.loginError = true;
    });
  }

angular 2 can not set reportDuplicates :false

I use angular 2 and set reportDuplicates: false , but display message , dose not exist in type "ScanOptions" , I source code is
this.barcodeScanner.scan({
formats: "QR_CODE",
// this callback will be invoked for every unique scan in realtime!
continuousScanCallback: (result) =>
{
this.count++;
console.log(result.format + ": " + result.text + " (count: " + this.count + ")");
this.scantext = result.text;
alert("count" + this.count + result.text);
if (this.count == 3)
{
this.barcodeScanner.stop();
}
} ,reportDuplicates: false
} )
.then(
(result) => {
console.log("We're now reporting scan results in 'continuousScanCallback'");
alert("scan" + result.text);
this.scantext = result.text;

  },
   (error) => {
    alert("No scan: " + error);
    console.log("No scan: " + error);
  }
);    

}

Android Build issue

I currently am facing this issue when trying to run/emulate on android (iOS works fine)

:processNativescript-barcodescannerDebugResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':processNativescript-barcodescannerDebugResources'.

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/Cellar/android-sdk/24.4.1_1/build-tools/23.0.2/aapt'' finished with non-zero exit value 1

tns version 1.7.0

Running demo does not work

Whenever I try to setup the quick demo as mentioned in the readme I get the follow errors:

error TS6053: File 'node_modules/tns-platform-declarations/tns-core-modules/android17.d.ts' not found.
error TS6053: File 'node_modules/tns-platform-declarations/tns-core-modules/ios/ios.d.ts' not found.
error TS6053: File 'node_modules/tns-platform-declarations/tns-core-modules/org.nativescript.widgets.d.ts' not found.

It seems there the package is no longer in NPM or not needed. I don't know how to solve it since I'm very new in this field :)

Continuous scanning

Is there any way to continuously scan barcodes rather than bounce between the scan view and the previous page?

iOS Barcode Scanning is Broken

After updating to the latest version of nativescript-barcodescanner from NPM, I was able to bootstrap it into my Angular 2 NativeScript app; however, when calling the scan function, I received an error:

Oct 19 16:25:58 mycomputer myapp[84719]: CONSOLE LOG file:///app/tns_modules/nativescript-barcodescanner/barcodescanner.js:175:28: Error in barcodescanner.scan: 
TypeError: QRCodeReaderViewController.readerWithCancelButtonTitleCodeReaderStartScanningAtLoadShowSwitchCameraButtonShowTorchButton 
is not a function. (In 'QRCodeReaderViewController.readerWithCancelButtonTitleCodeReaderStartScanningAtLoadShowSwitchCameraButtonShowTorchButton(closeButtonLabel, reader, startScanningAtLoad, flip, torch)', 'QRCodeReaderViewController.readerWithCancelButton
TitleCodeReaderStartScanningAtLoadShowSwitchCameraButtonShowTorchButton' is undefined)

Looking at the source it looks like you have a lot of stuff commented out... perhaps things aren't in the best state?

As soon as this is fixed I can complete my work on #40 .

Configuration error

Hi @EddyVerbruggen when i try scanning i get "Configuration error" logged on my console which is supposedly next to impossible at the comment says.. lol.

Please help me out here

UPC_A 12+5 Digits

Hello,

Is there a way to scan a UPC_A with a 5-char extension ?

Thanks in advance.

RouterExtensions.navigate not working after scan.

Hello, I had added this great plugin in my app. The scan work fine but I have two little problems.

First, after scan, the page is freeze for around 5 second and I can’t understand why. And second, if I insert a ‘RouterExtensions.navigate’ to other page inside ‘then’ function it’s not work.

Adding another NativeScript TNS module with Library project

Hello,
Thanks you for awesome TNS module.

I have a question about adding another module:
What if I have added the BarcodeScanner module and I want to add another module with the Labrary project?
Will this work?

I think the latest added module will override the LabraryProject folder. Is not it?
image

App Crash after scanning a barcode (Android)

This is my package.json

"dependencies": {
"@angular/common": "2.1.0",
"@angular/compiler": "2.1.0",
"@angular/core": "2.1.0",
"@angular/forms": "2.1.0",
"@angular/http": "2.1.0",
"@angular/platform-browser": "2.1.0",
"@angular/platform-browser-dynamic": "2.1.0",
"@angular/router": "3.1.0",
"nativescript-angular": "1.1.0",
"nativescript-barcodescanner": "^2.1.1",
"nativescript-drawingpad": "^1.1.1",
"nativescript-geolocation": "0.0.13",
"nativescript-theme-core": "^0.1.2",
"reflect-metadata": "~0.1.8",
"tns-core-modules": "^2.4.0-2016-10-17-4410"
},
"devDependencies": {
"babel-traverse": "6.16.0",
"babel-types": "6.16.0",
"babylon": "6.12.0",
"lazy": "1.0.11",
"nativescript-dev-typescript": "^0.3.2",
"typescript": "^2.0.3",
"zone.js": "~0.6.21"
}

I fix a problem by removing these 4 lines of code in barcodescanner.android.js

// if (self.rememberedContext !== null) {
// appModule.android.currentContext = self.rememberedContext;
// self.rememberedContext = null;
// }

And now my app working fine but could you check or tell me a problem, please?

Thanks

Plugin does not work

As soon as I add this plugin to my project using

tns plugin add nativescript-barcodescanner

(without actually even using it), I can no longer build my project. The following error comes up:

:buildMetadata
Exception in thread "main" java.lang.IllegalArgumentException: Class com.tns.internal.AppBuilderCallback conflict: .../platforms/android/build/intermediates/classes/F0F1/debug and /home/smueller/Products/vesino-ticket/platforms/android/build/intermediates/classes/F0/debug
    at com.telerik.metadata.ClassRepo.cacheJarFile(ClassRepo.java:21)
    at com.telerik.metadata.Builder.build(Builder.java:42)
    at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildMetadata'.
> Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 34.664 secs
Command .../platforms/android/gradlew failed with exit code 1

I just checked: This even happens with an empty project created with tns create.

What's wrong?

Error finding nativescript-barcodescanner

I'm receiving an Unhandled Exception error after including the nativescript-barcodescanner plugin.
console shows that all plugins were prepared

Successfully prepared plugin nativescript-barcodescanner for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared
tns version 2.0.1

Does not work on android

I'm getting error with newest nativescript + android: "Cannot read property 'zxing' of undefined" please help, there's no other plugins like this for nativescript.

Bulk scan callback is not updating after routing change

Hi, I have problem with bulk scan on android (Nexus 5X, android 7.0). I need to wait for user to scan specific code. After scan I compare result with wanted code. First scan works fine, but when I change my route and reenter route with scanner, it seems like callback is not overwritten by new one, and after scan it compares result with old code.
Here is sample app to test this issue: https://github.com/pgrzeszczak/nts-barcodescanner-test

Example steps to reproduce:

  • Run app (new random string: gzddh)
  • Start scan
JS: SCANNED: gzddh WANTED: gzddh
JS: Valid code!
  • Go to second component
  • Go to first component (new random string: uxkep)
  • Start scan
JS: SCANNED: uxkep WANTED: gzddh
JS: Invalid code!

Using scanning a barcode breaks dialogs on Android

I know this is a weird issue; but basically if you create one button to scan and another button to pop up say Dialogs.prompt. After you scan, if you do the button to bring up the prompt you will see the following callstack:

 Dialog err Error: java.lang.NullPointerException
    android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:143)
    android.app.AlertDialog$Builder.<init>(AlertDialog.java:360)
    java.lang.reflect.Constructor.constructNative(Native Method)
    java.lang.reflect.Constructor.newInstance(Constructor.java:423)
...

I'm not sure what the Zxing or the wrapper does, but it somehow looks like it messes up the theme.

This is using Android runtimes 1.7x with common core 1.7.x

Example Code for each button:

   BarcodeScanner.scan({ showFlipCameraButton: true })
      .then(  function(result) {  console.log("result", result);  })
      .catch(function(err) { console.log("ScanErr:", err); });

  Dialogs.prompt("Please type it in", "")
       .then(function (result) { console.log("result", result); })
      .catch(function (err) { console.log("Dialog err", err);  });

Customize CaptureActivity & MultiQRScan

Hi to everyone,
I'm using nativescript-barcodescanner, but I have to zoom the video to try to scan far QR codes. Is there any simple way to include another buttons to zoom in and zoom out with recompile everything?
Also, I want to use QRCodeMultiReader instead of QRCodeReader to try to recognice them as soon as possible. Additionally, it will be nice to tap the area to give the hints to Zxing. So I here I have the same question, is there any simple way to modify that? Should I recompile everything? If I have to do it? How is the best way to do it?
Thanks in advance!! :) 👍

Conflict with another similar plugin

Hello this plugins is conflicting with nativesript-zxing and I need both for my application.

Exception in thread "main" java.lang.IllegalArgumentException: Class com.google.zxing.pdf417.PDF417ResultMetadata conflict: /Users/kheenan/Documents/ExerClub/platforms/android/build/intermediates/exploded-aar/barcodescanner-release-2.0.2/jars/classes.jar and /Users/kheenan/.gradle/caches/modules-2/files-2.1/com.google.zxing/core/3.2.1/2287494d4f5f9f3a9a2bb6980e3f32053721b315/core-3.2.1.jar
at com.telerik.metadata.ClassRepo.cacheJarFile(ClassRepo.java:21)
at com.telerik.metadata.Builder.build(Builder.java:39)
at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED

I need both one to scan qr code and another to display them.
This one scans qrcodes really well but as far as I can tell cannot display them.
The other displays them but will only scan stored images. any thoughts on how I can get them to play nice together?

Only a question: scan speed

Hi Eddie,

i have successfully implemented your barcode plugin into my nativescript app. Anyway, the reactivity of the plugin in a nativescript app seems a bit slow; i have also tried the cordova based plugin, and that seems to respond more quickly, and also forgives more than the NS one in respect to positioning, light, etc.

Are there some parameters that i can touch to vary the reactivity of the scan ? I really would like to develop the app in nativescript, but for now, due to this problem, i am stuck into the cordova one, and after discovering NS this is a bit frustrating...

Not a real issue, only didn't know where to ask you this.

Thanks very much in advance

Compilation Failed on ios

When I'm running tns build ios .. compilation failed and show this error messages below:

Analyzing dependencies
Downloading dependencies
Using GoogleMaps (1.12.3)
Using IQKeyboardManager (4.0.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total
pods installed.
Processing node_modules failed. Exception: Pod install command failed. Error output: 2016-03-24 02:02:41.086 ruby[2692:42624] Failed to save project: "/Volumes/Data/<ProjectDir>/platforms/ios/Pods/Pods.xcodeproj"

I thought there is a problem with my internet connection so the pod can't be installed but after check my connection, everything is okay

And I'm using:

El Capitan 10.11.3
XCode 7.2

Any clue?

make type script happy with barcodescanner.d.ts

I am using nativescript but having issues in the latest version because the
///
file no longer exists in nod_ modules folder. Therefore I do not know how to tell the references.d.ts file where to look for barcode-scanner. Is there another another file that can be used for type script reference?

Cannot read property 'zxing' of undefined

plugin had been added. but error.
V/JS ( 1313): Error in barcodescanner.scan: TypeError: Cannot read property 'zxing' of undefined
V/JS ( 1313): No scan: TypeError: Cannot read property 'zxing' of undefined

Scanner Area

Is there a way to increase the scan area of the camera.

Now we have to move the camera to fit the barcode inside the scan area

Is there any way we can increase or decrease the scan area of camera.

Thanks
Swapnesh

Tag the last commit

Hi! Could you tag the last commit please? Otherwise "tns plugin add nativescript-barcodescanner" will install the 2.1.3 with the currentContext bug :)

Thanks!

Camera Auto Focus

Hi,
I use your plugin in my App, but sometimes it's not easy scan some barcodes. I think if we disabled the camera auto focus we get some fasteness. Do you know how to do this? What do you think about?

Stop method doesn't work

I'm trying this code on Android.
I want to open the scanner and after some time without reading, close it.

BarcodeScanner.scan({
        cancelLabel: "EXIT. Also, try the volume buttons!", // iOS only, default 'Close' 
        message: "Use the volume buttons for extra light", // Android only, default is 'Place a barcode inside the viewfinder rectangle to scan it.' 
        showFlipCameraButton: true,   // default false 
        preferFrontCamera: false,     // default false 
        showTorchButton: true,        // iOS only, default false 
        orientation: "landscape",     // Android only, optionally lock the orientation to either "portrait" or "landscape" 
        openSettingsIfPermissionWasPreviouslyDenied: true // On iOS you can send the user to the settings app if access was previously denied 
    }).then(
        function() {
            console.log("We're now reporting scan results in 'continuousScanCallback'");
        },
        function(error) {
            console.log("No scan: " + error);
        }
    );

setTimeout(function() {
        BarcodeScanner.stop();
    }, 5000);

PDF417 support for android is not working

Hello

I updated my project using this awsome module but actually I can't read PDF417 barcodes in android, I'm using my xperia z3 for testing, do I need some additional configuration ?

Version: 1.3.1

Thanks

Trying to access/implement AVCaptureFocusMode

Hello,

Thank you for this nativescript implementation. One issue I am having is that once I get a barcode into view it takes 1 - 1.5 seconds to focus the camera and successfully process the barcode..

I would like to see if I could tinker with some native features to see if I can get quicker performance.

One thing i'm particular interested in trying is the autoFocusRangeRestriction: AVCaptureAutoFocusRangeRestriction

I have been trying to look at the how the plugin code is exposing the native ios api's however I'm struggling to come to grips with how this is done.

Can anyone show me an example how I can expose/edit this variable?

Thank you.

callback after permission granted (android 6)

Currently in order to activate a scanner I have following code:

barcodescanner.hasCameraPermission().then(function(granted) {
  if (granted) {
    activateScanner();
  } else {
    barcodescanner.requestCameraPermission().then(function() {
      console.log("called before permission granted!");
      return activateScanner();
    });
  };
});

Please notice callback for requestCameraPermission fires before permission is granted or denied. Is that in purpose? If so, is there any other callback I can use to activate scanner after user grands permission?

Intent does not reolve

Hi There,

trying this plugin out with NativeScript 2, however when I try execute I get a Configuration Error.
this happens due to the intent not being resolved. I have checked and the aar is being included in the build.

Regards

UIApplication.sharedApplication is not a function

While testing on iOS 10.0 with latest tns 2.3.0 I got the following error:

file:///app/tns_modules/nativescript-barcodescanner/barcodescanner.js:89:36: JS ERROR TypeError: UIApplication.sharedApplication is not a function. (In 'UIApplication.sharedApplication()', 'UIApplication.sharedApplication' is an instance of UIApplication)

This issue will be solved if I remove () in barcodescanner.ios.js from:
UIApplication.sharedApplication().keyWindow.rootViewController.dismissViewControllerAnimatedCompletion(true, null);

to:
UIApplication.sharedApplication.keyWindow.rootViewController.dismissViewControllerAnimatedCompletion(true, null);

Since this is not a function, any more ?? Does anybody know why this is an issue now ?

Oops. scan closing, after setted "appmodule.android.currentContext" is undefined.

using "barcodescanner" in modal page (method. page.showModal)

Promise.resolve()
.then(function(){
    return BarcodeScanner.hasCameraPermission().then(function(grants){
        return (grants) ? Promise.resolve() : Promise.reject();
    })
    .catch(function(){
        return BarcodeScanner.requestCameraPermission().then(function(available){
            return (available) ? Promise.resolve() : Promise.reject();
        })
        .catch(function(){
            Toast.makeText("エラー:カメラを使用することはできません。").show();
        })
    })
})
.then(function(){
    return BarcodeScanner.available().then(function(available) {
        return (available) ? Promise.resolve() : Promise.reject();
    })
    .catch(function(){
        Toast.makeText("エラー:スキャナを使用することはできません。").show();
    })
})
.then(function(){
    return BarcodeScanner.scan({
        cancelLabel: "キャンセル", // iOS only, default 'Close'
        message: "QRコードを画面の中に見えるようにしてください", // Android only, default is 'Place a barcode inside the viewfinder rectangle to scan it.'
        preferFrontCamera: false,     // Android only, default false
        showFlipCameraButton: true    // Android only, default false (on iOS it's always available)
    })
    .catch(function(error){
        Toast.makeText(error).show();
    })
})
.then(function(resp){
    if(!(/[0-9]{18}/ig).test(resp.text)){
        return Toast.makeText("エラー:正しい形式の診察券コードはありません。").show();
    }
    Request.post("api/qr", { patient_number: resp.text })
    .then(function(resp){
        switch(resp.status_code){
        case 401:
            Toast.makeText(resp.status_message).show();
            break;
        default: 
            self.closeCallback && self.closeCallback();
        }
    })
    .catch(function(error){
        Toast.makeText("エラー:再試行してください。", 'long').show();
    })
})

how to fix ?

JS: Error: java.lang.NullPointerException
JS:     android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:144)
JS:     android.app.AlertDialog$Builder.<init>(AlertDialog.java:362)
JS:     java.lang.reflect.Constructor.constructNative(Native Method)
JS:     java.lang.reflect.Constructor.newInstance(Constructor.java:423)
JS:     com.tns.Platform.createInstance(Platform.java:302)
JS:     com.tns.Platform.callJSMethodNative(Native Method)
JS:     com.tns.Platform.dispatchCallJSMethodNative(Platform.java:816)
JS:     com.tns.Platform.callJSMethod(Platform.java:715)
JS:     com.tns.Platform.callJSMethod(Platform.java:694)
JS:     com.tns.Platform.callJSMethod(Platform.java:684)
JS:     com.tns.gen.android.view.GestureDetector_SimpleOnGestureListener_frnal_ts_helpers_l47_c38__TapAndDoubleTapGestureListener.onSingleTapUp(android.view.GestureDetector$SimpleOnGestureListener.java)
JS:     android.view.GestureDetector.onTouchEvent(GestureDetector.java:1457)
JS:     android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:475)
JS:     android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:538)
JS:     com.tns.Platform.callJSMethodNative(Native Method)
JS:     com.tns.Platform.dispatchCallJSMethodNative(Platform.java:816)
JS:     com.tns.Platform.callJSMethod(Platform.java:715)
JS:     com.tns.Platform.callJSMethod(Platform.java:694)
JS:     com.tns.Platform.callJSMethod(Platform.java:684)
JS:     com.tns.gen.android.view.View_OnTouchListener_ftns_modules_ui_core_view_l121_c49__.onTouch(android.view.View$OnTouchListener.java)
JS:     android.view.View.dispatchTouchEvent(View.java:8389)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2471)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2194)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2477)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2209)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2477)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2209)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2477)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2209)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2477)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2209)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2477)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2209)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2477)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2209)
JS:     com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2329)
JS:     com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1616)
JS:     android.app.Dialog.dispatchTouchEvent(Dialog.java:884)
JS:     com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2277)
JS:     android.view.View.dispatchPointerEvent(View.java:8602)
JS:     android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4918)
JS:     android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4769)
JS:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4323)
JS:     android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4377)
JS:     android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4346)
JS:     android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4457)
JS:     android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4354)
JS:     android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4514)
JS:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4323)
JS:     android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4377)
JS:     android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4346)
JS:     android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4354)
JS:     android.view.V
JS: iewRootImpl$InputStage.deliver(ViewRootImpl.java:4323)
JS:     android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6738)
JS:     android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6617)
JS:     android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6588)
JS:     android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6553)
JS:     android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6818)
JS:     android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
JS:     android.os.MessageQueue.nativePollOnce(Native Method)
JS:     android.os.MessageQueue.next(MessageQueue.java:138)
JS:     android.os.Looper.loop(Looper.java:131)
JS:     android.app.ActivityThread.main(ActivityThread.java:5756)
JS:     java.lang.reflect.Method.invokeNative(Native Method)
JS:     java.lang.reflect.Method.invoke(Method.java:515)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
JS:     dalvik.system.NativeStart.main(Native Method)

#ActivityLifecycleCallbacks

Plugin does not work with AppBuilder

When using Telerik AppBuilder, installing the plugin appears to be successful, but the deployed application cannot find the module.
Error message is: Module "nativescript-barcodescanner" not found

Using other plugins within AppBuilder work correctly.

No scan. TypeError: Cannot read property 'zxing' of undefined

Hi,

I'm new to NativeScript and I'm trying to use this module. but I get this "No scan. TypeError: Cannot read property 'zxing' of undefined" whenever I try to use it.

I have already looked into these two issues, but they didn't help. I'm running the plugin's 1.3.10 version.
#4
#1

thanks

Getting error on fresh hello-world-ng app: Can't find variable: QRCodeReaderDelegate

I created a fresh app and installed the plugin, now getting

Jul 8 14:53:11 Mac-Pro mobile[47233]: 1 0xa025c -[TNSRuntime executeModule:] Jul 8 14:53:11 Mac-Pro mobile[47233]: 2 0x5203b main Jul 8 14:53:11 Mac-Pro mobile[47233]: 3 0x3cfda25 start Jul 8 14:53:11 Mac-Pro mobile[47233]: 4 0x1 Jul 8 14:53:11 Mac-Pro mobile[47233]: file:///app/tns_modules/nativescript-barcodescanner/barcodescanner.js:96:65: JS ERROR ReferenceError: Can't find variable: QRCodeReaderDelegate Jul 8 14:53:11 Mac-Pro com.apple.CoreSimulator.SimDevice.7B84929E-6CC8-4BC4-8002-D96E18C01083.launchd_sim[42146] (UIKitApplication:org.nativescript.mobile[0x741e][47233]): Service exited due to signal: Segmentation fault: 11

tns create mobile --template https://github.com/NativeScript/template-hello-world-ng

Added iOS platform and the nativescript-barcodescanner plugin then ran livesync in the emulator.

Style to scanner

Is there a way to style the scanner? For example on the google authenicator app the scanner screen has a nice cancel button with a message at the top of the scanner view. I know there is a message property but this only shows a text.

Dialogs module stop working after calling scan function

Hi,

After calling scan function, the dialogs module stop working raising below error:

JS: display error: Error: java.lang.NullPointerException
JS: android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:143)
JS: android.app.AlertDialog$Builder.(AlertDialog.java:360)
JS: java.lang.reflect.Constructor.constructNative(Native Method)
JS: java.lang.reflect.Constructor.newInstance(Constructor.java:423)
JS: com.tns.Platform.createInstance(Platform.java:302)
JS: com.tns.Platform.callJSMethodNative(Native Method)
JS: com.tns.Platform.dispatchCallJSMethodNative(Platform.java:816)
JS: com.tns.Platform.callJSMethod(Platform.java:715)
JS: com.tns.Platform.callJSMethod(Platform.java:694)
JS: com.tns.Platform.callJSMethod(Platform.java:684)
JS: com.tns.gen.android.view.View_OnClickListener_ftns_modules_ui_button_button_l19_c42__.onClick(android.view.View$OnClickListener.java)
JS: android.view.View.performClick(View.java:4496)
JS: android.view.View$PerformClick.run(View.java:18603)
JS: android.os.Handler.handleCallback(Handler.java:733)
JS: android.os.Handler.dispatchMessage(Handler.java:95)
JS: android.os.Looper.loop(Looper.java:136)
JS: android.app.ActivityThread.main(ActivityThread.java:5433)
JS: java.lang.reflect.Method.invokeNative(Native Method)
JS: java.lang.reflect.Method.invoke(Method.java:515)
JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
JS: dalvik.system.NativeStart.main(Native Method)

I figure it out that this is related to appmodule.android.currentContext is lost (undefined) after calling scan function. I fixed it using below workaround in my code:

const context = appmodule.android.currentContext
vm.scan().then(() => {
appmodule.android.currentContext = context;
});

Where vm.scan returns the barcodescanner.scan() promise

Is anyone else facing the same issue?, I'm using below dependencies:
"nativescript-barcodescanner": "^1.2.1",
"tns-core-modules": "^1.7.1"

Thanks.

flashlight button

hi,
I think there is no easy way to add a flashlight on/off button to the scanning screen?

onPermissionRejected

When you reject the camera permission there is an Android crash.
The current error is:
TypeError: self.onPermissionRejected is not a function

Angular Usage Docs Need Updating

I saw that recently for 2.0 you converted everything over to TypeScript and exposed a class. I think this is great! With this change, we will need to update the documentation for using it in Angular. It should be much simpler now that you are exposing a class - we shouldn't need any of the OpaqueToken stuff anymore.

I'd be happy to update the docs myself but I don't quite have the time today, so I thought I would open this issue to track this until I can submit the PR.

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.