Giter Site home page Giter Site logo

dariosalvi78 / cordova-plugin-health Goto Github PK

View Code? Open in Web Editor NEW

This project forked from incentfit/healthkit

175.0 175.0 126.0 1.07 MB

Cordova plugin for the HealthKit and Google Fit frameworks

License: MIT License

Objective-C 33.45% JavaScript 14.45% Java 52.10%
cordova-plugin fitness google-fit health healthkit mhealth

cordova-plugin-health's People

Contributors

aggarwalankush avatar albertinad avatar chandratejoma avatar dariosalvi78 avatar eddyverbruggen avatar emmavray avatar fniwes avatar hdavidzhu avatar jamtholee avatar julianlaval avatar kingsfleet avatar lamuertepeluda avatar lineke avatar lnelson-videra avatar marioshtika avatar michaelsolati avatar mrjustreborn avatar mschristo avatar nexus-uw avatar noktilux avatar northmccormick avatar paulmillr avatar petemcwilliams avatar pushparajsamant avatar rafaellop avatar randnetdd avatar schigh avatar seanbdoherty avatar sgilroy avatar wongpeiyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-health's Issues

Incorrect activity durations from Google Fit

Weird bug (feature?) with Google Fit - returned activities have the wrong start time if the query startDate param is between said activities' start and end time. Steps to reproduce:

  • Create an activity starting at 9am and ending at 10am via Google Fit.
  • Query activity with startDate = 9.30am and endDate = any time after 10am
  • startDate for the returned activity will be 9.30am rather than 9am.

This differs with HealthKit behaviour, which is to not return this event if the query startDate is between an activity's start and end time.

First of all, can you reproduce? Second, is this expected behaviour?

Android exec() call threading issue

Hi,

in an App where we sync several fitness data to server I encountered an App-freeze on calls. I thought that was a problem with proper dereferencing in the app and found it was caused by the plugins query and queryAggregated methods. (see logcat below)

W/PluginManager(32105): THREAD WARNING: exec() call to health.queryAggregated blocked the main thread for 643ms. Plugin should use CordovaInterface.getThreadPool().

W/PluginManager(32105): THREAD WARNING: exec() call to health.query blocked the main thread for 354ms. Plugin should use CordovaInterface.getThreadPool().

If I got some spare time I am going to try to fix it by myself, but do not want to leave it unmentioned.

Thank you very much for providing this repo,
keep going and have a nice weekend.

create isAuthorized() function

the function must accept an array of data types and must return if the app is authorized to access those types.

Telerik's plugin already has it implemented, it only needs data types to be translated.

In Google Fit, the only way is by asking for authorization without trying to auto-resolve the issue.

Support new Google Fit health data types (blood glucose, etc)

It looks like Google Fit has added support for blood pressure, blood glucose, and some other health data types. It would be great to have support for reading and writing these data types via cordova-plugin-health, and updated documentation to go with it.

References:
https://developers.google.com/android/reference/com/google/android/gms/fitness/data/HealthDataTypes.html#TYPE_BLOOD_GLUCOSE
https://developers.google.com/fit/scenarios/write-blood-glucose-data
https://developers.google.com/fit/scenarios/write-bp-data

I have not seen an explicit announcement for the change, but the above pages say "Last updated February 15, 2017".

These new metrics fall into the category of "restricted data types".

Note: Because health data is potentially sensitive, Google Fit restricts write access for the data types in HealthDataTypes to only certain developers.

datatype Activity: Calories not included in returned object (Android)

Hi,

First of all: thanks for you awesome plugin.

Currently I notice (with version 0.8.3 of the plugin) that the returned object for Activity Datatype, does not include calories.
Not 100% sure, but I think it should be returned in this case?

If I do this query:

