So yes, this is possible with a non-cordova build (ionic build) and a cordova browser build (ionic cordova build browser) (non supported by Ionic, but still working) .
So if I properly understand, I can use any compatible browser (chrome, edge, etc.) loading a ionic PWA app? Am I right?
If this is correct, it would be perfect. For the moment, when I try to use chrome and do a scan, I get the following error message: “Native: tried calling BarcodeScanner.scan, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator”. The camera doesn’t even load (nothing happens).
If you use the cordova browser platform, and the plugin support browser in a serious way, yes.
But: Ionic team normally doesn’t advice you to do that but use ionic build to build a PWA.
So you can a) do it anyway and maybe have problems or b) not do it and find another way to use the functionality, as the first link I posted gives you an option to.
(I am happy that I don’t have to decide between a) and b) right now myself)
In generall if you wnat to use the Cordova browser platform you add it with ionic cordova platform add browser and then build or run it with ionic cordova run browser.
Hi there, I’m trying too to make the cordova-plugin-qrscanner work in a “cordova-less” mode with an ionic app built without cordova.
I cannot manage to make window.QRScanner available at runtime in the browser (Chrome), it is always undefined.
How are we supposed to import the lib? I tried following the plugin’s README but it is very generic and not fit for an ionic app (with typescript etc.)
I tried your code, and saw in the dev tools that the lib was indeed imported. But I still did not have access to the QRScanner object.
So I tried again multiple import variants, and finally, found this one to work :
import * as QRScanner from 'cordova-plugin-qrscanner/dist/cordova-plugin-qrscanner-lib.min';
QRScanner is then a global object instance.
It works!
At least, it works in my app as it used to work when I used it as a Cordova Plugin on an ios/browser platform…
I will try to push a sample app on GitHub as proof
I tried testing my sample app on iOS Safari Mobile browser (without Cordova), and while it almost worked on Chrome 63 –
video preview is showing but scanning occurred once during all my testing – it did not work on iOS Mobile Safari.