App Availability plugin error

Hi all,

I’m trying to use the App Availability plugin. I follow the installation instructions in https://ionicframework.com/docs/native/app-availability/ but I have this error

Cannot find module “@ionic-native/app-availability”

I install the plugin via

$ ionic plugin add cordova-plugin-appavailability

make the imports

import { AppAvailability } from ‘@ionic-native/app-availability’;
import { Platform } from ‘ionic-angular’;

And when I add
private appAvailability: AppAvailability
to the constructor the error appears.

What’s my mistake?

I have

Cordova CLI: 6.5.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.0
Xcode version: Not installed

Thanks in advance

You also have to run
npm install --save @ionic-native/app-availability

1 Like

You need to add the plugin as a Provider.

Here’s an example based on the Barcode Scanner plugin:

Hi,

thanks for the answer zanzofily and PWHSoftware.

After the installation the error dissapears, and another one appears.

Runtime Error
Cannot find module “@ionic-native/core”

I install ionic-native/core

npm install --save @ionic-native/core

After, another error appears during runtime:

No provider for AppAvailability!

I add to the page the provider.

@Component({
selector: ‘page-actividad-fisica’,
templateUrl: ‘actividad-fisica.html’,
providers: [AppAvailability]
})
export class ActividadFisicaPage {

and all works fine.

Thanks!