Giter Club home page Giter Club logo

healthkit's Introduction

Cordova HealthKit Plugin

NPM version Downloads Twitter Follow

Supported functions

See the example for how to use these functions.

  • available: check if HealthKit is supported (iOS8+, not on iPad)
  • checkAuthStatus: pass in a type and get back on of undetermined | denied | authorized
  • requestAuthorization: ask some or all permissions up front
  • readDateOfBirth: formatted as yyyy-MM-dd
  • readGender: output = male|female|other|unknown
  • readBloodType: output = A+|A-|B+|B-|AB+|AB-|O+|O-|unknown
  • readFitzpatrickSkinType: output = I|II|III|IV|V|VI|unknown
  • readWeight: pass in unit (g=gram, kg=kilogram, oz=ounce, lb=pound, st=stone)
  • saveWeight: pass in unit (g=gram, kg=kilogram, oz=ounce, lb=pound, st=stone) and amount
  • readHeight: pass in unit (mm=millimeter, cm=centimeter, m=meter, in=inch, ft=foot)
  • saveHeight: pass in unit (mm=millimeter, cm=centimeter, m=meter, in=inch, ft=foot) and amount
  • saveWorkout
  • findWorkouts: no params yet, so this will return all workouts ever of any type
  • querySampleType
  • querySampleTypeAggregated
  • sumQuantityType
  • monitorSampleType
  • saveQuantitySample
  • saveCorrelation
  • queryCorrelationType
  • deleteSamples

Resources

Tips

Installation

Using the Cordova CLI?

cordova plugin add com.telerik.plugins.healthkit --variable HEALTH_READ_PERMISSION='App needs read access' --variable HEALTH_WRITE_PERMISSION='App needs write access'

HEALTH_READ_PERMISSION and HEALTH_WRITE_PERMISSION are shown when your app asks for access to data in HealthKit.

Using PhoneGap Build?

<plugin name="com.telerik.plugins.healthkit" source="npm" />

<!-- Read access -->
<config-file platform="ios" parent="NSHealthShareUsageDescription">
  <string>App needs read access</string>
</config-file>
<!-- Write access -->
<config-file platform="ios" parent="NSHealthUpdateUsageDescription">
  <string>App needs write access</string>
</config-file>

Using PhoneGap Build - cli-7 or superior?

PhoneGap Build has recently migrated from the custom build process to the standard Cordova build process. If you are already running on the new builder, it is no longer necessary to add the variables differently, and the variables must be defined as in the Cordova case.

<platform name="ios">
    <plugin name="com.telerik.plugins.healthkit" spec="^0.5.5" >
        <variable name="HEALTH_READ_PERMISSION" value="App needs read access" />
        <variable name="HEALTH_WRITE_PERMISSION" value="App needs write access" />
    </plugin>        
</platform>

Need Clinical Records Functionality (FHIR)?

If you would like to read clinical record (FHIR) data from the HealthKit store you can use the fork of this plugin here. Please see #113 for why this was functionality was removed from this plugin.

healthkit's People

Contributors

anibalsanchez avatar awatson1978 avatar drbeermann avatar eddyverbruggen avatar emmavray avatar hdavidzhu avatar igoris avatar kingsfleet avatar lamuertepeluda avatar northmccormick avatar paulmillr avatar rossmartin avatar schigh avatar seanbdoherty avatar sgilroy 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  avatar  avatar  avatar  avatar  avatar  avatar

healthkit's Issues

Denied status for accepted ReadTypes

I have these read types -

['HKQuantityTypeIdentifierBodyMass','HKQuantityTypeIdentifierStepCount','HKQuantityTypeIdentifierHeartRate']

Plugin is able to pull the data and read it. It works great. But if run checkAuthStatus like this -

window.plugins.healthkit.checkAuthStatus({ type : "HKQuantityTypeIdentifierBodyMass" },console.log,console.log);

it always return denied even if the permissions are granted.

Platform : iOS 8.3

findWorkouts doesn't return bundleIdentifier or workoutActivity

When I query findWorkouts I'm just getting back duration, startDate and endDate.
It appears bundleIdentifier and workoutActivity are not being returned.

Here's the code:

