[AC-5579] HKHealthStore requestAuthorizationToShareTypes is not a function
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Resolved |
| Resolution | Not Our Bug |
| Resolution Date | 2018-02-07T15:05:08.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Hyperloop |
| Labels | n/a |
| Reporter | Yanko Valera |
| Assignee | Shak Hossain |
| Created | 2018-02-07T13:39:18.000+0000 |
| Updated | 2018-02-07T15:05:48.000+0000 |
Description
While trying to get permissions from HealthKit, the HKHealthStore instance is not allowing me to call the requestAuthorizationToShareTypes function. Code below
var HKHealthStore = require('HealthKit/HKHealthStore');
var HKObjectType = require('HealthKit/HKObjectType');
var HKCategoryTypeIdentifierSleepAnalysis = require("HealthKit").HKCategoryTypeIdentifierSleepAnalysis;
var NSSet = require('Foundation/NSSet');
exports.start = function() {
if (HKHealthStore.isHealthDataAvailable()) {
var healthStore = HKHealthStore.alloc().init();
var shareTypes = NSSet.set();
var readTypes = NSSet.setWithObject(HKObjectType.categoryTypeForIdentifier(HKCategoryTypeIdentifierSleepAnalysis));
healthStore.requestAuthorizationToShareTypes(shareTypes, readTypes, function(success, error) {
});
}
}
Hey there! Sorry, but this is not valid. Regarding the [docs](https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorizationtosharetypes), the correct call is
Basically, you just need to ensure that all arguments are concatenated and it will match it.var healthStore = new HKHealthStore(); // Same as alloc().init(); healthStore.requestAuthorizationToShareTypesReadTypesCompletion(shareTypes, readTypes, function(success, error)) { // Handle result });