navigator.health.queryAggregated({
startDate: new Date(year, month, day, 0, 0, 0).getTime() - 4 * 24 * 60 * 60 * 1000,
endDate: new Date(year, month, day, 23, 59, 59).getTime() - 4 * 24 * 60 * 60 * 1000,
dataType: 'activity',
}, function (msg) {
var str4 = JSON.stringify(msg);
console.log('day4 object is' + str4);
}, function (e) {
console.log(e);
});

The returned object is (which I log in the console as a string for test purpose):

{
"startDate":"2017-02-06T23:00:00.000Z",
"endDate":"2017-02-07T22:59:59.000Z",
"value":{"still":{"duration":70888730},
"in_vehicle":{"duration":6331334},
"walking":{"duration":5074437},
"swimming.pool":{"duration":1800000},
"running":{"duration":194074}},
"unit":"activitySummary"
}

If I look up this data in Google Fit, the calories for all these activities are available.

Kind regards, and thanks in advance
Frank

Paging on query

I am having an issue getting all the data back from the query method on iOS. It only returns me the first handful of results for a day rather than the whole payload. Is there a way to "page" the data to retreive the rest of it?

estimated steps

"queryAggregated" doesn't return estimated steps but "all" steps, even not significant ones. The result is that Google Fit app show me 2300 steps and "queryAggregated" returns me 6900 steps.

As explains here: https://developers.google.com/fit/faq#values-no-match
It should be interesting for "queryAggregated" to return estimated steps.
I tried and it works perfectly. I edited HealthPlugin.java and replaced line 622 by:

DataSource ESTIMATED_STEP_DELTAS = new DataSource.Builder()
.setDataType(DataType.TYPE_STEP_COUNT_DELTA)
.setType(DataSource.TYPE_DERIVED)
.setStreamName("estimated_steps")
.setAppPackageName("com.google.android.gms")
.build();
builder.aggregate(ESTIMATED_STEP_DELTAS, DataType.AGGREGATE_STEP_COUNT_DELTA);

Doesn't do anything on Android

I'm using this plugin with success on iOS, but Android is still not working for me.
I followed the documentation for setting up the Google Project with the proper oAuth keys.

I get no errors or what so ever when I try to authorize or retrieve data, even in adb logcat I don't see any errors with the tag cordova-plugin-health. When I use the method promptInstallFit and I don't have Google Fit installed it does redirect to the Play Store.

I do see this in adb logcat, but I don't know if it has anything to do with this plugin:

01-23 13:26:37.265 17072 17174 W CordovaPlugin: Attempted to send a second callback for ID: health1911832199
01-23 13:26:37.265 17072 17174 W CordovaPlugin: Result was: false

My system information:

Cordova CLI: 6.4.0
Ionic CLI Version: 2.1.14
Ionic App Lib Version: 2.1.7
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: OS X El Capitan
Node Version: v4.6.0
Xcode version: Xcode 8.2.1 Build version 8C1002

build.phonegap.com fail after update

There is a new error from build.phonegap.com:

Error - The following 3rd-party plugin is causing the build to fail and may need to be updated to a newer version: cordova-plugin-health

Attach all error log
error-log.txt

User cancelled the dialog

I am getting this error (User cancelled the dialog) when I try the simple code as the example in the Ionic Framework.

this.health.isAvailable()
.then((available:boolean) => {
  console.log(available);
  this.health.requestAuthorization([
    'distance', 'nutrition',  //read and write permissions
    {
      read: ['steps'],       //read only permission
      write: ['height', 'weight']  //write only permission
    }
  ])
  .then(res => console.log(res))
  .catch(e => console.log(e));
})
.catch(e => console.log(e));

Not getting sourceName in query response

Hi,
I am using Google Fit App to log the data and created my own application, in which I am using query method.
It returns only data without source name

