1

I am using the @ionic-native/printer module to print a specific area.

Here is the code of the print button:

print() {

this.platform.ready().then(success => {
  this.printer.check().then(data => {
    this.toastCtr.create({
      message: data
    });
  }, error => {
    this.toastCtr.create({
      message: error,
      closeButtonText: 'Ok'
    }).present();
  });
},
  error => {
    this.toastCtr.create({
      message: error
    }).present();
  });
}

And the button html:

<button ion-button color="secondary" (click)="print()">PRINT THIS OFFER</button>

The module is imported in app.module.ts and in home.ts where it's used.

When I click on the print button, I get the following error:

cordova_not_available

But cordova is already installed.

Phonolog
  • 6,321
  • 3
  • 36
  • 64
alim1990
  • 4,656
  • 12
  • 67
  • 130
  • How are you testing your app? `ionic serve` will not work here, instead you will have to test on an actual device. See [this question](https://stackoverflow.com/questions/42840951/uncaught-in-promise-cordova-not-available-in-ionic-2) for further info. – Phonolog Jul 30 '18 at 17:12
  • Yeah I am working on my computer and using ionic serve command. – alim1990 Jul 30 '18 at 17:13
  • 1
    You'll instead have to test on a real device, the corresponding plugin repo [lists the supported platforms](https://github.com/katzer/cordova-plugin-printer#supported-platforms)... – Phonolog Jul 30 '18 at 17:16

0 Answers0