Hi
I added a Cordova plugin from GitHub, which is not part of the ionic-native
plugins. The plugin does show under the list of plugins when I run cordova plugin list
, so it has been added successfully, but when I call a method from the plugin, I get this error:
ReferenceError: CustomPlugin is not defined
Here is my code:
import { Component, OnInit } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
declare var CustomPlugin: any;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage implements OnInit {
constructor(public navCtrl: NavController) { }
ngOnInit() {
CustomPlugin.initialise(function () {
CustomPlugin.setReceiveScanCallback(function (data, type) {
console.log("scan received: " + data + "(" + type + ")");
});
});
}
scanBarcode() {
CustomPlugin.requestScan(function () { });
}
}