Hey, I made a barcode scanner using the https://github.com/phonegap/phonegap-plugin-barcodescanner.
I am able to scan barcodes and qr codes, but I couldnt figure out how I could make it scan aztec.
Here is the code of my “home.ts”
import {Component } from '@angular/core';
import {NavController } from 'ionic-angular';
import {BarcodeScanner} from 'ionic-native';
import {Platform} from 'ionic-angular';
import {ScanPage} from '../scan/scan';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
private barcodeText:String;
private barcodeFormat:String;
private platform:Platform;
private navController:NavController;
constructor(public navCtrl: NavController,platform:Platform){
this.platform = platform;
this.navController = navCtrl;
}
doScan(){
console.log('scannig product barcode');
this.platform.ready().then(() => {
BarcodeScanner.scan({"formats" : "aztec"}).then((result) => {
if (!result.cancelled) {
this.barcodeText = result.text;
this.barcodeFormat = result.format;
this.scanningDone({'text':result.text,'format':result.format});
}
}, (error) => {
console.log('error when scanning product barcode');
});
});
}
scanningDone(data){
this.navController.push(ScanPage, {data: data});
}
}
export class BarcodeData {
constructor(
public text: String,
public format: String
) {}
}
cli packages: (/var/ionic/myApp/node_modules)
@ionic/cli-plugin-cordova : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils : 1.7.0
ionic (Ionic CLI) : 3.7.0
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.0.2
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.5.3
System:
Node : v6.11.1
OS : Linux 4.4
npm : 5.3.0
If you need additional code/information just ask.