[AC-6465] Hyperloop - HealthKit requestAuthorizationToShareTypes is not a function
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop, Titanium SDK & CLI |
Labels | ios |
Reporter | Petr Malakhaltsev |
Assignee | Shak Hossain |
Created | 2020-01-01T21:36:07.000+0000 |
Updated | 2020-01-29T20:24:31.000+0000 |
Description
I'm trying to authorize HealthKit via Hyperloop to query height of the user, so I run the following code:
import {
HKHealthStore,
} from 'HealthKit';
if (HKHealthStore.isHealthDataAvailable()) {
Ti.API.log('available');
} else {
Ti.API.log('not available');
}
let hk = new HKHealthStore();
hk.requestAuthorizationToShareTypes([], [], function() {});
It does show "available" message, so I assume that heath data is available, but then it throughs an error "hk.requestAuthorizationToShareTypes is not a function", I've tried "swift-like" function "requestAuthorization" as well, but same result.
p.s. Is there any way to get available functions from Hyperloop?
I guess you are trying to use [requestAuthorizationToShareTypes:readTypes:completion:](https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorizationtosharetypes?language=objc). According to the conventions for [method names](https://docs.appcelerator.com/platform/latest/#!/guide/iOS_Hyperloop_Programming_Guide-section-src-46253491_iOSHyperloopProgrammingGuide-Namedmethods), this is the Hyperloop equivalent:
Yes, that's true. It was my mistake that I missed this part of the iOS Hyperloop Programming Guide. But now, after I follow your suggestion it doesn't seem to do anything. No error, no authorization popup.
[~pmalakhaltsev] have you configured the correct plist keys? Like NSHealthShareUsageDescription and NSHealthUpdateUsageDescription?
Yes, I have both keys in tiapp.xml
Also I have "entitlements" section:
Besides this I've tried to clean the project and rebuild it. Doesn't help.
[~pmalakhaltsev] perhaps you have the same issue as [this guy?](https://stackoverflow.com/questions/26010554/requestauthorizationtosharetypes-method-not-displaying-permissions-prompt-in-ios)
@topener, that's unlikely as: 1. I pass not a string but (hopefully) quanityType
2. I initialize healthStore as an object (according to Hyperloop guide):
So I can't spot any visible mistake in the code ..