From what I understand I cannot use ionic-native if I’m using capacitor and not Cordova, even though I tried it anyways.
What is the best way to integrate QRscanner into capacitor apps on iOS? Im using a package for angular to scan which works fine on any browser, but I don’t want to use browser. Don’t know if capacitor will ever have api for qrscanner.
I believe Capacitor supports cordova (and hence ionic native) for many plugins. Some may conflict.
Haven’t tried QR but I would defintely give it a try.
There is a list of community plugins for Capacitor. And no one knows of course when the QR will arrive, unless you build it yourself.
I took the QR js code of this package and injected it separately in the app, so I can use it in PWA and test without having to run ionic cordova run browser.
And works fine. No camera preview of course, but that is a web issue I believe.
import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner/ngx';
this.qrScanner = new QRScanner();
// start scanning - as seen in the documentation.....
const scanSub = this.qrScanner.scan().subscribe((text: any) => {
console.log('Scanned something', text);
// here the result
if (text.result) {
}
this.qrScanner.hide(); // hide camera preview
scanSub.unsubscribe(); // stop scanning
});
}
Yeah I’ve done this. It doesn’t work. Just a blank screen, I guess it’s the no preview. Works fine on browser, on iOS doesn’t do what I need it to do. sigh
It works in Safari, Firefox and Chrome but on Firefox Preview (now it is on Nightly channel) it works kinda iffy.
Also, if you are using TypeScript you will have to change the index.d.ts file (not sure if it’s called index, but you will see an error that quagga is not a module or something related) on the node_modules because the definition package is all janked up but it is an easy fix (don’t export as module but as a default variable, and export everything in that file). I tried pushing a change, but they revert to the one that gave issues for some reason.
There are others packages that does the same as this one that I always find just looking around.