网易云

Ionic实战视频教程(跨平台): https://www.itying.com/goods-1067.html

Flutter实战视频教程(跨平台): https://www.itying.com/goods-1176.html

Diagnostic

Contents

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

https://github.com/dpa99c/cordova-diagnostic-plugin

联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic 检测硬件 Diagnostic插件的安装(Installation)

ionic cordova plugin add cordova.plugins.diagnostic npm 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=YOURPRODUCTKEY npm install @ionic-enterprise/diagnostic

Ionic 检测硬件 Diagnostic插件支持的平台(Supported Platforms)

  • Android
  • iOS
  • Windows

Ionic 检测硬件 Diagnostic插件的用法(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));