# Diagnostic plugin not installed

**URL:** <https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437>\
**Category:** Ionic Native\
**Created:** [August 5, 2018, 6:08pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437 "2018-08-05T18:08:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwanite](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@kwanite](https://forum.ionicframework.com/u/kwanite)\
**Post date:** [August 5, 2018, 6:08pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/1 "2018-08-05T18:08:26Z")

</div>

I get the following error message on console when testing the app both on iOS and Android using the Ionic DevApp:

```auto
[13:59:34] console.warn: Ionic Native: tried calling Diagnostic.getLocationAuthorizationStatus, but the Diagnostic
            plugin is not installed.
[13:59:34] console.warn: Install the Diagnostic plugin: 'ionic cordova plugin add cordova.plugins.diagnostic'

```

Plugin is already installed. When I use “ionic cordova plugin add cordova.plugins.diagnostic”, I get the following message showing that plugin is already installed:

```auto
Plugin "cordova.plugins.diagnostic" already installed on android.

Plugin "cordova.plugins.diagnostic" already installed on ios.

Adding cordova.plugins.diagnostic to package.json

Saved plugin info for "cordova.plugins.diagnostic" to config.xml

```

Here is my package.json:

```auto
{
  "name": "Geolocation",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/core": "~4.11.0",
    "@ionic-native/diagnostic": "^4.11.0",
    "@ionic-native/geolocation": "^4.11.0",
    "@ionic-native/splash-screen": "~4.11.0",
    "@ionic-native/status-bar": "~4.11.0",
    "@ionic/storage": "2.1.3",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-ionic-keyboard": "^2.1.2",
    "cordova-plugin-ionic-webview": "^2.0.2",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova.plugins.diagnostic": "^4.0.8",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26",
    "cordova-ios": "~4.5.5"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.11",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova.plugins.diagnostic": {}
    },
    "platforms": [
      "ios",
      "android"
    ]
  }
}

```

In my home.ts after importing and referencing diagnostics in constructor, I use the following code:

```auto
export class HomePage {

public locState: any;
  constructor(public navCtrl: NavController, 
    private diagnostic: Diagnostic
  ) {

  }

  ionViewDidLoad(){

      this.diagnostic.getLocationAuthorizationStatus().then( state => {
      if (state == this.diagnostic.permissionStatus.GRANTED){
      this.locState = 'GRANTED';
      } else {
      this.locState = 'NOT GRANTED';
      }}).catch(e => console.error(e));
       
      
  }
}

```

Thus, I use getLocationAuthorizationStatus() that is both for iOS and Android.

In home.html, I want to display locState:

```auto
<p>{{ locState }}</p>

```

Of course this doesn’t show on screen. I also do get this error message saying plugin not installed.

Am I making a mistake somewhere? Why does the system tell me plugin not installed although it actually is.

Thanks!

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [August 5, 2018, 9:08pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/2 "2018-08-05T21:08:20Z")

</div>

How and where are you testing?  
What is your `ionic info` output?

---

<div class="post-metadata">

**Author:** ![dpa99c1](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dpa99c1](https://forum.ionicframework.com/u/dpa99c1)\
**Post date:** [August 6, 2018, 3:08pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/3 "2018-08-06T15:08:33Z")

</div>

Since Cordova plugins are loaded dynamically at runtime, the Diagnostic plugin is not guaranteed to be loaded until the `deviceready` event has fired, this in Ionic terms is when the platform is ready.

Therefore, you need to hook into the platform to be sure you are only calling the plugin once it has been loaded and is ready, something like this:

```
import {Platform} from 'ionic-angular';
import {Diagnostic} from '@ionic-native/diagnostic';

export class HomePage {

public locState: any;
  constructor(public navCtrl: NavController, 
    private diagnostic: Diagnostic,
    private platform: Platform
  ) {
    
  }

  ionViewDidLoad(){
      this.platform.ready().then(() => {
        this.diagnostic.getLocationAuthorizationStatus().then( state => {
          if (state == this.diagnostic.permissionStatus.GRANTED){
            this.locState = 'GRANTED';
          } else {
            this.locState = 'NOT GRANTED';
          }
        }).catch(e => console.error(e));
    });
  }
}
```

---

<div class="post-metadata">

**Author:** ![kwanite](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@kwanite](https://forum.ionicframework.com/u/kwanite)\
**Post date:** [August 6, 2018, 4:17pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/4 "2018-08-06T16:17:13Z")

</div>

I use Ionic Dev App to test this on iPhone 7 and Galaxy S9. This is what ionic info shows:

```auto
cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.11
    Cordova Platforms : android 7.0.0 ios 4.5.5
    Ionic Framework : ionic-angular 3.9.2

System:

    Node : v8.9.4
    npm : 4.6.1
    OS : macOS High Sierra
    Xcode : Xcode 9.3.1 Build version 9E501

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

```

---

<div class="post-metadata">

**Author:** ![kwanite](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@kwanite](https://forum.ionicframework.com/u/kwanite)\
**Post date:** [August 6, 2018, 4:36pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/5 "2018-08-06T16:36:24Z")

</div>

Thanks but I tried this code but still got the same error message:

```auto
[12:23:19] console.warn: Ionic Native: tried calling Diagnostic.getLocationAuthorizationStatus, but the Diagnostic
            plugin is not installed.
[12:23:19] console.warn: Install the Diagnostic plugin: 'ionic cordova plugin add cordova.plugins.diagnostic'

```

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [August 6, 2018, 5:25pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/6 "2018-08-06T17:25:27Z")

</div>

I don’t think the diagnostic plugin is supported in the dev app:

> **[Ionic Framework](https://ionicframework.com/docs/pro/devapp/#native-cordova-plugin-support)**
>
> The Ionic Pro platform helps you build better apps on ionic framework with Pro's integrated suite of tools and services designed for the entire app lifecycle.

---

<div class="post-metadata">

**Author:** ![kwanite](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@kwanite](https://forum.ionicframework.com/u/kwanite)\
**Post date:** [August 6, 2018, 8:08pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/7 "2018-08-06T20:08:49Z")

</div>

Thank you. This is a very useful list to have. I wasn’t aware of it.

What is the next easiest way to test the diagnostic plugin?

I guess I can build the app using Android Studio and Xcode and then run it on a device. That is more time consuming than DevApp obviously.

---

<div class="post-metadata">

**Author:** ![kwanite](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@kwanite](https://forum.ionicframework.com/u/kwanite)\
**Post date:** [August 6, 2018, 8:25pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/8 "2018-08-06T20:25:20Z")

</div>

Works when built using Android studio… I tried the same code by building the app using Android studio and running it on a device… it works perfectly…

As discussed above, DevApp doesn’t support diagnostic plugin testing… so you have to build and run it on a device…

I wish there was an easier way to do it but I will work with this method for the moment…

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [August 6, 2018, 8:34pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/9 "2018-08-06T20:34:39Z")

</div>

It’s technically impossible to include all available plugins in an app like DevApp, which makes building the app yourself the only solution. In the best case `ionic cordova run android` is enough to get your app on a device.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:26pm UTC](https://forum.ionicframework.com/t/diagnostic-plugin-not-installed/137437/10 "2021-07-19T21:26:08Z")

</div>

Closed on July 19, 2021, 9:26pm UTC


