Menu

 

Cordova

Cordova plugin for integrating WeFitter and HealthKit into your app

Installation

cordova plugin add https://github.com/wefitter/cordova-plugin-wefitter-ios.git#v2.0.1

 

Usage

Add the following code inside onDeviceReady in www/js/index.js:

See wefitterhealthkit.js for all available functions.

Show code example
Hide code example

var configureSuccess = function (message) {
  console.log(message);
  // Connect can be called after configure has succeeded
  wefitterhealthkit.connect(success, failure);
};

var success = function (message) {
  console.log(message);
  alert(message);
};

var failure = function (message) {
  console.log(message);
  alert(message);
};

var config = {
  token: "YOUR_TOKEN", // required, WeFitter API profile bearer token
  url: "CUSTOM_URL", // optional, the url should be base without `v1.3/ingest/` as the library will append this. Default: `https://api.wefitter.com/api/`
  startDate: "CUSTOM_START_DATE", // optional with format `yyyy-MM-dd`, by default data of the past 20 days will be uploaded
  enabledDataTypes: ['CUSTOM_DATA_TYPES'], // optional array of datatypes to customize requested permissions. Default: all
  enableDailyDetail: false, // optional boolean that enables uploading of daily detail. This wil result in a lot of extra processing and can slow down syncing of data when there is a lot of historic data. Default: false
  enableHeartRateSamples: false, // optional boolean that enables uploading of heart rate samples. This wil result in a lot of extra processing and can slow down syncing of data when there is a lot of historic data. Default: false
};

// Configure should be called every time your app starts when HealthKit is supported
wefitterhealthkit.canConnectToHealthData((supported) => {
  if (supported) {
    wefitterhealthkit.configure(config, configureSuccess, failure);
  }
});

Thank you for reaching out!

We will be in touch with you soon. WeFitter team.

You are subscribed!

You will soon receive our newsletter!
WeFitter team.