Menu

 

Cordova

Cordova plugin for integrating WeFitter and Health Connect into your app

Installation

cordova plugin add https://github.com/wefitter/cordova-plugin-wefitter-health-connect.git#v0.0.1

 

Usage

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

See wefitterhealthconnect.js for all available functions.

Show code example
Hide code example

// create success and failure handlers to receive status changes and errors
const success = (status) => {
  switch (status) {
    case "CONFIGURED":
      console.log(status);

      // enable connection if it hasn't already been enabled,
      // or move this for example to a button press or toggle change
      // and then `wefitterhealthconnect.disconnect()` is also useful.
      wefitterhealthconnect.isConnected((connected) => {
        if (!connected) wefitterhealthconnect.connect();
      });
      break;
    case "NOT_CONFIGURED":
      console.log(status);
      break;
    case "CONNECTED":
      console.log(status);
      break;
    case "DISCONNECTED":
      console.log(status);
      break;
  }
};
const failure = (error) => {
  console.log(error);
};

// create config
const config = {
  token: "YOUR_TOKEN", // required, WeFitter API profile bearer token
  apiUrl: "YOUR_API_URL", // optional, only use if you want to use your backend as a proxy and forward all API calls to the WeFitter API. 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
  notificationTitle: "CUSTOM_TITLE", // optional
  notificationText: "CUSTOM_TEXT", // optional
  notificationIcon: "CUSTOM_ICON", // optional, e.g. `ic_notification` placed in either drawable, mipmap or raw
  notificationChannelId: "CUSTOM_CHANNEL_ID", // optional
  notificationChannelName: "CUSTOM_CHANNEL_NAME", // optional
};

// configure wefitterhealthconnect
wefitterhealthconnect.configure(config, success, 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.