datalogic / cordova-plugin-datalogic

Cordova Plugin for Datalogic Android SDK
0 stars 7 forks source link

barcodeManager is not defined. #11

Closed AlexanderNikolaiev closed 5 years ago

AlexanderNikolaiev commented 5 years ago

I'm writing an Ionic 4 application and need to use this library. Steps to reproduce:

  1. Install it via npm npm i --save-dev @datalogic/cordova-plugin-datalogic
  2. Include it to the required component 2.1. If I include it just with declare let barcodeManager: any;, it returns me not defined error when trying to use 2.2. If I try to import it directly like import { barcodeManager} from '@datalogic/cordova-plugin-datalogic/www/barcodeManager';. it fails the compilation because unable to resolve cordova/exec module.

What is the correct way of including and using your library in an Ionic project? Please, respond ASAP.

AlexanderNikolaiev commented 5 years ago

the same error reproduces when I include the library to my project via Ionic, ionic cordova plugin add @datalogic/cordova-plugin-datalogic. Could you please provide a right way to include it?

codybrookshear commented 5 years ago

Hi @AlexanderNikolaiev,

Including the library using the ionic cordova plugin add @datalogic/cordova-plugin-datalogic (as you tried) is the best way to include the library for Ionic development. I just created a FAQ page that walks through creating an Ionic app from scratch using Ionic 5. I realize you are using Ionic 4, but I wanted to verify on the latest version first. Could you step through and see if this works for you?

https://datalogic.github.io/cordova/faq

Thanks, Cody

ngaranko commented 5 years ago

Hi @codybrookshear,

Sorry for slow response, I'm working with Alex, we've found a problem in our own code :)

Here's backstory: Running tests will generate

HeadlessChrome 77.0.3865 (Linux 0.0.0) AppComponent should create the app FAILED
    ReferenceError: barcodeManager is not defined
    error properties: Object({..,  ...
        at <Jasmine>
        at AppComponent.initializeApp (http://localhost:9876/_karma_webpack_/src/app/app.component.ts:49:9)

This is related to Clobber not being resolved, we've solved issue by wrapping barcodeManager use into if (typeof barcodeManager !== 'undefined') { which is not idea, but solved problem for now. JFYI.

This issue can be closed.

-Nick

codybrookshear commented 5 years ago

Good. Thanks for letting me know @ngaranko 👍