Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stridekick/react-native-google-fit

Package Overview
Dependencies
Maintainers
5
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stridekick/react-native-google-fit - npm Package Compare versions

Comparing version
3.0.9
to
3.0.10
.prettierignore

Sorry, the diff of this file is not supported yet

+7
arrowParens: 'always'
bracketSpacing: true
printWidth: 120
semi: false
singleQuote: true
tabWidth: 2
trailingComma: 'all'
+4
-4

@@ -42,6 +42,6 @@ def DEFAULT_COMPILE_SDK_VERSION = 23

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.facebook.react:react-native:+'
compile "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-fitness:$googlePlayServicesVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.facebook.react:react-native:+'
implementation "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
implementation "com.google.android.gms:play-services-fitness:$googlePlayServicesVersion"
}

@@ -185,17 +185,23 @@ /**

for (DataPoint dp : dataSet.getDataPoints()) {
Log.i(TAG, "Data point:");
Log.i(TAG, "\tType: " + dp.getDataType().getName());
Log.i(TAG, "\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
Log.i(TAG, "\tEnd: " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
Field field = dp.getDataType().getFields().get(0);
String fieldName = field.getName();
if (fieldName.equals("duration")) {
activityMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
activityMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
activityMap.putDouble("minutes", dp.getValue(field).asInt());
activityMap.putDouble("startDate", dp.getStartTime(TimeUnit.MILLISECONDS));
activityMap.putDouble("endDate", dp.getEndTime(TimeUnit.MILLISECONDS));
for (Field field : dp.getDataType().getFields()) {
Log.i(TAG, "\tValue: " + dp.getValue(field));
String fieldName = field.getName();
if (fieldName.equals("duration")) {
activityMap.putDouble("minutes", dp.getValue(field).asInt());
}
if (fieldName.equals("distance")) {
activityMap.putDouble("distance", dp.getValue(field).asFloat());
}
if (fieldName.equals("steps")) {
activityMap.putDouble("steps", dp.getValue(field).asInt());
}
}
if (fieldName.equals("distance")) {
activityMap.putDouble("distance", dp.getValue(field).asFloat());
}
if (fieldName.equals("steps")) {
activityMap.putDouble("steps", dp.getValue(field).asInt());
}
}

@@ -202,0 +208,0 @@ }

+48
-36
'use strict'
import {DeviceEventEmitter, NativeModules} from 'react-native';
import { DeviceEventEmitter, NativeModules } from 'react-native'
const googleFit = NativeModules.RNGoogleFit;
const googleFit = NativeModules.RNGoogleFit

@@ -25,53 +25,65 @@ const METERS_PER_MILE = 0.000621371

/**
* Get the total distance per day over a specified date range.
* @param {Object} options getDailyDistanceSamples accepts an options object containing required startDate: ISO8601Timestamp and endDate: ISO8601Timestamp.
* @callback callback The function will be called with an array of elements.
*/
* Get the total distance per day over a specified date range.
* @param {Object} options getDailyDistanceSamples accepts an options object containing required startDate: ISO8601Timestamp and endDate: ISO8601Timestamp.
* @callback callback The function will be called with an array of elements.
*/
getActivities(options) {
let startDate = Date.parse(options.startDate);
let endDate = Date.parse(options.endDate);
let startDate = Date.parse(options.startDate)
let endDate = Date.parse(options.endDate)
return new Promise((resolve, reject) => {
googleFit.getActivities(startDate, endDate, (error) => {
resolve(error);
}, (response) => {
if (response.length > 0) {
const rawResponse = response[0]
const distance = rawResponse.distance * METERS_PER_MILE
const activities = {
...rawResponse,
distance,
googleFit.getActivities(
startDate,
endDate,
(error) => {
resolve(error)
},
(response) => {
if (response.length > 0 && !!response[0].startDate) {
const rawResponse = response[0]
const distance = rawResponse.distance * METERS_PER_MILE
const activities = {
...rawResponse,
distance,
}
return resolve(activities)
}
return resolve(activities)
}
return resolve({})
})
return resolve({})
},
)
})
}
isAvailable(callback) { // true if GoogleFit installed
isAvailable(callback) {
// true if GoogleFit installed
return new Promise((resolve, reject) => {
googleFit.isAvailable((error) => {
resolve(error)
}, (response) => {
resolve(response)
});
googleFit.isAvailable(
(error) => {
resolve(error)
},
(response) => {
resolve(response)
},
)
})
}
isEnabled(callback) { // true if permission granted
isEnabled(callback) {
// true if permission granted
return new Promise((resolve, reject) => {
googleFit.isEnabled((error) => {
resolve(error)
}, (response) => {
resolve(response)
});
googleFit.isEnabled(
(error) => {
resolve(error)
},
(response) => {
resolve(response)
},
)
})
}
}
export default new RNGoogleFit();
export default new RNGoogleFit()
{
"name": "@stridekick/react-native-google-fit",
"version": "3.0.9",
"version": "3.0.10",
"description": "A React Native bridge module for interacting with Google Fit",

@@ -5,0 +5,0 @@ "main": "index.js",