This Titanium module makes it possible to read data from Google Fitness.
- Build this project or download the module from the
distdirectory. - Require the module.
- Get an OAuth 2.0 Client ID
- Add the ACTIVITY_RECOGNITION permission to the tiapp.xml file.
- Use the module.
Checks whether you have permissions for the dataTypes parameters.
- Required Array of strings
dataTypes- Specify all the data types you are interested in. See below for all types. - Required Boolan
write- Currently writing data is not possible yet, so use alwaysfalse.
- Required Array of strings
dataTypes- Specify all the data types you are interested in. See below for all types. - Required Boolan
write- Currently writing data is not possible yet, so use alwaysfalse. - Required Function
callback- Will be called after success or error.
Disables the Google Fit connection and removes all subsciptions.
Removes all subscriptions.
- Optional Function
callback- Will be called after success or error.
Retrieves all subscriptions.
- Optional Function
callback- Will be called after success or error.
Subscribes to the specified data types.
- Required Array of strings
dataTypes- Specify all the data types you are interested in. See below for all types. - Optional Function
callback- Will be called after success or error.
Retrieves data.
- Required Object
arg- Available keys:- Required Date
startDate- The start date for the data. Be aware that this date determines how the buckets (the time slots) will be. For example if you use the current time but 7 days ago and sets thetimeFrametoday, then you get buckets that exactly start at the specified time. If the time is 15:35h, then you get buckets from 12/06/2020 15:35:00 - 13/06/2020 15:35:00, 13/06/2020 15:35:00 - 14/06/2020 15:35:00 etc. So make sure you set thestartDateto exactly the time you want the buckets to start. - Required Date
endDate- The end date for the data. - Required Array of strings
dataTypes- Specify all the data types you are interested in. See below for all types. - Required String
timeFrame- A string indicating the bucket time. Possible values:minute,hour,day,week.
- Required Date
- Required Function
callback- Will be called after success or error. The argument of this callback has aresultkey which is an array with objects. Each object has:startDate- ISO8601 date stringendDate- ISO8601 date stringdataSets- Object with key = name of data type and value = Object of:- key = name of field (for example
stepsorduration- this depends on the date type), value = value of field
- key = name of field (for example
You can call this everytime before you call getData if you wish. If we already have the necessary permissions, nothing happens so it won't crash your app. But it can have some performance consequences. Maybe a better approach is to call requestPermissions only once in a session.
You can specify the data types by using the module's constants, for example:
const googlefit = require("mve.googlefit");
console.log(googlefit.TYPE_STEP_COUNT_DELTA);
- TYPE_STEP_COUNT_DELTA
- TYPE_MOVE_MINUTES
- TYPE_CALORIES_EXPENDED
- TYPE_HEART_POINTS
- TYPE_HEART_RATE_BPM
Clone this project. Go inside the android directory and do:
ti build -p android --build-only
This project is licensed under the GNU GPLv3 License - see the LICENSE file for details.