[
{"startDate":"2017-06-06T01:50:35.663Z","endDate":"2017-06-6T01:51:35.663Z","value":7,"unit":"count"},
{"startDate":"2017-06-06T01:51:59.000Z","endDate":"2017-06-06T01:52:19.932Z","value":9,"unit":"count"},
{"startDate":"2017-06-06T01:52:19.932Z","endDate":"2017-06-6T01:52:59.000Z","value":18,"unit":"count"},
{"startDate":"2017-06-06T01:52:59.000Z","endDate":"2017-06-06T01:53:01.880Z","value":5,"unit":"count"},
{"startDate":"2017-06-06T01:53:29.384Z","endDate":"2017-06-06T01:54:29.384Z","value":7,"unit":"count"},
{"startDate":"2017-06-06T01:54:36.892Z","endDate":"2017-06-6T01:55:42.892Z","value":33,"unit":"count"},
{"startDate":"2017-06-06T01:58:03.893Z","endDate":"2017-06-6T01:59:03.893Z","value":16,"unit":"count"},
{"startDate":"2017-06-06T02:00:58.889Z","endDate":"2017-06-6T02:01:58.889Z","value":12,"unit":"count"},
{"startDate":"2017-06-06T02:01:58.889Z","endDate":"2017-06-06T02:02:01.631Z","value":2,"unit":"count"},
{"startDate":"2017-06-06T02:22:03.212Z","endDate":"2017-06-6T02:22:28.901Z","value":37,"unit":"count"},
{"startDate":"2017-06-06T02:22:36.901Z","endDate":"2017-06-06T02:23:36.901Z","value":8,"unit":"count"},
{"startDate":"2017-06-06T02:23:36.901Z","endDate":"2017-06-6T02:24:16.891Z","value":38,"unit":"count"},
{"startDate":"2017-06-06T02:24:16.891Z","endDate":"2017-06-06T02:24:23.445Z","value":7,"unit":"count"},
{"startDate":"2017-06-06T02:24:23.445Z","endDate":"2017-06-6T02:25:32.237Z","value":85,"unit":"count"},
{"startDate":"2017-06-06T02:25:32.237Z","endDate":"2017-06-06T02:25:33.535Z","value":2,"unit":"count"}
]

Let me know how to get sourceName. Also is it possible to get sourceName in queryAggregated() method?

Update documentation for limit and ascending

Healthkit.m

(void)querySampleType:(CDVInvokedUrlCommand *)command {
   NSDictionary *args = command.arguments[0];
   NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:[args[HKPluginKeyStartDate] longValue]];
   NSDate *endDate = [NSDate dateWithTimeIntervalSince1970:[args[HKPluginKeyEndDate] longValue]];
   NSString *sampleTypeString = args[HKPluginKeySampleType];
   NSString *unitString = args[HKPluginKeyUnit];
   NSUInteger limit = ((args[@"limit"] != nil) ? [args[@"limit"] unsignedIntegerValue] : 100);
   BOOL ascending = (args[@"ascending"] != nil && [args[@"ascending"] boolValue]);

is accepting limit as an int and ascending as a boolean value.

Would be great to update the documentation and examples. Otherwise the default is set to 100 and reverse order.

Potential device support error when including cordova-plugin-health to an existing iOS app

Per https://developer.apple.com/library/content/qa/qa1623/_index.html:

iTunes Connect does not allow uploading an updated version of an app when the update runs on fewer devices than the version of the app currently in the App Store. This is by design.

As it stands, the project's plugin.xml includes healthkit as a required capability (see UIRequiredDeviceCapabilities info here). This is problematic for a number of reasons:

  • Adding cordova-plugin-health to an app that has previously been added to the App Store is impossible, as this new key removes support for a number of devices that were previously supported (e.g. iPads), triggering the error mentioned above
  • Unless I'm mistaken, new apps that include this key will inherently be unavailable for devices that don't support Apple Health

Having removed this key from my fork, I can confirm that the plugin still works correctly and updates can once again be uploaded to the App Store. Although I haven't yet been able to test the app on a device that doesn't support Apple Health, I would assume that the isAvailable method respond correctly to this scenario.

