Library: How Can I implement it in my IONIC App

Created on 28 May 2018  路  10Comments  路  Source: zxing-js/library

I am trying to implement this library in IONIC App. How I can implement this in my IONIC App. Is it available in IONIC or any doc available for it.

ionic question

All 10 comments

I happen to also use this library for a Cordova plugin, but Cordova does not allow direct node dependencies, so the code is copied into it.

Not sure if it will help you, but here is my project:
https://github.com/Tjieco/cordova-plugin-barcodescanner-browser-support

@Tjieco But above plugin also not work

I meant sharing the plugin more in a way for you to look into the code and see how the library was implemented into the plugin.

Currently, Cordova does not support node modules in browser Cordova applications so this project can't be a dependency. Instead, what you can do is compile the TS code into a minified JS file and copy that manually in your plugin. I know it's a very bad practice but I couldn't figure out another way to do it.

I hope this helps a little.

PS: if you find things are not working with the plugin please share them or make an issue, otherwise I will not be able to know what is wrong or what to fix.

@Tjieco MyActual requirement to cover only mobile Android and iOS with pdf417 scanning support.

If you really want to use this code in your IONIC project you need to manually copy in the minified javascript code in your project. I have struggled with this for a long time aswell. Make sure to comment out any externals from the Webpack config before building though!

The alternative is to use existing plugins. The Cordova barcodescanner plugin supports PDF417 on Android (https://github.com/phonegap/phonegap-plugin-barcodescanner),
but not on iOS, so you'd either have to use other plugins like (just quickly googled, may not actually work) https://github.com/PDF417/pdf417-phonegap for iOS and manually check in your code what kind of device is using it.

@Tjieco any possibility of we create a ionic-scanner or something so we can work on this Ionic stuff?

That is very difficult to say..
I'm afraid this library cannot be exported as an Ionic plugin due to the node dependencies. You would have to make a new project, copy the compiled javascript code in it, and export that as a plugin like I did or find out a way to integrate node modules inside an Ionic app.

However, if someone does manage to do the latter then it opens a LOT more possibilities for developers in Phonegap/Cordova and Ionic.

If you have any other solutions I would love to hear them!

You would have to make a new project, copy the compiled javascript code in it, and export that as a plugin like I did or find out a way to integrate node modules inside an Ionic app.

I think we can manage some build with Webpack that uses the compiled JS to build into a plugin. 馃

I got to be honest, my WebPack experience is severely lacking so I did not even think about doing that.
If you manage to configure Webpack to make a build and publish that as a plugin then by all means go for it, I'm sure many others would like to use it aswell. Looks like this issue needs some investigation first though.

MyActual requirement to cover only mobile Android and iOS with pdf417 scanning support.

PDF417 is currently not supported, subscribe to #124 for more info.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sabasayer picture sabasayer  路  3Comments

josephernest picture josephernest  路  8Comments

majestic84 picture majestic84  路  8Comments

michael-pearson picture michael-pearson  路  6Comments

Hopingocean picture Hopingocean  路  3Comments