Skip to content

vikramezhil/cordova-plugin-humanapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-humanapi

humanapi cordova plugin for android & ios

Current version

v1.0.5

Plugin installation

via npm

npm i cordova-plugin-humanapi

via cordova

cordova plugin add cordova-plugin-humanapi

via ionic

ionic cordova plugin add cordova-plugin-humanapi

Documentation

For a detailed documentation 📔, please have a look at the Wiki.

IOS Prerequisites

  • The human API code for IOS is written in swift 4 language. In order to use this plugin, your project deployment target should be set to a minimum of 11.

  • In case your project doesn't have swift support, please add this plugin

  • The Xcode Version should be 10.0+

  • The swift version (found under Build Settings) in Xcode should be set to 4

Usage

Cordova, Ionic 1

Authentication

window.plugin.humanapi.auth("CLIENT_ID", "CLIENT_SECRET", "USER_ID", "PUBLIC_TOKEN", "ACCESS_TOKEN", function(result) {
    alert("Result = " + result)
}, function(error) {
    alert("Error = " + error)
})

Wellness Data

window.plugin.humanapi.execute("WELLNESS_NAME", "ACCESS_TOKEN", function(result) {
    alert("Result = " + result)
}, function(error) {
    alert("Error = " + error)
})

window.plugin.humanapi.executeByFilter("WELLNESS_NAME", "ACCESS_TOKEN", "FILTER_NAME", function(result) {
    alert("Result = " + result)
}, function(error) {
    alert("Error = " + error)
})

Sources Data

window.plugin.humanapi.execute("sources", "ACCESS_TOKEN", function(result) {
    alert("Result = " + result)
}, function(error) {
    alert("Error = " + error)
})

Ionic 2+

Authentication

var human: any = window
human.plugin.humanapi.auth("CLIENT_ID", "CLIENT_SECRET", "USER_ID", "PUBLIC_TOKEN", "ACCESS_TOKEN", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})

Wellness Data

var human: any = window
human.plugin.humanapi.execute("WELLNESS_NAME", "ACCESS_TOKEN", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})

human.plugin.humanapi.executeByFilter("WELLNESS_NAME", "ACCESS_TOKEN", "FILTER_NAME", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})

Sources Data

var human: any = window
human.plugin.humanapi.execute("sources", "ACCESS_TOKEN", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})

Authentication Data Format

{
  clientID: "CLIENT_ID",
  clientSecret: "CLIENT_SECRET",
  userID: "USER_ID",
  humanID: "HUMAN_ID",
  sessionToken: "SESSION_TOKEN",
  publicToken: "PUBLIC_TOKEN",
  accessToken: "ACCESS_TOKEN", 
  pluginMsg: "The plugin message if any"
}

Wellness Supported API's & Data Format

{
  humanAPIData: "WELLNESS_API_DATA",
  key: "PASSED_KEY",
  pluginMsg: "The plugin message if any"
}

Currently the plugin supports 17 wellness API's (excluding Genetic Traits & Genotypes). Please refer for the list of wellness API's and data formats here

Sources Data Format

{
  humanAPIData: "SOURCES_API_DATA",
  key: "PASSED_KEY",
  pluginMsg: "The plugin message if any"
}

Please refer to sources data format here

Examples

For general plugin examples, please refer here

For a full fledged ionic example, please refer here