Bearing all of this in mind, maybe it would be a good idea to remove this requirement altogether, or at least make it optional?

"GoogleApiClient is not connected yet." Android race condition

Querying Google Fit shortly after requesting authorisation sometimes yields the following:

nutrition error: "Cannot connect to Google Fit"
activity error: "Cannot connect to Google Fit"
GoogleApiClient is not connected yet.
nutrition.fat.total error: "Cannot connect to Google Fit"
nutrition.calories error: "Cannot connect to Google Fit"
nutrition.fat.saturated error: "Cannot connect to Google Fit"
nutrition.fat.polyunsaturated error: "Cannot connect to Google Fit"
nutrition.fat.monounsaturated error: "Cannot connect to Google Fit"
nutrition.sodium error: "Cannot connect to Google Fit"
nutrition.cholesterol error: "Cannot connect to Google Fit"
nutrition.carbs.total error: "Cannot connect to Google Fit"
nutrition.potassium error: "Cannot connect to Google Fit"
nutrition.dietary_fiber error: "Cannot connect to Google Fit"
nutrition.sugar error: "Cannot connect to Google Fit"
nutrition.vitamin_a error: "Cannot connect to Google Fit"
nutrition.calcium error: "Cannot connect to Google Fit"
nutrition.vitamin_c error: "Cannot connect to Google Fit"
nutrition.protein error: "Cannot connect to Google Fit"
nutrition.iron error: "Cannot connect to Google Fit"

This seems to only occur on first install / reinstall / hard reload. I suspect the root cause may be a race condition where Google Fit isn't yet ready but the authentication callback has successfully returned.

Any ideas on how this can avoided?

Details:
Galaxy S7 emulated in Genymotion
Android 7.1.0
API 25
Latest Play services (10.2.6)

GoogleApiClient is not connected yet.

It sometimes raise the message as title said, but not always. It seems that the onConnected() method will still be called in spite of current state is "isConnecting"
logcat log:
W/GmsClientEvents(20908): unregisterConnectionCallbacks(): listener org.apache.cordova.health.HealthPlugin$4@1a2e9b7 not found
I/cordova-plugin-health(20908): Google Fit connected
I/cordova-plugin-health(20908): enter_function_authReqSuccess
I/cordova-plugin-health(20908): after_request
I/cordova-plugin-health(23675): isConnected=false
I/cordova-plugin-health(23675): isConnecting= true
I/cordova-plugin-health(20908): authReqSuccess_error3= GoogleApiClient is not connected yet.

Details:
[email protected]
Nexus 7
Android 5.1.1
API 25
compile "com.google.android.gms:play-services-fitness:9.4.0"
compile "com.google.android.gms:play-services-gcm:9.0.2+"

src code:
`private void authReqSuccess(){
//Create custom data types
new Thread(new Runnable(){

        @Override
        public void run() {
            try{
                Log.i(TAG, "enter_function_authReqSuccess");
                String packageName = cordova.getActivity().getApplicationContext().getPackageName();
                DataTypeCreateRequest request = new DataTypeCreateRequest.Builder()
                        .setName(packageName+".gender")
                        .addField("gender",Field.FORMAT_STRING)
                        .build();
                Log.i(TAG, "after_request");
                Log.i(TAG, "isConnected="+mClient.isConnected());
                Log.i(TAG, "isConnecting= "+mClient.isConnecting());
                PendingResult<DataTypeResult> pendingResult =  Fitness.ConfigApi.createCustomDataType(mClient, request);
                ...
                authReqCallbackCtx.success();
            } catch (Exception ex){
                Log.i(TAG, "authReqSuccess_error3= "+ex.getMessage());
                authReqCallbackCtx.error(ex.getMessage());
            }
        }
    }).start();
}`

Plugin dont exist in Android

Plugin dont exist in Android plugins.healthkit
In iPhone everything is good.
Samsung S4
Android 5.0.1
Google Fit & Play are installed

