我正在按照official manual的说明设置HealthKit以读取用户的健康记录。我启用了它,并通过了所有三个步骤来使其起作用,但是以某种方式禁用了“运行状况记录”功能,因此我无法对其进行检查。结果,该应用崩溃,因为它无法验证对健康记录的请求。
如何启用它?
具有iOS 12 SDK的Xcode版本10.0 beta 6(10L232m)。
还有一个授权文件:
帐户设置:
我的代码:
RCT_EXPORT_METHOD(requestAccess:(RCTResponseSenderBlock)callback) {
NSNull * null = [NSNull null];
NSSet * recordTypes = [self recordTypes];
HKHealthStore *store = [HKHealthStore new];
[store requestAuthorizationToShareTypes:nil
readTypes:recordTypes
completion:^void (BOOL success, NSError * _Nullable error) {
if (success) {
callback(@[null, @true]);
崩溃报告
Exception 'Authorization to read the following types is disallowed: HKClinicalTypeIdentifierMedicationRecord' was thrown while invoking requestAccess on target AppHealthRecords with params (
259
)
callstack: (
0 CoreFoundation 0x000000010709429b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000105777735 objc_exception_throw + 48
2 CoreFoundation 0x00000001070940f5 +[NSException raise:format:] + 197
3 HealthKit 0x0000000104dc7ec0 -[HKHealthStore _throwIfAuthorizationDisallowedForSharing:types:] + 540
4 HealthKit 0x0000000104dc6912 -[HKHealthStore _validateAuthorizationRequestWithShareTypes:readTypes:] + 224
5 HealthKit 0x0000000104dc6a82 -[HKHealthStore requestAuthorizationToShareTypes:readTypes:shouldPrompt:completion:] + 321
6 HealthKit 0x0000000104dc680f -[HKHealthStore requestAuthorizationToShareTypes:readTypes:completion:] + 77
7 app 0x0000000104574c43 -[AppHealthRecords requestAccess:] + 307
8 CoreFoundation 0x000000010709b11c __invoking___ + 140
9 CoreFoundation 0x00000001070985b5 -[NSInvocation invoke] + 325
10 CoreFoundation 0x0000000107098a06 -[NSInvocation invokeWithTarget:] + 54
11 app 0x000000010461ec6a -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2810
12 app 0x00000001046d5dd6 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 790
13 app 0x00000001046d58ef _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
14 app 0x00000001046d5869 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
15 libdispatch.dylib 0x00000001099c251d _dispatch_call_block_and_release + 12
16 libdispatch.dylib 0x00000001099c3587 _dispatch_client_callout + 8
17 libdispatch.dylib 0x00000001099ca058 _dispatch_lane_serial_drain + 720
18 libdispatch.dylib 0x00000001099cab9b _dispatch_lane_invoke + 401
19 libdispatch.dylib 0x00000001099d39c6 _dispatch_workloop_worker_thread + 645
20 libsystem_pthread.dylib 0x0000000109d48fd2 _pthread_wqthread + 980
21 libsystem_pthread.dylib 0x0000000109d48be9 start_wqthread + 13
)