Flutter教程

Health

Contents

A plugin that abstracts fitness and health repositories like Apple HealthKit or Google Fit.

https://github.com/dariosalvi78/cordova-plugin-health

联系我们?

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 Health插件的安装(Installation)

ionic cordova plugin add cordova-plugin-health npm install @ionic-native/health
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/health

Ionic Health插件支持的平台(Supported Platforms)

  • Android
  • iOS

Ionic Health插件的用法(Usage)

import { Health } from '@ionic-native/health/ngx';


constructor(private health: Health) { }

...

this.health.isAvailable()
.then((available:boolean) => {
  console.log(available);
  this.health.requestAuthorization([
    'distance', 'nutrition',  //read and write permissions
    {
      read: ['steps'],       //read only permission
      write: ['height', 'weight']  //write only permission
    }
  ])
  .then(res => console.log(res))
  .catch(e => console.log(e));
})
.catch(e => console.log(e));

See description at https://github.com/dariosalvi78/cordova-plugin-health for a full list of Datatypes and see examples.