add healthkit entitlements in plugin.xml

add these two to plugin.xml as done in Telerik's plugin:

    <config-file target="*/Entitlements-Debug.plist" parent="com.apple.developer.healthkit">
      <true/>
    </config-file>

    <config-file target="*/Entitlements-Release.plist" parent="com.apple.developer.healthkit">
      <true/>
    </config-file>

Android queryAggregated() function date problem

I have a trouble with date param in queryAggregated() function.
So that code works perfectly in iOS:

navigator.health.queryAggregated({
    startDate: new Date(new Date().getTime() - 3 * 24 * 60 * 60 * 1000), // three days ago
    endDate: new Date(), // now
    dataType: 'steps'
}, function(msg){
    console.log(msg)
}, function(e){
    console.log(e)
})

returns in iOS:

endDate: Fri Aug 05 2016 13:25:40 GMT+0500 (AZST)
startDate: Tue Aug 02 2016 13:25:40 GMT+0500 (AZST)

return in Android:

endDate: Thu Aug 04 2016 19:25:11 GMT+0500 (AZST)
startDate: Thu Aug 04 2016 19:24:11 GMT+0500 (AZST)

So you see there are not correct result in Android.
Please help with advice, thanks.

P.S.

That code even don't works on Android, but in iOS works good:

var year = new Date().getFullYear();
var month = new Date().getMonth();
var date = new Date().getDate();

var morning = new Date(year, month, date, 0, 0, 0);
var night = new Date(year, month, date, 23, 59, 59);

navigator.health.queryAggregated({
    startDate: morning, 
    endDate:night, 
    dataType: 'steps'
}, function(msg){
    console.log(msg)
}, function(e){
    console.log(e)
})

iOS return:

endDate: Fri Aug 05 2016 23:59:59 GMT+0500 (AZST)
startDate: Fri Aug 05 2016 00:00:00 GMT+0500 (AZST)
unit: "count"
value: 840

Android return:

endDate: Invalid Date
startDate: Invalid Date

for the same code

Is there a way to check if it has been authorized?

I want to implement the setting page which can show if Google fit is connected. As I observed from other apps on iOS, it seems it is not possible on iOS right?
But for Google Fit, since requestAuthorization prompts the user if it has not been authorized, is there a way to know that without prompting the user?

Android error on empty nutrient query

Attempting to query a specific nutrient from Google Fit, e.g. nutrition.cholesterol, for which no data exists yields the following error:

Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference

Diving deeper, it seems this issue only occurs when other nutrients aren't empty. For example, in my setup I concurrently poll nutrition and all common nutrients. If all are empty, no problem:

nutrition.calories []
nutrition.carbs.total []
nutrition.dietary_fiber []
nutrition.sugar []
nutrition.protein []
nutrition.vitamin_a []
nutrition.vitamin_c []
nutrition.calcium []
nutrition.iron []
nutrition.water []
nutrition.fat.saturated []
nutrition []
nutrition.potassium []
nutrition.cholesterol []
nutrition.fat.monounsaturated []
nutrition.fat.polyunsaturated []
nutrition.fat.total []
nutrition.sodium []

But if values are returned for some, the error is thrown for others:

