Handles HealthKit requests from Unity.
|
HKHealthStore * | healthStore |
| The HKHealthStore object.
|
|
NSString * | controllerName |
| name of the GameObject to send messages to
|
|
BEPedometer * | pedometer |
| The BEPedometer object.
|
|
NSDictionary * | longRunningQueries |
| keeps track of long-running queries
|
|
|
(instancetype) | + sharedHealthKit |
| returns the shared BEHealthKit object
|
|
◆ addLongRunningQuery:forType:
- (void) addLongRunningQuery: |
|
(HKQuery *) | query |
forType: |
|
(HKSampleType *) | sampleType |
This is used by the plugin to keep track of observer queries.
- Parameters
-
query | The query in question. |
sampleType | The sample type the query is for. |
◆ authorizationStatusForType:
- (int) authorizationStatusForType: |
|
(NSString *) | dataTypeString |
|
- Parameters
-
dataTypeString | HealthKit datatype identifiers to query. |
◆ authorizeHealthKitToRead:write:completion:
- (void) authorizeHealthKitToRead: |
|
(NSArray *) | readIdentifiers |
write: |
|
(NSArray *) | writeIdentifiers |
completion: |
|
(void(^)(bool success, NSError *error)) | completion |
Wrapper around the HealthKit -requestAuthorizationToShareTypes:readTypes:completion method.
- Parameters
-
readIdentifiers | array of HealthKit datatype identifiers to read. |
writeIdentifiers | array of HealthKit datatype identifiers to write. |
completion | called after the user responds to the request. If success is false, error contain information about what went wrong, otherwise it will be set to nil. |
◆ beginBackgroundObserverQuery:
- (void) beginBackgroundObserverQuery: |
|
(HKQuantityTypeIdentifier) | identifierString |
|
◆ defaultUnitForSampleType:
- (HKUnit *) defaultUnitForSampleType: |
|
(HKSampleType *) | sampleType |
|
I try to be somewhat intelligent about this (temperature, for example, will be returned in the device's locale, so you don't need to worry about converting it before displaying to the user. That said, if you want to change some of these defaults this is the place to do it. Will return nil if there is no default unit, but this shouldn't happen.
- Parameters
-
sampleType | The sample type in question. Can be any sample type supported by HealthKit. |
◆ errorOccurred:
- (void) errorOccurred: |
|
(NSError *) | error |
|
Converts the error to XML (See NSError+XML.h), and calls ErrorOccurred() on the HealthStore GameObject.
- Parameters
-
◆ readCharacteristic:resultsHandler:
- (void) readCharacteristic: |
|
(HKCharacteristicType *) | characteristic |
resultsHandler: |
|
(void(^)(id result, NSError *error)) | resultsHandler |
Characteristics are things that don't change over time, like blood type or birth date.
- Parameters
-
characteristic | The characteristic to read. |
resultsHandler | Called when the query finishes executing. If unsuccessful, error contains information about what went wrong, otherwise it will be set to nil. |
Provided by category BEHealthKit(read).
◆ readDocumentOfType:predicate:limit:sortDescriptors:includeDocumentData:resultsHandler:
- (void) readDocumentOfType: |
|
(HKDocumentType *) | documentType |
predicate: |
|
(NSPredicate *) | predicate |
limit: |
|
(NSUInteger) | limit |
sortDescriptors: |
|
(NSArray<NSSortDescriptor *> *) | sortDescriptors |
includeDocumentData: |
|
(BOOL) | includeDocumentData |
resultsHandler: |
|
(void(^)(id result, BOOL done, NSError *error)) | resultsHandler |
A query that returns a snapshot of all matching documents currently saved in the HealthKit store. See HKDocumentQuery.
- Parameters
-
documentType | Currently, only HKDocumentTypeIdentifierCDA is supported. |
predicate | a predicate that limits the results of the query |
limit | the maximum number of documents to return |
sortDescriptors | an array of sort decsriptors |
includeDocumentData | send true to include all document data. send false to just return a summary. |
resultsHandler | Called when the query finishes executing. If unsuccessful, error contains information about what went wrong, otherwise it will be set to nil. |
Provided by category BEHealthKit(read).
◆ readHealthRecords:resultsHandler:
- (void) readHealthRecords: |
|
(HKSampleType *) | sampleType |
resultsHandler: |
|
(void(^)(id result, NSError *error)) | resultsHandler |
A streamlined method to perform sample queries on clinical types.
- Parameters
-
sampleType | the type of sample to read. |
resultsHandler | Called when the query finishes executing. If unsuccessful, error contains information about what went wrong, otherwise it will be set to nil. |
Provided by category BEHealthKit(clinicalRecords).
◆ readSamples:fromDate:toDate:resultsHandler:
- (void) readSamples: |
|
(HKSampleType *) | sampleType |
fromDate: |
|
(NSDate *) | startDate |
toDate: |
|
(NSDate *) | endDate |
resultsHandler: |
|
(void(^)(NSArray *results, NSError *error)) | resultsHandler |
Executes a query with -initWithSampleType:predicate:limit:sortDescriptors:resultsHandler:. Limit will be set to no limit, and they will be sorted by startDate, in ascending order.
- Parameters
-
sampleType | the type of sample to read. |
startDate | the starting limit for the query. |
endDate | the end date. |
resultsHandler | Called when the query finishes executing. If unsuccessful, error contains information about what went wrong, otherwise it will be set to nil. |
Provided by category BEHealthKit(read).
◆ readSamplesForWorkoutActivity:fromDate:toDate:resultsHandler:
- (void) readSamplesForWorkoutActivity: |
|
(HKWorkoutActivityType) | activity |
fromDate: |
|
(NSDate *) | startDate |
toDate: |
|
(NSDate *) | endDate |
resultsHandler: |
|
(void(^)(NSArray *results, NSError *error)) | resultsHandler |
...
- Parameters
-
activity | The activity type to read. See HKWorkoutActivityType documentation |
startDate | the starting limit for the query. |
endDate | the end date. |
resultsHandler | Called when the query finishes executing. If unsuccessful, error contains information about what went wrong, otherwise it will be set to nil. |
Provided by category BEHealthKit(read).
◆ readStatisticsCollectionForQuantityType:predicate:options:anchorDate:intervalComponents:resultsHandler:
- (void) readStatisticsCollectionForQuantityType: |
|
(HKQuantityType *) | quantityType |
predicate: |
|
(NSPredicate *) | predicate |
options: |
|
(HKStatisticsOptions) | options |
anchorDate: |
|
(NSDate *) | anchorDate |
intervalComponents: |
|
(NSDateComponents *) | interval |
resultsHandler: |
|
(void(^)(id result, NSError *error)) | resultsHandler |
A query that performs multiple statistics queries over a series of fixed-length time intervals, and returns the results. See HKStatisticsCollectionQuery
- Parameters
-
quantityType | the type of sample to read. |
predicate | a predicate that limits the results of the query |
options | a single option that defines the type of calculation to be performed on the data |
anchorDate | the anchor date for the collection's time intervals |
interval | the date components that determine the time interval for each statistic in this collection |
resultsHandler | Called when the query finishes executing. If unsuccessful, error contains information about what went wrong, otherwise it will be set to nil. |
Provided by category BEHealthKit(read).
◆ readStatisticsForQuantityType:predicate:options:resultsHandler:
- (void) readStatisticsForQuantityType: |
|
(HKQuantityType *) | quantityType |
predicate: |
|
(NSPredicate *) | predicate |
options: |
|
(HKStatisticsOptions) | options |
resultsHandler: |
|
(void(^)(id result, NSError *error)) | resultsHandler |
A query that performs statistical calculations over a set of matching quantity samples, and returns the results. See HKStatisticsQuery.
- Parameters
-
quantityType | the type of sample to read. |
predicate | a predicate that limits the results of the query |
options | a single option that defines the type of calculation to be performed on the data |
resultsHandler | Called when the query finishes executing. If unsuccessful, error contains information about what went wrong, otherwise it will be set to nil. |
Provided by category BEHealthKit(read).