Diagnostic

Contents

Checks whether device hardware features are enabled or available to the app, e.g. camera, GPS, wifi

Installation

ionic cordova plugin add cordova.plugins.diagnosticnpm install @ionic-native/diagnostic
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEYnpm install @ionic-enterprise/diagnostic

Supported Platforms

  • Android
  • iOS
  • Windows

Usage

import { Diagnostic } from '@ionic-native/diagnostic/ngx';

constructor(private diagnostic: Diagnostic) { }

...

let successCallback = (isAvailable) => { console.log('Is available? ' + isAvailable); }
let errorCallback = (e) => console.error(e);

this.diagnostic.isCameraAvailable().then(successCallback).catch(errorCallback);

this.diagnostic.isBluetoothAvailable().then(successCallback, errorCallback);


this.diagnostic.getBluetoothState()
  .then((state) => {
    if (state == this.diagnostic.bluetoothState.POWERED_ON){
      // do something
    } else {
      // do something else
    }
  }).catch(e => console.error(e));