NSMutableDictionary *entry = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithDouble:workout.duration], @"duration",
[df stringFromDate:workout.startDate], HKPluginKeyStartDate,
[df stringFromDate:workout.endDate], HKPluginKeyEndDate,
workout.source.bundleIdentifier, HKPluginKeySourceBundleId,
workoutActivity, @"activityType",
nil
];

querySampleType and sumQuantityType functions not working

Hello Eddy,
I just played with the plugin and all functions work properly (read/save Weight/Height) except the querySampleType and sumQuantityType function. I don't get any response from those functions whatsoever (nor onSuccess, not onError). What could be wrong or where should I be looking? I just upgraded to iOS 8.3, I haven't tried it on earlier version though, so I was thinking if this is perhaps an issue.
Using phonegap-version 3.7.0 and I include the plugin in config.xml using gap:plugin name="com.telerik.plugins.healthkit"

Wish: Determine activity type

Is there a way to have findWorkouts() return activityType associated with each activity? i.e. walking, running...etc.

iOS 9 Issues?

Has anyone tried using this with iOS 9? I'm having issues with the querySampleType functionality and am receiving this error:

[Log] Error in Success callbackId: HealthKit706152221 : TypeError: undefined is not an object (evaluating 'd.getDate') (console-via-logger.js, line 173)

Still trying to track it down but haven't figured it out yet.

Active calories permission asked for even when energy not entered

Entering an activity like this:

window.plugins.healthkit.saveWorkout(
  {
    'activityType': 'HKWorkoutActivityTypeFishing',
    'quantityType': 'HKWorkoutTypeIdentifier',
    'requestReadPermission' : true, // set this if you don't need to read workouts as well
    'startDate': new Date(), // mandatory
    'endDate': null,         // optional, use either this or duration
    'duration': 60 * 60     // in seconds, optional, use either this or endDate
  },
  onSuccess,
  onError
);

Still requests the Active Calories data permission. I'm guessing it has to do with the code around line 162 of HealthKit.m:

 NSSet *types = [NSSet setWithObjects:[HKWorkoutType workoutType], [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned], [HKQuantityType quantityTypeForIdentifier:quantityType], nil];