nutrition.fat.saturated [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":21.850000381469727,"unit":"g"}]
nutrition.calories [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":1100,"unit":"kcal"}]
nutrition.fat.polyunsaturated error: "Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference"
nutrition.fat.monounsaturated [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":31.149999618530273,"unit":"g"}]
nutrition.sodium [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":1.8665000200271606,"unit":"mg"}]
nutrition.cholesterol error: "Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference"
nutrition.carbs.total [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":114,"unit":"g"}]
nutrition.potassium [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":0.7770000100135803,"unit":"mg"}]
nutrition.sugar [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":15,"unit":"g"}]
nutrition [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":{"item":"Pizza margherita","meal_type":"lunch","nutrients":{"nutrition.calories":1100,"nutrition.fat.total":53,"nutrition.fat.saturated":21.850000381469727,"nutrition.fat.monounsaturated":31.149999618530273,"nutrition.sodium":1.8665000200271606,"nutrition.potassium":0.7770000100135803,"nutrition.carbs.total":114,"nutrition.dietary_fiber":8.5,"nutrition.sugar":15,"nutrition.protein":41.5}},"unit":"nutrition"}]
nutrition.dietary_fiber [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":8.5,"unit":"g"}]
nutrition.protein [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":41.5,"unit":"g"}]
nutrition.fat.total [{"startDate":"2017-06-03T11:00:00.000Z","endDate":"2017-06-03T11:00:00.005Z","sourceName":"lifesum-nutrition","sourceBundleId":"com.sillens.shapeupclub","value":53,"unit":"g"}]
nutrition.calcium error: "Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference"
nutrition.vitamin_c error: "Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference"
nutrition.vitamin_a error: "Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference"
nutrition.water []
nutrition.iron error: "Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference"

Any ideas?

[iOS] unknown data type distanace

When I was calling requestAuthorization to authorize "distance" on iOS, it returns with this error message.

unknown data type distanace

It is working on Android though.
I've tried "calories" and "activity", and they are working on iOS.

Ionic2 Support

Hey there!

Is there any update on supporting Ionic2 and creating an IonicNative wrapper?

how to just ask for 'read' permissions?

I'm using 'requestAuthorization' to read health data as mentioned in docs. But by default, it asks for read and write permissions. How can I just ask for 'read' permission?

differentiate between basal and expended calories

HK laready has a clear differentiation:
HKQuantityTypeIdentifierBasalEnergyBurned;
HKQuantityTypeIdentifierActiveEnergyBurned;

in Android there are:
TYPE_BASAL_METABOLIC_RATE
TYPE_CALORIES_EXPENDED
but TYPE_CALORIES_EXPENDED includes also the basal expenditure AFAIK

Using obfuscated API Field.zzn() in Android

The Android source is using an undocumented and obfuscated, but publicly accessible method, called Field.zzn(...). The problem with this, that because it is obfuscated, it can change anytime.
In my source version it is already called Field.zzl(...), so the plugin does not work out of the box for Android.

add HKMetadataKeyBloodGlucoseMealTime with Blood Glucose meal in iOS

include the HKMetadataKeyBloodGlucoseMealTime meta key with the blood glucose.

This needs:

  • the blood_glucose query to return an object with glucose and mealtime
  • meal time should be coded into these: "fasting", "breakfast", "dinner", "lunch", "snack", "unknown", "before_breakfast", "before_dinner", "before_lunch", "before_snack", "after_breakfast", "after_dinner", "after_lunch", "after_snack"
  • the key must be added to HealthKit.m
  • should work for both read and write

Duration data in returned object incorrect on Android?

Dear @dariosalvi78 ,

First of all: thanks for you awesome plugin. It really is very awesome :)

However I am wondering if the duration information in the returned object for Android is correct?
An example of an object returned if I query for 'Activity' with navigator.health.queryAggregated

{"startDate":"2017-04-22T22:00:00.000Z","endDate":"2017-04-23T21:59:59.000Z","value":{
"still":{"duration":86399000,"calories":1068.8572998046875},
"in_vehicle":{"duration":81471533,"calories":341.9926452636719},
"walking":{"duration":44405366,"calories":762.522216796875},
"running":{"duration":5969930,"calories":1568.8883056640625},
"unknown":{"duration":1936558,"calories":0}
},"unit":"activitySummary"}

If you count everything together, tot total is a bit more than 61 hours, while the timespan is 24 hours.
The "running" information is correct, but for example the "walking" information is wrong.

Thanks for having a look!
Frank

cannot find symbol method hasPermission

Got following error on running the application:
`Error:(165, 29) error: cannot find symbol method hasPermission(String)
Error:(172, 24) error: cannot find symbol method requestPermissions(HealthPlugin,int,String[])
Error:Execution failed for task ':compileDebugJava'.

Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
`

public void requestDynamicPermissions() {
        if (dynPerms.isEmpty()) {
            authReqCallbackCtx.success();
        } else {
            LinkedList<String> perms = new LinkedList<String>();
            for (String p : dynPerms) {
                if (!cordova.hasPermission(p)) {
                    perms.add(p);
                }
            }
            if (perms.isEmpty()) {
                authReqCallbackCtx.success();
            } else {
                cordova.requestPermissions(this, REQUEST_DYN_PERMS, perms.toArray(new String[perms.size()]));
            }
        }
    }

Is it possible to pass in NSHealthShareUsageDescription and NSHealthUpdateUsageDescription strings using Phonegap Build?

Is it possible to pass in NSHealthShareUsageDescription and NSHealthUpdateUsageDescription strings using Phonegap Build?

For example the cordova-plugin-media-capture uses variables to add strings to the info.plist:

<plugin name="cordova-plugin-media-capture" source="npm" version="1.4.1">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera." />
        <variable name="MICROPHONE_USAGE_DESCRIPTION" value="App would like to access the microphone." />
        <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library." />
    </plugin>

Support queries for nutrition (dietary/food) data types in Google Fit

We are currently using the Telerik HealthKit plugin to get nutrition data types from HealthKit. The cordova-plugin-health plugin does not (yet) support this.

To get nutrition data from Google Fit, query for DataType.TYPE_NUTRITION. For each data point, nutrients can be retrieved via datapoint.getValue(Field.FIELD_NUTRIENTS) and then specifiec nutrients can be retrieved via nutrients.getKeyValue(Field.NUTRIENT_TOTAL_CARBS).

Documentation on Field.FIELD_NUTRIENTS:
https://developers.google.com/android/reference/com/google/android/gms/fitness/data/Field.html#FIELD_NUTRIENTS

List of nutrients (constants prefixed with NUTRIENT_):
https://developers.google.com/android/reference/com/google/android/gms/fitness/data/Field#constant-summary

Tasks:

  • include all nutrient types in nutritiondatatypes
  • support retrieving samples for each nutrient type in query() with appropriate unit value for each type
  • support aggregated queries for each nutrient type in queryAggregated()

Eventually, support should also be added for mapping and querying the equivalent data types in HealthKit (see this list for reference). However, I don't personally need HealthKit support at the moment, so I will start with just the Google Fit side.

How to revoke Authorization?

Hello,

Once I do

navigator.health.requestAuthorization(['steps'], successCallback, errorCallback)

How to revoke or detach this?

OAuth2 consent error

I am getting this error: Application needs OAuth consent from the user.
These are the permissions I have passed to requestAuthorization():
permissionsAndroid = [
'TYPE_HEIGHT',
'TYPE_WEIGHT',
'TYPE_STEP_COUNT_DELTA'
];

Getting empty array in result.

I want to fetch step history by query 3 days result i.e

navigator.health.queryAggregated({ startDate: new Date(new Date().getTime() - 3 * 24 * 60 * 60 * 1000), // three days ago endDate: new Date(), // now dataType: 'steps', bucket: 'day' }, function (succ) { $scope.result = succ; }, function (err) { $scope.error = err; });

this returned empty array in iOS 10

Real iOS device issue

Hello, I realize that this comes from the original Health Plugin, so I've opened the issue there, but this plugin depends on it, so it's better to have it here as well I think:

Building/Deploying for the actual iOS device causes a linker error:
Undefined symbols for architecture armv7:
"_HKCharacteristicTypeIdentifierFitzpatrickSkinType", referenced from:
-[HealthKit readFitzpatrickSkinType:] in HealthKit-18B10050B69093A6.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ios10 - Missing parameters in info.plist

Not quite sure where exactly it belongs into, but as of iOS 10 following two parameters have to be present in the info.plist

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW48

NSHealthShareUsageDescription="A very good reason why I want to read your data.";
NSHealthUpdateUsageDescription="A very good reason why I want to write data.";

80leaves

p.s. also opened up the same issue in HealthKit project
EddyVerbruggen#77

Do not open Google Play Store for Google Fit if not available

Currently if Google Fit is not installed, calling health.isAvailable() will open the Google Play Store to allow the user to install Google Fit. This is problematic in my application because we want to determine if Google Fit is available and then from there decide what to show the user with regards to options for enabling Google Fit integration. Checking for availability should be a separate method from helping the user install Google Fit. Alternatively, the same method isAvailable() could be used, but an optional parameter could be used to determine whether to open the Google Play Store if the package is not installed.

cannot access AbstractSafeParcelable

After I updated Andoid SDK the fallowing error showed up

Error : C:...\android\src\org\apache\cordova\health\HealthPlugin.java:70: error: cannot access AbstractSafeParcelable
Error : public static Map<String, DataType> activitydatatypes = new HashMap<String, DataType>();
Error : class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found

Calories empty in iOS

Hi,

I have a problem that the calories stay empty on iOS. I can access my steps

[{"startDate":"2017-03-09T23:00:00.000Z","endDate":"2017-03-10T23:00:00.000Z","value":3501,"unit":"count"},{"startDate":"2017-03-10T23:00:00.000Z","endDate":"2017-03-11T23:00:00.000Z","value":2719,"unit":"count"},{"startDate":"2017-03-11T23:00:00.000Z","endDate":"2017-03-12T23:00:00.000Z","value":290,"unit":"count"},{"startDate":"2017-03-12T23:00:00.000Z","endDate":"2017-03-13T23:00:00.000Z","value":1031,"unit":"count"},{"startDate":"2017-03-13T23:00:00.000Z","endDate":"2017-03-14T23:00:00.000Z","value":620,"unit":"count"},{"startDate":"2017-03-14T23:00:00.000Z","endDate":"2017-03-15T23:00:00.000Z","value":1092,"unit":"count"},{"startDate":"2017-03-15T23:00:00.000Z","endDate":"2017-03-16T23:00:00.000Z","value":736,"unit":"count"},{"startDate":"2017-03-16T23:00:00.000Z","endDate":"2017-03-17T23:00:00.000Z","value":640.9999999999999,"unit":"count"},{"startDate":"2017-03-17T23:00:00.000Z","endDate":"2017-03-18T23:00:00.000Z","value":2118,"unit":"count"},{"startDate":"2017-03-18T23:00:00.000Z","endDate":"2017-03-19T23:00:00.000Z","value":43,"unit":"count"},{"startDate":"2017-03-19T23:00:00.000Z","endDate":"2017-03-20T23:00:00.000Z","value":0,"unit":"count"}]

But when I look at calories it remains 0.
[{"startDate":"2017-03-09T23:00:00.000Z","endDate":"2017-03-10T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-10T23:00:00.000Z","endDate":"2017-03-11T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-11T23:00:00.000Z","endDate":"2017-03-12T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-12T23:00:00.000Z","endDate":"2017-03-13T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-13T23:00:00.000Z","endDate":"2017-03-14T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-14T23:00:00.000Z","endDate":"2017-03-15T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-15T23:00:00.000Z","endDate":"2017-03-16T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-16T23:00:00.000Z","endDate":"2017-03-17T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-17T23:00:00.000Z","endDate":"2017-03-18T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-18T23:00:00.000Z","endDate":"2017-03-19T23:00:00.000Z","value":0,"unit":"kcal"},{"startDate":"2017-03-19T23:00:00.000Z","endDate":"2017-03-20T23:00:00.000Z","value":0,"unit":"kcal"}]

Is this a misconfiguration?

Kind regards,
Kab

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.