Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Ionic 3 Cordova plugin gives undefined error

$
0
0

@deanwilliammills wrote:

Hi

I added a Cordova plugin from GitHub, which is not part of the ionic-native plugins. So plug does show under the list of plugins, 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 () { });

}
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>