[self.healthStore requestAuthorizationToShareTypes:types readTypes:requestReadPermission ? types : nil completion:^(BOOL success, NSError *error) {

Removing the "quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned" from that list works, but I know it will need to be optionally added back when people do use that value.

Observable properties

Ideally this plugin should support observable properties, some values such as blood pressure might be subject to safety limits and should be reacted so by the observing app as soon as possible.

PhoneGap Build Version is old

Hi,

Great work on the plugin! We recently moved our app to Phonegap Build, but noticed that the latest version of your plugin on there is 0.1.0. I was wondering if you guys wouldn't mind updating it on that platform.

Thanks!

Exception with Withings blood pressure data

Hello,

it sounds weird, but i have a strange issue. I use

    window.plugins.healthkit.queryCorrelationType(
        {
            'startDate' : new Date(0), 
            'endDate'   : new Date(), 
            'correlationType': 'HKCorrelationTypeIdentifierBloodPressure', 
            'unit': 'mmHg'
        },
        function (value) {
        alert('alive')
        ...

This is working. When i add manual values or with the plugin, i can read them. But when i use a Withings blood pressure monitor with the withings app and a single value is added, then i get this exception:

2015-08-24 15:00:56.367 BloodPressureTest[225:14006] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__NSTaggedDate)'
*** First throw call stack:
(0x1861d822c 0x1976240e4 0x1861d816c 0x18714c20c 0x18714e1bc 0x18612c444 0x18611998c 0x18714ddb0 0x18714c0d4 0x18714e1bc 0x18612c444 0x18611998c 0x18714ddb0 0x18714c0d4 0x18714e0a4 0x1860ccd48 0x1860ccc2c 0x18714dfa4 0x18714c178 0x18714e1bc 0x1860c19e0 0x1860c18c0 0x18714ddb0 0x18714c0d4 0x18714e0a4 0x1860ccd48 0x1860ccc2c 0x18714dfa4 0x18714c178 0x18714e0a4 0x1860d3b94 0x1860ca4f4 0x18714dfa4 0x18714c178 0x18714bf00 0x18714cfe8 0x10006f5e4 0x10005c1b8 0x100070730 0x10004d22c 0x100258f94 0x100267a60 0x100258f94 0x10025dc28 0x18618f544 0x18618d5ec 0x1860b8f74 0x18f9bb6fc 0x18acbad94 0x100004ba8 0x197ccea08)
libc++abi.dylib: terminating with uncaught exception of type NSException

The alert is not shown. I have tried to play with the dates, but i get always the same result.

Any idea what to do?

Request Permissions not working

Hi!

I manage to check if HealthKit is available, but the request permission funtion won't fire a permission dialog on the users device. Also, when trying to add a new workout without permissions nothing happens....

Any thoughts?

This is my code:

// after checking window.plugins and window.plugins.healthkit are available, do:
if (window.plugins) {
  window.plugins.healthkit.available(
    function(isAvailable) {
      console.log('HEALTHKIT AVAILABLE, REQUESTING PERMISSIONS')
      window.plugins.healthkit.requestAuthorization(
        {
          'readTypes'  : ['HKCharacteristicTypeIdentifierDateOfBirth', 'HKQuantityTypeIdentifierActiveEnergyBurned', 'HKQuantityTypeIdentifierHeight'],
          'writeTypes' : ['HKQuantityTypeIdentifierActiveEnergyBurned', 'HKQuantityTypeIdentifierHeight', 'HKQuantityTypeIdentifierDistanceCycling']
        },
        console.log('SUCCESS'),
        console.log('ERROR')
      );
    }
  );
}

Not able to retrieve blood group type. Error is "sampleType was invalid"

Here is the code that's not working

window.plugins.healthkit.checkAuthStatus({
                    "type"  : "HKCharacteristicTypeIdentifierBloodType"
                  },
                  function(){
                    window.plugins.healthkit.querySampleType(
                      {
                        'startDate' : new Date(new Date().getTime()-2*24*60*60*1000), // two days ago
                        'endDate'   : new Date(), // now
                        'sampleType': 'HKCharacteristicTypeIdentifierBloodType'
                      },
                      function(){},
                      function(e){alert(e);}
                    );
                  }
                );

Please help. Its urgent. Thanks in advance.

Extra shim on the plugin. Causing cordova to think plugin already exists.

0     923650   error    module com.telerik.plugins.healthkit.HealthKit already defined, http://<host>/cordova.js, Line: 71
1     928421   log      deviceready has not fired after 5 seconds.
2     928424   log      Channel not fired: onCordovaReady
3     928426   log      Channel not fired: onCordovaInfoReady

This error is caused by the following line 1-2 in HealthKit.js:

cordova.define("com.telerik.plugins.healthkit.HealthKit", function(require, exports, module) { function HealthKit() {

This is added from 0.3.3 to 0.3.4. However, during the build process of Ionic (Cordova), an additional cordova.define is created, causing the plugin to be unusable.

Question: Check which permissions are enabled by user

Hi! I was wondering if it might be possible to check which permissions are actually enabled by the user via the HealthKit's permissions screen? I'm currently calling the request authorization method like:

        $cordovaHealthKit.requestAuthorization(
            permissions, // Read permission
            permissions // Write permission
        ).then(function(success) {
            // store that you have permissions
            console.log("success! " + success);
        }, function(err) {
            console.log("error! " + err);
        });

I noticed that even when the user doesn't enable any permissions on the permissions page and simply hit "done", it still enters the success callback function, and the "success" object is null. Is there a way to check if the user actually enabled permissions?

Thanks a ton!

Non-ISO Date Format

Hi,
digging into the code I found that you use these weird settings for NSDateFormatter:

            NSDateFormatter *df = [[NSDateFormatter alloc] init];
            [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

The above settings generate a date string that results in "Invalid Date" object when passed to JavaScript Date constructor (tested iPhone 5c, iOS 9.2).
I would strongly suggest to adopt ISO 8601 for better compliance with JavaScript Date object, as suggested in this post.

These settings are working:

            NSDateFormatter *df = [[NSDateFormatter alloc] init];
            NSLocale *enUSPOSIXLocale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
            [df setLocale:enUSPOSIXLocale];
            [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"];

This allows for date deserialization in JavaScript with correct time zone:

  /* do some query that yields a result with dates */
 var date = new Date(measure.dateStart); //your well formatted date object that interacts with other JS Libraries

cheers,

Vito

Add support for collection queries (HKStatisticsCollectionQuery)

HKStatisticsCollectionQuery would enable retrieving daily data for steps, calories, etc. This can be accomplished using sumQuantityType() but only for a single day. According to apple "collection queries can also receive updates when matching samples are added to or removed from the HealthKit store.

saveWorkout function issue

Your document says that distance is optional but when i comment this line then it creates exception. And also please tell me which identifier should be used for dancing, fishing etc. workout.

Thanks in advance.

queryCorrelationType causes crash for blood pressure data from iHealth

Looks like there is a problem converting the data to JSON. Note that the error does not occur when querying data from other sources, such as Omron. The iHealth data has two extra keys when viewed in the Health app: HKBeginDateKey and HKAndonDataIdKey.
image

Steps:

  1. Install the iHealth app and create an account.
  2. Create and save a test value (no device required).
  3. Verify that the measurement is exported to HealthKit (enable HealthKit in iHealth if necessary).
  4. Query for the data using the plugin.

Expected:
Data should be returned without an error.

Actual:
App crashes. See below for the exception and stack trace (from my app Twine via Crashlytics).

Fatal Exception: NSInvalidArgumentException
Invalid type in JSON write (__NSDate)

Thread : Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x00000001823c82d8 __exceptionPreprocess + 132
1  libobjc.A.dylib                0x0000000193bec0e4 objc_exception_throw + 60
2  CoreFoundation                 0x00000001823c8218 -[NSException initWithCoder:]
3  Foundation                     0x000000018333c20c _writeJSONValue + 720
4  Foundation                     0x000000018333e1bc ___writeJSONObject_block_invoke + 236
5  CoreFoundation                 0x000000018231c7a4 __65-[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 88
6  CoreFoundation                 0x0000000182309cec -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 240
7  Foundation                     0x000000018333ddb0 _writeJSONObject + 332
8  Foundation                     0x000000018333c0d4 _writeJSONValue + 408
9  Foundation                     0x000000018333e1bc ___writeJSONObject_block_invoke + 236
10 CoreFoundation                 0x00000001822b1d40 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 124
11 CoreFoundation                 0x00000001822b1c20 -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
12 Foundation                     0x000000018333ddb0 _writeJSONObject + 332
13 Foundation                     0x000000018333c0d4 _writeJSONValue + 408
14 Foundation                     0x000000018333e0a4 ___writeJSONArray_block_invoke + 136
15 CoreFoundation                 0x00000001822bd0a8 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 132
16 CoreFoundation                 0x00000001822bcf8c -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 312
17 Foundation                     0x000000018333dfa4 _writeJSONArray + 264
18 Foundation                     0x000000018333c178 _writeJSONValue + 572
19 Foundation                     0x000000018333e0a4 ___writeJSONArray_block_invoke + 136
20 CoreFoundation                 0x00000001822c3ef4 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 88
21 CoreFoundation                 0x00000001822ba854 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 300
22 Foundation                     0x000000018333dfa4 _writeJSONArray + 264
23 Foundation                     0x000000018333c178 _writeJSONValue + 572
24 Foundation                     0x000000018333bf00 -[_NSJSONWriter dataWithRootObject:options:error:] + 140
25 Foundation                     0x000000018333cfe8 +[NSJSONSerialization dataWithJSONObject:options:error:] + 380
26 Twine                          0x00000001000f5378 -[NSArray(CDVJSONSerializingPrivate) cdv_JSONString]
27 Twine                          0x00000001000e89d8 -[CDVPluginResult argumentsAsJSON]
28 Twine                          0x00000001000f5eb4 -[CDVCommandDelegateImpl sendPluginResult:callbackId:]
29 Twine                          0x00000001000d13dc __34-[HealthKit queryCorrelationType:]_block_invoke468 (HealthKit.m:805)
30 libdispatch.dylib              0x000000019423d954 _dispatch_client_callout + 16
31 libdispatch.dylib              0x000000019424b590 _dispatch_barrier_sync_f_slow_invoke + 488
32 libdispatch.dylib              0x000000019423d954 _dispatch_client_callout + 16
33 libdispatch.dylib              0x000000019424220c _dispatch_main_queue_callback_4CF + 1608
34 CoreFoundation                 0x000000018237f7f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
35 CoreFoundation                 0x000000018237d8a0 __CFRunLoopRun + 1492
36 CoreFoundation                 0x00000001822a92d4 CFRunLoopRunSpecific + 396
37 GraphicsServices               0x000000018babf6fc GSEventRunModal + 168
38 UIKit                          0x0000000186e6efac UIApplicationMain + 1488
39 Twine                          0x00000001000bfb04 main (main.m:32)
40 libdyld.dylib                  0x000000019426aa08 start + 4

.available() method succeeds on iPad ( and shouldn't ? )

Hi there,

Thanks so much for this plugin, which has saved me countless hours of frustration and helplessness.

I'm currently working on a universal app, primarily iPhone, but optimized for iPad as well. The app pulls data from HealthKit where available, and falls back to a manual entry option when it's not present (e.g. iOS 7).

While researching how to run an app with the HealthKit entitlement on a device that doesn't have HK, I came across this solution. Under the Project Info in Xcode, I removed 'healthkit' from the list of 'Required device capabilities' in the Target Properties list. Then, in the General tab > Linked Frameworks and Libraries, I set 'HealthKit.framework' to Optional instead of Required.

So, when I review 'Capabilities' > HealthKit, I see an alert prompting me to 'Add the "HealthKit" key to your info plist file'. However the app nows run on these devices.

Which brings me to my issue: testing on an iPad 2 running iOS 8.2, I noticed that the .available() method in the HealthKit plugin is succeeding, even though HealthKit isn't currently available on iPads. So, my users will see HealthKit-related buttons that attempt to execute queries against HealthKit, because the app assumes HealthKit is available. These queries fail silently in the debugger.

My current code:

        if("device" in window){

            if(window.device.platform == "iOS"){

                if(window.device.version.split(".")[0] == "8"){

                    window.plugins.healthkit.available( // succeeds where it shouldn't
                        function(isAvailable) {
                            controller.set("healthKit", true);
                        }
                    );

                }
            }
        }

I've tested this on an iPad 2 and 4th-gen iPad, both running iOS 8.2. If this isn't a bug in your code (i.e. Apple's fault), I could always filter out iPads when testing the device capabilities. However, this would mean I would need to issue a subsequent app update when Apple makes HealthKit more widely available.

Can you please advise whether this is a bug or not? If it's not, will you take any action in your codebase to pre-empt Apple's upstream bug? For example, if you ran a check like ( os-version < 8.2 && device-type == "iPad"), you could return a failure for this and previous OS versions, but leave the door open for a fix in subsequent software updates by Apple. This would future-proof your code, and would save developers from having to issue app updates once Apple issues a patch.

Interested to hear your thoughts, and thanks again!

findWorkouts returns workouts registered only with health app

Hi,
I'm not sure if i'm demanding too much, but for now it looks like findWorkouts returns only workouts
inserted manually via Health app, i cannot get any workouts tracked by e.g. Endomondo.
Should it also return workouts from third party apps integrated with iOS Health?

Also there is no calories in workout list item, isn't it possible to get this data too?

monitorSampleType in background thread

I'm experimenting with your nice Healthkit plugin and the (experimental) monitorSampleType method.
I've got things working, but encountered the following line in my logs:

THREAD WARNING: ['HealthKit'] took '62985.450195' ms. Plugin should use a background thread.

Found this thread on Stackoverflow which provides a little context:
http://stackoverflow.com/questions/20370598/thread-warnings-in-phonegap-cordova-app

I'm not an Objective-C expert, do you think that some code needs wrapping in a background job?

querySampleType only returning single day

When I query a date range for most sample types using querySampleType (eg., HKQuantityTypeIdentifierActiveEnergyBurned), the return is less than a full day of data. The exception seems to be HKQuantityTypeIdentifierStepCount, which will return up to 4-5 days of data.

I have not been able to confirm that this is an inherent limitation in HealthKit's API. Is it a glitch in this plugin?

Issue building HealthKit with latest Xcode?

Odd one, just updated to 0.3.3 using the command line tools, and the project no longer compiles, instead fails with the following linkage errors:

Ld /Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Products/Debug-iphonesimulator/KeepingWell.app/KeepingWell normal x86_64
cd /Users/gdavison/Development/NetBeansProjects/Monitor/platforms/ios
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk -L/Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Products/Debug-iphonesimulator -F/Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Products/Debug-iphonesimulator -filelist /Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Intermediates/KeepingWell.build/Debug-iphonesimulator/KeepingWell.build/Objects-normal/x86_64/KeepingWell.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Products/Debug-iphonesimulator/libCordova.a -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Intermediates/KeepingWell.build/Debug-iphonesimulator/KeepingWell.build/KeepingWell.app.xcent -framework AssetsLibrary /Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Products/Debug-iphonesimulator/libCordova.a -framework CoreGraphics -framework MobileCoreServices -framework CoreLocation -weak_framework AudioToolbox -weak_framework Social -weak_framework MessageUI -framework StoreKit -lz -liconv -framework AVFoundation -framework CoreVideo -framework QuartzCore -Xlinker -dependency_info -Xlinker /Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Intermediates/KeepingWell.build/Debug-iphonesimulator/KeepingWell.build/Objects-normal/x86_64/KeepingWell_dependency_info.dat -o /Users/gdavison/Library/Developer/Xcode/DerivedData/KeepingWell-aodgojqbwmyfysckkigmmvwotzpc/Build/Products/Debug-iphonesimulator/KeepingWell.app/KeepingWell

Undefined symbols for architecture x86_64:
"_HKSampleSortIdentifierEndDate", referenced from:
-[HKHealthStore(AAPLExtensions) aapl_mostRecentQuantitySampleOfType:predicate:completion:] in HKHealthStore+AAPLExtensions.o
"OBJC_CLASS$HKHealthStore", referenced from:
l_OBJC
$CATEGORY_HKHealthStore$_AAPLExtensions in HKHealthStore+AAPLExtensions.o
"OBJC_CLASS$_HKSampleQuery", referenced from:
objc-class-ref in HKHealthStore+AAPLExtensions.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is this an error anybody else has come accross?

Include source and metadata with querySampleType results

Each result should include the UUID, source, metadata, sourceBundleIdentifier, and creationDate. HealthKit includes all of this data but it is being omitted by the plugin.

HKObject    HKObject        
    NSObject    NSObject        
    _UUID   __NSConcreteUUID *  0x7fbaf2e92920  0x00007fbaf2e92920
    _source HKSource *  0x7fbaf2e5df30  0x00007fbaf2e5df30
        NSObject    NSObject        
        _name   __NSCFString *  @"Health"   0x00007fbaf2e8c0b0
        _bundleIdentifier   __NSCFString *  @"com.apple.Health" 0x00007fbaf2e78430
        _localDevice    bool    false   false
        _productType    NSString *  nil 0x0000000000000000
        _options    unsigned long long  3   3
    _metadata   __NSDictionaryI *   1 key/value pair    0x00007fbaf2e4b630
        [0] (null)  @"HKWasUserEntered" : (double)1 
            key __NSCFString *  @"HKWasUserEntered" 0x00007fbaf2e73460
            value   __NSCFNumber *  (double)1   0x00007fbaf2e6ece0
    _sourceBundleIdentifier NSString *  nil 0x0000000000000000
    _creationDate   __NSDate *  2015-04-22 12:48:18 UTC 0x00007fbaf2e48b00

querySampleType does not work with retrieving BAC

Hi, I am not getting a proper value back with HKQuantityTypeIdentifierBloodAlcoholContent. Although it isn't explicit, the Healthkit docs seem to indicate the unit should be 'percent'. However, that argument, along with other dummy arguments don't seem to be accepted. However, 'count' is accepted but in my success callback I am not getting a value but an empty array. Is this a bug? Anyone else have this issue? The example given with stepcount works fine for me.

Here is HKTypeIdentifiers.h for your reference.

Best place to ask questions + getting data points?

What is the best place to ask general questions about this plugin? I don't want to clutter up the issue box, but I haven't found a good alternative space to ask questions.

(My actual question: ) I've been using the plugin to get my steps for a whole day, but I would like to get the actual step data points to produce my own graph. Currently, I'm using something like this:

window.plugins.healthkit.sumQuantityType({
  'startDate': startDate,
  'endDate': endDate,
  'sampleType': 'HKQuantityTypeIdentifierStepCount'
}

My startDate and endDate are defined by moment. This utilizes sumQuantityType, so it only return the sum. How can I get the individual points?

I've been following this tutorial: http://kingsfleet.blogspot.co.uk/2015/02/how-long-did-i-sleep-last-night-using.html

HKQuantityTypeIdentifierDietaryEnergyConsumed unit issue

Hello,
I am using this function to save consume calorie in health kit

window.plugins.healthkit.saveQuantitySample(
{
'startDate': new Date(), // now
'endDate': new Date(), // now
'sampleType': HKQuantityTypeIdentifierDietaryEnergyConsumed,
'unit': unit,
'amount': qty
},
onSuccess,
onError
);

When i am passing unit "kcal" and qty 56, then on health kit calorie is 56

But when i am passing unit "cal" and qty 56, then on health kit calorie is 0.056 (wrong)

And default unit in health kit is cal

Can you explain me what is wrong with this. this is health kit issue or plugin issue or my code issue.

Workout Duration in Milliseconds?

Hey Eddy,

iOS 8.2 added the ability to actually view workout activities as "Trainings" in hours/minutes rather than just the Active Calories burned.

I believe that the demo mentioned that the duration for saveWorkout and then in line 121 of HealthKit.m it calculates the duration when an endDate is not given. Could you confirm that this is adding it to a millisecond date value?

If so, I think the only real thing that needs to be done would be to update the demo index.html to say milliseconds instead of seconds next to duration.

Does this sound about right? We only noticed because a user said their 5 minute workout showed up as 8 seconds.

HealthKit Permissions should be asked for up-front

In the 2014 WWDC presentation on HealthKit they say that an app should ask for all permissions they might want up front. This makes it easier for users to be able to understand what the app is asking for.

For example an app might need weight, height, pulse and blood pressure. In the current API design it appears to request each property singly. This might stop app being approved in the app store.

Does the Telerik HealthKit plugin support the reproductive health data?

Hi!

I would like to use this plugin for our app that analyzes women's reproductive health data to determine the fertility. However, I do not manage to read or write any of the reproductive health data, such as:

HKQuantityTypeIdentifierBasalBodyTemperature
or
HKCategoryTypeIdentifierMenstrualFlow

For the temperature I cannot get the unit right and for the menstrual flow it complains about the type. So I wonder if the reproductive health part of Health kit is supported at all in this plugin? In that case, how do I for instance specify the units for basal body temperature?

Thank you,
Elina

Better Documentation

Currently docs just explain here are some bunch of function that you can use.

Can you provide a better documentation explaining the functions and their parameters.

querySampleType requiring write permissions

Here is my prompt for permission code

window.plugins.healthkit.requestAuthorization({ 'readTypes' : ['HKQuantityTypeIdentifierStepCount','HKQuantityTypeIdentifierActiveEnergyBurned' ]}, auth_callback, auth_callback);

And my query code:

window.plugins.healthkit.querySampleType({'startDate': start, 'endDate': finish, 'sampleType': 'HKQuantityTypeIdentifierStepCount'}

The authorisation dialogue appears with 2 toggles as expected initially, however the query code forces the authorisation dialogue again, with the 2 toggles maintaining their "on" stage, but also displays a prompt for write permission for the Identifier being requested (HKQuantityTypeIdentifierStepCount). I do not need write permission and do not explicitly request it in my code. The code I've shown is all the code my application contains that relates to this plugin.

Am I missing something obvious or is this unexpected behaviour?

Excited

Excited about this. Any timeline on when you're planning to release it, if you're planning it at all? Cheers,

Healthkit retain cycle error

I have an app and i'm trying to use HealthKit plugin. Everything works fine (on my device) but i'm unabled to upload it to app store since it gives me an error on
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];

The error:
Capturing 'self' strongly in this block is likely to lead to a retain cycle

Do you have any idea how can i resolve this?

Thanks a lot
Martim Dornellas

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.