diagnostic.isLocationAvailable()

I want to use the diagnostic plugin. I have installed it, but when I try to use diagnostic.islocationavailable in the following code, I get a error " Expected 0 arguments, but got 2."
I’m lost with this because in the plugin’s user manual there are 2 functions as parameters.

import { Component, Input, Injectable } from '@angular/core';
import * as L from 'leaflet';
import { Diagnostic } from '@ionic-native/diagnostic';


export class MapComponent {

constructor(private diagnostic: Diagnostic) {


  }
 ngOnInit() {
    this.showMap();
    this.checkLocation();
    //this.navigation();

  }
  showMap() {
    this.map = L.map('map').
      setView([42.1003479, -8.6134110],
        12);
    L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?').addTo(this.map);

  }
  checkLocation() {
    this.diagnostic.isLocationAvailable(function (available) {
      alert("Location is " + (available ? "available" : "not available"));
    }, function (error) {
      alert("The following error occurred: " + error);
    });
  }
}

Are you sure you installed and read the documentation carefully???
https://ionicframework.com/docs/native/diagnostic/

Yes, I did.
I followed the 2 steps:

  1. Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova.plugins.diagnostic
$ npm install --save @ionic-native/diagnostic
  1. [Add this plugin to your app’s module]

Maybe, I miss something?

It is strange few days back I used the diagnostic plugin and it worked fine.

The solution that I found has been change the function:


 checkLocation() {

    let p = this.diagnostic.isLocationAvailable();
    p.then(function (available) {
      alert("Location is " + (available ? "available" : "not available"));
    }).catch(function (error) {
      alert("The following error occurred: " + error);
    });


  }


the import you have is from
import { Diagnostic } from ‘@ionic-native/diagnostic’;

I have and it works fine:
import { Diagnostic } from ‘@ionic-native/diagnostic/ngx’;