苹果健康接入

苹果健康方案调研

1、说明

苹果健康属于apple 系统级应用,直接调用iOS Api去获取数据,上传数据,不支持云云对接,只能通过Api获取数据,获取之前需要先用户授权
请添加图片描述

2、数据项

可以获取到的数据项为
请添加图片描述

步数、步行 +跑步距离、呼吸速率、活壁动能量、静息能量、静息心率、骑车距离、身高、身高体重指数、睡眠分析、体能训练、体能训练途径、体脂率、体重、心率、血氧饱和度、腰围、最大摄氧量、

3、接入方式

1、修改证书,添加HealthKit权限。
2、选中项目TARGETS,然后点击+Capability,搜索添加HealthKit
3、调用实现如下:

// .h文件
#import <Foundation/Foundation.h>
#import <HealthKit/HealthKit.h>
#import <UIKit/UIDevice.h>

NS_ASSUME_NONNULL_BEGIN

@interface HealthKitManager : NSObject

@property (nonatomic, strong) HKHealthStore *healthStore;

+ (id)shareInstance;

- (void)authorizeHealthKit:(void(^)(BOOL success, NSError *error))compltion;

- (void)getStepCount:(void(^)(double value, NSError *error))completion;

- (void)getDistance:(void(^)(double value, NSError *error))completion;


@end

NS_ASSUME_NONNULL_END


// .m文件
#import "HealthKitManager.h"

#define CustomHealthErrorDomain @"com.wangsk.healthError"

@implementation HealthKitManager
+ (id)shareInstance{
    static id manager ;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[[self class] alloc] init];
    });
    return manager;
}

/*
 *  @brief  检查是否支持获取健康数据
 */
- (void)authorizeHealthKit:(void(^)(BOOL success, NSError *error))compltion{
    if([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0){
        if (![HKHealthStore isHealthDataAvailable]) {
            NSError *error = [NSError errorWithDomain: @"com.raywenderlich.tutorials.healthkit" code: 2 userInfo: [NSDictionary dictionaryWithObject:@"HealthKit is not available in th is Device"                                                                      forKey:NSLocalizedDescriptionKey]];
            if (compltion != nil) {
                compltion(false, error);
            }
            return;
        }
        if ([HKHealthStore isHealthDataAvailable]) {
            if(self.healthStore == nil){
                self.healthStore = [[HKHealthStore alloc] init];
            }
            /*
             组装需要读写的数据类型
             */
//            NSSet *writeDataTypes = [self dataTypesToWrite];
            NSSet *readDataTypes = [self dataTypesRead];
            
            /*
             注册需要读写的数据类型,也可以在“健康”APP中重新修改
             */
            [self.healthStore requestAuthorizationToShareTypes:nil readTypes:readDataTypes completion:^(BOOL success, NSError *error) {
                
                if (compltion != nil) {
                    NSLog(@"error->%@", error.localizedDescription);
                    compltion (success, error);
                }
            }];
        }

    }else {
        NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"iOS 系统低于8.0"                                                                      forKey:NSLocalizedDescriptionKey];
        NSError *aError = [NSError errorWithDomain:CustomHealthErrorDomain code:0 userInfo:userInfo];
        compltion(0,aError);
    }
}

/*!
 *  @brief  写权限
 *  @return 集合
 */
- (NSSet *)dataTypesToWrite{
    HKQuantityType *heightType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
    HKQuantityType *weightType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
    HKQuantityType *temperatureType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyTemperature];
    HKQuantityType *activeEnergyType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned];
    
    return [NSSet setWithObjects:heightType, temperatureType, weightType,activeEnergyType,nil];
}

/*!
 *  @brief  读权限
 *  @return 集合
 */
- (NSSet *)dataTypesRead{
//    HKQuantityType *heightType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
//    HKQuantityType *weightType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
//    HKQuantityType *temperatureType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyTemperature];
//    HKCharacteristicType *birthdayType = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth];
//    HKCharacteristicType *sexType = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierBiologicalSex];
//    HKQuantityType *stepCountType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
//    HKQuantityType *distance = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
//    HKQuantityType *activeEnergyType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned];
//
//    return [NSSet setWithObjects:heightType, temperatureType,birthdayType,sexType,weightType,stepCountType, distance, activeEnergyType,nil];
    
    
    HKQuantityType *stepCountType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
    HKQuantityType *distance = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
    return [NSSet setWithObjects:stepCountType,distance,nil];
    
}

//获取步数
- (void)getStepCount:(void(^)(double value, NSError *error))completion{
    HKQuantityType *stepType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
    NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];
    
    // Since we are interested in retrieving the user's latest sample, we sort the samples in descending order, and set the limit to 1. We are not filtering the data, and so the predicate is set to nil.
    HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:stepType predicate:[HealthKitManager predicateForSamplesToday] limit:HKObjectQueryNoLimit sortDescriptors:@[timeSortDescriptor] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
        if(error){
            completion(0,error);
        }else{
            NSInteger totleSteps = 0;
            for(HKQuantitySample *quantitySample in results){
                HKQuantity *quantity = quantitySample.quantity;
                HKUnit *heightUnit = [HKUnit countUnit];
                double usersHeight = [quantity doubleValueForUnit:heightUnit];
                totleSteps += usersHeight;
            }
            NSLog(@"当天行走步数 = %ld",(long)totleSteps);
            completion(totleSteps,error);
        }
    }];
    
    [self.healthStore executeQuery:query];
}

//获取公里数
- (void)getDistance:(void(^)(double value, NSError *error))completion{
    HKQuantityType *distanceType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
    NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];
    HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:distanceType predicate:[HealthKitManager predicateForSamplesToday] limit:HKObjectQueryNoLimit sortDescriptors:@[timeSortDescriptor] resultsHandler:^(HKSampleQuery * _Nonnull query, NSArray<__kindof HKSample *> * _Nullable results, NSError * _Nullable error) {
        
        if(error){
            completion(0,error);
        }
        else{
            double totleSteps = 0;
            for(HKQuantitySample *quantitySample in results){
                HKQuantity *quantity = quantitySample.quantity;
                HKUnit *distanceUnit = [HKUnit meterUnitWithMetricPrefix:HKMetricPrefixKilo];
                double usersHeight = [quantity doubleValueForUnit:distanceUnit];
                totleSteps += usersHeight;
            }
            NSLog(@"当天行走距离 = %.2f",totleSteps);
            completion(totleSteps,error);
        }
    }];
    [self.healthStore executeQuery:query];
}

/*!
 *  @brief  当天时间段
 *
 *  @return 时间段
 */
+ (NSPredicate *)predicateForSamplesToday {
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDate *now = [NSDate date];
    NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now];
    [components setHour:0];
    [components setMinute:0];
    [components setSecond: 0];
    
    NSDate *startDate = [calendar dateFromComponents:components];
    NSDate *endDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:1 toDate:startDate options:0];
    NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate endDate:endDate options:HKQueryOptionNone];
    return predicate;
}
@end

4、API



HKQuantityTypeIdentifierAppleSleepingWristTemperature: 苹果睡眠时手腕温度(摄氏度, 离散型算术)
HKQuantityTypeIdentifierBodyFatPercentage: 体脂百分比(百分比, 离散型算术)
HKQuantityTypeIdentifierBodyMass: 体重(千克, 离散型算术)
HKQuantityTypeIdentifierBodyMassIndex: 体重指数(计数, 离散型算术)
HKQuantityTypeIdentifierElectrodermalActivity: 皮肤电活动(单位S, 离散型算术)
HKQuantityTypeIdentifierHeight: 身高(米, 离散型算术)
HKQuantityTypeIdentifierLeanBodyMass: 瘦体重(千克, 离散型算术)
HKQuantityTypeIdentifierWaistCircumference: 腰围(米, 离散型算术)



// Fitness 
以下是苹果 HealthKit 框架中的一系列 `HKQuantityTypeIdentifier` 及其对应的中文翻译和描述:

1. `HKQuantityTypeIdentifierActiveEnergyBurned`:
   - **中文**: 活跃能量消耗
   - **单位**: 千卡路里(kcal)
   - **类型**: 累积型(Cumulative)

2. `HKQuantityTypeIdentifierAppleExerciseTime`:
   - **中文**: 苹果锻炼时间
   - **单位**: 分钟(min)
   - **类型**: 累积型(Cumulative)

3. `HKQuantityTypeIdentifierAppleMoveTime`:
   - **中文**: 苹果活动时间
   - **单位**: 分钟(min)
   - **类型**: 累积型(Cumulative)

4. `HKQuantityTypeIdentifierAppleStandTime`:
   - **中文**: 苹果站立时间
   - **单位**: 分钟(min)
   - **类型**: 累积型(Cumulative)

5. `HKQuantityTypeIdentifierBasalEnergyBurned`:
   - **中文**: 基础能量消耗
   - **单位**: 千卡路里(kcal)
   - **类型**: 累积型(Cumulative)

6. `HKQuantityTypeIdentifierCyclingCadence`:
   - **中文**: 骑行踏频
   - **单位**: 次/分钟(count/min)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

7. `HKQuantityTypeIdentifierCyclingFunctionalThresholdPower`:
   - **中文**: 骑行功能性阈值功率
   - **单位**: 瓦特(W)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

8. `HKQuantityTypeIdentifierCyclingPower`:
   - **中文**: 骑行功率
   - **单位**: 瓦特(W)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

9. `HKQuantityTypeIdentifierCyclingSpeed`:
   - **中文**: 骑行速度
   - **单位**: 米/秒(m/s)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

10. `HKQuantityTypeIdentifierDistanceCycling`:
    - **中文**: 骑行距离
    - **单位**: 米(m)
    - **类型**: 累积型(Cumulative)

11. `HKQuantityTypeIdentifierDistanceDownhillSnowSports`:
    - **中文**: 下坡滑雪运动距离
    - **单位**: 米(m)
    - **类型**: 累积型(Cumulative)

12. `HKQuantityTypeIdentifierDistanceSwimming`:
    - **中文**: 游泳距离
    - **单位**: 米(m)
    - **类型**: 累积型(Cumulative)

13. `HKQuantityTypeIdentifierDistanceWalkingRunning`:
    - **中文**: 步行或跑步距离
    - **单位**: 米(m)
    - **类型**: 累积型(Cumulative)

14. `HKQuantityTypeIdentifierDistanceWheelchair`:
    - **中文**: 轮椅使用距离
    - **单位**: 米(m)
    - **类型**: 累积型(Cumulative)

15. `HKQuantityTypeIdentifierFlightsClimbed`:
    - **中文**: 爬楼梯数
    - **单位**: 计数(count)
    - **类型**: 累积型(Cumulative)

16. `HKQuantityTypeIdentifierNikeFuel`:
    - **中文**: NikeFuel(耐克能量)
    - **单位**: 计数(count)
    - **类型**: 累积型(Cumulative)

17. `HKQuantityTypeIdentifierPhysicalEffort`:
    - **中文**: 身体努力
    - **单位**: 千卡路里/(公斤*小时)(kcal/(kg*hr))
    - **类型**: 离散型(Discrete),算术(Arithmetic)

18. `HKQuantityTypeIdentifierPushCount`:
    - **中文**: 推动次数(如轮椅推动)
    - **单位**: 计数(count)
    - **类型**: 累积型(Cumulative)

19. `HKQuantityTypeIdentifierRunningPower`:
    - **中文**: 跑步功率
    - **单位**: 瓦特(W)
    - **类型**: 离散型(Discrete),算术(Arithmetic)

20. `HKQuantityTypeIdentifierRunningSpeed`:
    - **中文**: 跑步速度
    - **单位**: 米/秒(m/s)
    - **类型**: 离散型(Discrete),算术(Arithmetic)

21. `HKQuantityTypeIdentifierStepCount`:
    - **中文**: 步数
    - **单位**: 计数(count)
    - **类型**: 累积型(Cumulative)

22. `HKQuantityTypeIdentifierSwimmingStrokeCount`:
    - **中文**: 游泳划水次数
    - **单位**: 计数(count)
    - **类型**: 累积型(Cumulative)

23. `HKQuantityTypeIdentifierUnderwaterDepth`:
    - **中文**: 水下深度
    - **单位**: 米(m)
    - **类型**: 离散型(Discrete),算术(Arithmetic)

这些标识符使开发者能够在应用程序中追踪和分析用户的活动和锻炼数据,帮助用户更好地了解自己的健康状况和锻炼效果。

以下是苹果 HealthKit 框架中定义的与听力健康和心脏健康相关的 `HKQuantityTypeIdentifier` 标识符的中文翻译和描述:

### 听力健康 (Hearing Health)

1. `HKQuantityTypeIdentifierEnvironmentalAudioExposure`:
   - **中文**: 环境音频暴露
   - **单位**: 分贝等效连续声压级(dBASPL)
   - **类型**: 离散型(Discrete),等效连续水平(Equivalent Continuous Level)

2. `HKQuantityTypeIdentifierEnvironmentalSoundReduction`:
   - **中文**: 环境声音降低
   - **单位**: 分贝等效连续声压级(dBASPL)
   - **类型**: 离散型(Discrete),等效连续水平(Equivalent Continuous Level)

3. `HKQuantityTypeIdentifierHeadphoneAudioExposure`:
   - **中文**: 耳机音频暴露
   - **单位**: 分贝等效连续声压级(dBASPL)
   - **类型**: 离散型(Discrete),等效连续水平(Equivalent Continuous Level)

### 心脏 (Heart)

4. `HKQuantityTypeIdentifierAtrialFibrillationBurden`:
   - **中文**: 房颤负担
   - **单位**: 百分比(%)
   - **类型**: 离散型(Discrete),时间加权(Temporally Weighted)

5. `HKQuantityTypeIdentifierHeartRate`:
   - **中文**: 心率
   - **单位**: 次/秒(count/s)
   - **类型**: 离散型(Discrete),时间加权(Temporally Weighted)

6. `HKQuantityTypeIdentifierHeartRateRecoveryOneMinute`:
   - **中文**: 一分钟内心率恢复
   - **单位**: 次/分钟(count/min)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

7. `HKQuantityTypeIdentifierHeartRateVariabilitySDNN`:
   - **中文**: 心率变异性(SDNN)
   - **单位**: 毫秒(ms)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

8. `HKQuantityTypeIdentifierPeripheralPerfusionIndex`:
   - **中文**: 周围灌注指数
   - **单位**: 百分比(%)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

9. `HKQuantityTypeIdentifierRestingHeartRate`:
   - **中文**: 静息心率
   - **单位**: 次/分钟(count/min)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

10. `HKQuantityTypeIdentifierVO2Max`:
    - **中文**: 最大摄氧量
    - **单位**: 毫升/(公斤*分钟)(ml/(kg*min))
    - **类型**: 离散型(Discrete),算术(Arithmetic)

11. `HKQuantityTypeIdentifierWalkingHeartRateAverage`:
    - **中文**: 平均步行心率
    - **单位**: 次/分钟(count/min)
    - **类型**: 离散型(Discrete),算术(Arithmetic)

这些标识符允许开发者在应用程序中追踪和分析用户的听力健康和心脏健康数据,帮助用户更好地了解自己的健康状况和锻炼效果。

// Mobility
以下是苹果 HealthKit 框架中定义的与移动性(Mobility)相关的 `HKQuantityTypeIdentifier` 标识符的中文翻译和描述:

1. `HKQuantityTypeIdentifierAppleWalkingSteadiness`:
   - **中文**: 苹果步行稳定性
   - **单位**: 百分比(%)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

2. `HKQuantityTypeIdentifierRunningGroundContactTime`:
   - **中文**: 跑步触地时间
   - **单位**: 毫秒(ms)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

3. `HKQuantityTypeIdentifierRunningStrideLength`:
   - **中文**: 跑步步长
   - **单位**: 米(m)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

4. `HKQuantityTypeIdentifierRunningVerticalOscillation`:
   - **中文**: 跑步垂直振幅
   - **单位**: 厘米(cm)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

5. `HKQuantityTypeIdentifierSixMinuteWalkTestDistance`:
   - **中文**: 六分钟步行测试距离
   - **单位**: 米(m)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

6. `HKQuantityTypeIdentifierStairAscentSpeed`:
   - **中文**: 上楼梯速度
   - **单位**: 米/秒(m/s)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

7. `HKQuantityTypeIdentifierStairDescentSpeed`:
   - **中文**: 下楼梯速度
   - **单位**: 米/秒(m/s)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

8. `HKQuantityTypeIdentifierWalkingAsymmetryPercentage`:
   - **中文**: 步行不对称百分比
   - **单位**: 百分比(%)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

9. `HKQuantityTypeIdentifierWalkingDoubleSupportPercentage`:
   - **中文**: 步行双支撑百分比
   - **单位**: 百分比(%)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

10. `HKQuantityTypeIdentifierWalkingSpeed`:
    - **中文**: 步行速度
    - **单位**: 米/秒(m/s)
    - **类型**: 离散型(Discrete),算术(Arithmetic)

11. `HKQuantityTypeIdentifierWalkingStepLength`:
    - **中文**: 步行步长
    - **单位**: 米(m)
    - **类型**: 离散型(Discrete),算术(Arithmetic)

这些标识符用于追踪和分析用户的移动性和步行稳定性,对于评估用户的运动表现和健康状况非常有用。开发者可以在健康和健身应用程序中使用这些标识符来提供个性化的反馈和建议。

// Nutrition
以下是苹果 HealthKit 框架中定义的与营养摄入相关的 `HKQuantityTypeIdentifier` 标识符的中文翻译和描述:

1. `HKQuantityTypeIdentifierDietaryBiotin`:
   - **中文**: 饮食中生物素摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

2. `HKQuantityTypeIdentifierDietaryCaffeine`:
   - **中文**: 饮食中咖啡因摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

3. `HKQuantityTypeIdentifierDietaryCalcium`:
   - **中文**: 饮食中钙摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

4. `HKQuantityTypeIdentifierDietaryCarbohydrates`:
   - **中文**: 饮食中碳水化合物摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

5. `HKQuantityTypeIdentifierDietaryChloride`:
   - **中文**: 饮食中氯化物摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

6. `HKQuantityTypeIdentifierDietaryCholesterol`:
   - **中文**: 饮食中胆固醇摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

7. `HKQuantityTypeIdentifierDietaryChromium`:
   - **中文**: 饮食中铬摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

8. `HKQuantityTypeIdentifierDietaryCopper`:
   - **中文**: 饮食中铜摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

9. `HKQuantityTypeIdentifierDietaryEnergyConsumed`:
   - **中文**: 饮食中消耗的能量
   - **单位**: 千卡路里(kcal)
   - **类型**: 累积型(Cumulative)

10. `HKQuantityTypeIdentifierDietaryFatMonounsaturated`:
    - **中文**: 饮食中单不饱和脂肪摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

11. `HKQuantityTypeIdentifierDietaryFatPolyunsaturated`:
    - **中文**: 饮食中多不饱和脂肪摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

12. `HKQuantityTypeIdentifierDietaryFatSaturated`:
    - **中文**: 饮食中饱和脂肪摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

13. `HKQuantityTypeIdentifierDietaryFatTotal`:
    - **中文**: 饮食中总脂肪摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

14. `HKQuantityTypeIdentifierDietaryFiber`:
    - **中文**: 饮食中纤维摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

15. `HKQuantityTypeIdentifierDietaryFolate`:
    - **中文**: 饮食中叶酸摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

16. `HKQuantityTypeIdentifierDietaryIodine`:
    - **中文**: 饮食中碘摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

17. `HKQuantityTypeIdentifierDietaryIron`:
    - **中文**: 饮食中铁摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

18. `HKQuantityTypeIdentifierDietaryMagnesium`:
    - **中文**: 饮食中镁摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

19. `HKQuantityTypeIdentifierDietaryManganese`:
    - **中文**: 饮食中锰摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

20. `HKQuantityTypeIdentifierDietaryMolybdenum`:
    - **中文**: 饮食中钼摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

21. `HKQuantityTypeIdentifierDietaryNiacin`:
    - **中文**: 饮食中烟酸摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

22. `HKQuantityTypeIdentifierDietaryPantothenicAcid`:
    - **中文**: 饮食中泛酸摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

23. `HKQuantityTypeIdentifierDietaryPhosphorus`:
    - **中文**: 饮食中磷摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

24. `HKQuantityTypeIdentifierDietaryPotassium`:
    - **中文**: 饮食中钾摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

25. `HKQuantityTypeIdentifierDietaryProtein`:
    - **中文**: 饮食中蛋白质摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

26. `HKQuantityTypeIdentifierDietaryRiboflavin`:
    - **中文**: 饮食中核黄素摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

27. `HKQuantityTypeIdentifierDietarySelenium`:
    - **中文**: 饮食中硒摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

28. `HKQuantityTypeIdentifierDietarySodium`:
    - **中文**: 饮食中钠摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

29. `HKQuantityTypeIdentifierDietarySugar`:
    - **中文**: 饮食中糖摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

30. `HKQuantityTypeIdentifierDietaryThiamin`:
    - **中文**: 饮食中硫胺素摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

31. `HKQuantityTypeIdentifierDietaryVitaminA`:
    - **中文**: 饮食中维生素A摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)

32. `HKQuantityTypeIdentifierDietaryVitaminB12`:
    - **中文**: 饮食中维生素B12摄入量
    - **单位**: 克(g)
    - **类型**: 累积型(Cumulative)


以下是苹果 HealthKit 框架中定义的与营养摄入和其他健康相关数据类型的 `HKQuantityTypeIdentifier` 标识符的中文翻译和描述:

### 营养 (Nutrition)

1. `HKQuantityTypeIdentifierDietaryVitaminB6`:
   - **中文**: 饮食中维生素B6摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

2. `HKQuantityTypeIdentifierDietaryVitaminC`:
   - **中文**: 饮食中维生素C摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

3. `HKQuantityTypeIdentifierDietaryVitaminD`:
   - **中文**: 饮食中维生素D摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

4. `HKQuantityTypeIdentifierDietaryVitaminE`:
   - **中文**: 饮食中维生素E摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

5. `HKQuantityTypeIdentifierDietaryVitaminK`:
   - **中文**: 饮食中维生素K摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

6. `HKQuantityTypeIdentifierDietaryWater`:
   - **中文**: 饮食中水摄入量
   - **单位**: 毫升(mL)
   - **类型**: 累积型(Cumulative)

7. `HKQuantityTypeIdentifierDietaryZinc`:
   - **中文**: 饮食中锌摄入量
   - **单位**: 克(g)
   - **类型**: 累积型(Cumulative)

### 其他 (Other)

8. `HKQuantityTypeIdentifierBloodAlcoholContent`:
   - **中文**: 血液酒精含量
   - **单位**: 百分比(%)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

9. `HKQuantityTypeIdentifierBloodPressureDiastolic`:
   - **中文**: 舒张压
   - **单位**: 毫米汞柱(mmHg)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

10. `HKQuantityTypeIdentifierBloodPressureSystolic`:
    - **中文**: 收缩压
    - **单位**: 毫米汞柱(mmHg)
    - **类型**: 离散型(Discrete),算术(Arithmetic)

11. `HKQuantityTypeIdentifierInsulinDelivery`:
    - **中文**: 胰岛素输送量
    - **单位**: 国际单位(IU)
    - **类型**: 累积型(Cumulative)

12. `HKQuantityTypeIdentifierNumberOfAlcoholicBeverages`:
    - **中文**: 酒精饮料数量
    - **单位**: 计数(count)
    - **类型**: 累积型(Cumulative)

13. `HKQuantityTypeIdentifierNumberOfTimesFallen`:
    - **中文**: 跌倒次数
    - **单位**: 计数(count)
    - **类型**: 累积型(Cumulative)

14. `HKQuantityTypeIdentifierTimeInDaylight`:
    - **中文**: 日照时间
    - **单位**: 分钟(min)
    - **类型**: 累积型(Cumulative)

15. `HKQuantityTypeIdentifierUVExposure`:
    - **中文**: 紫外线暴露
    - **类型**: 离散型(Discrete),算术(Arithmetic)

16. `HKQuantityTypeIdentifierWaterTemperature`:
    - **中文**: 水温
    - **单位**: 摄氏度(degC)
    - **类型**: 离散型(Discrete),算术(Arithmetic)


// Reproductive Health
以下是苹果 HealthKit 框架中定义的与生殖健康、呼吸和生命体征相关的 `HKQuantityTypeIdentifier` 标识符的中文翻译和描述:

### 生殖健康 (Reproductive Health)

1. `HKQuantityTypeIdentifierBasalBodyTemperature`:
   - **中文**: 基础体温
   - **单位**: 摄氏度(degC)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

### 呼吸 (Respiratory)

2. `HKQuantityTypeIdentifierForcedExpiratoryVolume1`:
   - **中文**: 用力呼气量(第一秒)
   - **单位**: 升(L)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

3. `HKQuantityTypeIdentifierForcedVitalCapacity`:
   - **中文**: 用力肺活量
   - **单位**: 升(L)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

4. `HKQuantityTypeIdentifierInhalerUsage`:
   - **中文**: 吸入器使用次数
   - **单位**: 计数(count)
   - **类型**: 累积型(Cumulative)

5. `HKQuantityTypeIdentifierOxygenSaturation`:
   - **中文**: 氧饱和度
   - **单位**: 百分比(%)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

6. `HKQuantityTypeIdentifierPeakExpiratoryFlowRate`:
   - **中文**: 峰值呼气流速
   - **单位**: 升/分钟(L/min)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

7. `HKQuantityTypeIdentifierRespiratoryRate`:
   - **中文**: 呼吸频率
   - **单位**: 次/秒(count/s)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

### 生命体征 (Vital Signs)

8. `HKQuantityTypeIdentifierBloodGlucose`:
   - **中文**: 血糖水平
   - **单位**: 毫克/分升(mg/dL)
   - **类型**: 离散型(Discrete),算术(Arithmetic)

9. `HKQuantityTypeIdentifierBodyTemperature`:
   - **中文**: 体温
   - **单位**: 摄氏度(degC)
   - **类型**: 离散型(Discrete),算术(Arithmetic)



/*--------------------------------*/
/*   HKCategoryType Identifiers   */
/*--------------------------------*/

typedef NSString * HKCategoryTypeIdentifier NS_STRING_ENUM;

这段代码定义了苹果 HealthKit 框架中的 `HKCategoryTypeIdentifier` 类型,这些标识符用于表示健康数据中的分类类型。以下是每个标识符的中文翻译和描述:

### 健身 (Fitness)

1. `HKCategoryTypeIdentifierAppleStandHour`:
   - **中文**: 苹果站立小时
   - **说明**: 表示用户在特定小时内站立的情况,通常与 Apple Watch 的站立提醒功能相关。

### 听力健康 (Hearing Health)

2. `HKCategoryTypeIdentifierEnvironmentalAudioExposureEvent`:
   - **中文**: 环境音频暴露事件
   - **说明**: 表示用户在某个时间段内的环境音频暴露情况。

3. `HKCategoryTypeIdentifierHeadphoneAudioExposureEvent`:
   - **中文**: 耳机音频暴露事件
   - **说明**: 表示用户通过耳机听音乐时的音频暴露情况。

### 心脏 (Heart)

4. `HKCategoryTypeIdentifierHighHeartRateEvent`:
   - **中文**: 高心率事件
   - **说明**: 表示用户的心率超过某个预设阈值的事件。

5. `HKCategoryTypeIdentifierIrregularHeartRhythmEvent`:
   - **中文**: 不规律心律事件
   - **说明**: 表示用户心律不规律的事件。

6. `HKCategoryTypeIdentifierLowCardioFitnessEvent`:
   - **中文**: 低心肺健康事件
   - **说明**: 表示用户心肺健康水平低于某个阈值的事件。

7. `HKCategoryTypeIdentifierLowHeartRateEvent`:
   - **中文**: 低心率事件
   - **说明**: 表示用户的心率低于某个预设阈值的事件。

### 正念 (Mindfulness)

8. `HKCategoryTypeIdentifierMindfulSession`:
   - **中文**: 正念会话
   - **说明**: 表示用户进行正念练习或冥想的会话。

### 移动性 (Mobility)

9. `HKCategoryTypeIdentifierAppleWalkingSteadinessEvent`:
   - **中文**: 苹果步行稳定性事件
   - **说明**: 表示用户步行稳定性的评估结果。

### 其他 (Other)

10. `HKCategoryTypeIdentifierHandwashingEvent`:
    - **中文**: 洗手事件
    - **说明**: 表示用户洗手的行为记录。

11. `HKCategoryTypeIdentifierToothbrushingEvent`:
    - **中文**: 刷牙事件
    - **说明**: 表示用户刷牙的行为记录。



这段代码定义了苹果 HealthKit 框架中的 `HKCategoryTypeIdentifier` 类型,这些标识符用于表示生殖健康相关的分类数据。以下是每个标识符的中文翻译和描述:

### 生殖健康 (Reproductive Health)

1. `HKCategoryTypeIdentifierCervicalMucusQuality`:
   - **中文**: 宫颈粘液质量
   - **说明**: 表示女性宫颈粘液的特性,这可能与生育能力有关。

2. `HKCategoryTypeIdentifierContraceptive`:
   - **中文**: 避孕措施
   - **说明**: 表示使用的避孕方法或避孕药品。

3. `HKCategoryTypeIdentifierInfrequentMenstrualCycles`:
   - **中文**: 不规律月经周期
   - **说明**: 表示月经周期不规律的情况。

4. `HKCategoryTypeIdentifierIntermenstrualBleeding`:
   - **中文**: 经期间出血
   - **说明**: 表示在两个月经周期之间的出血情况。

5. `HKCategoryTypeIdentifierIrregularMenstrualCycles`:
   - **中文**: 不规律月经周期
   - **说明**: 表示月经周期出现不规则性。

6. `HKCategoryTypeIdentifierLactation`:
   - **中文**: 哺乳
   - **说明**: 表示哺乳期间的情况。

7. `HKCategoryTypeIdentifierMenstrualFlow`:
   - **中文**: 月经流量
   - **说明**: 表示月经期间的出血量。

8. `HKCategoryTypeIdentifierOvulationTestResult`:
   - **中文**: 排卵测试结果
   - **说明**: 表示排卵测试的结果,通常用于生育追踪。

9. `HKCategoryTypeIdentifierPersistentIntermenstrualBleeding`:
   - **中文**: 持续性经期间出血
   - **说明**: 表示持续性的非周期性出血。

10. `HKCategoryTypeIdentifierPregnancy`:
    - **中文**: 怀孕
    - **说明**: 表示怀孕的状态。

11. `HKCategoryTypeIdentifierPregnancyTestResult`:
    - **中文**: 怀孕测试结果
    - **说明**: 表示怀孕测试的结果。

12. `HKCategoryTypeIdentifierProgesteroneTestResult`:
    - **中文**: 孕酮测试结果
    - **说明**: 表示孕酮水平的测试结果,可能与生育能力或怀孕状态有关。

13. `HKCategoryTypeIdentifierProlongedMenstrualPeriods`:
    - **中文**: 延长月经周期
    - **说明**: 表示月经周期比正常时间长。

14. `HKCategoryTypeIdentifierSexualActivity`:
    - **中文**: 性活动
    - **说明**: 表示性活动的发生。

这些分类类型标识符允许开发者在健康应用程序中记录和分析用户的生殖健康状况,从而提供更个性化的健康服务和管理建议。

// Respiratory

// Sleep
  HKCategoryTypeIdentifierSleepAnalysis                        // HKCategoryValueSleepAnalysis
//睡眠分析

### 症状 (Symptoms)

1. `HKCategoryTypeIdentifierAbdominalCramps`:
   - **中文**: 腹部绞痛
   - **说明**: 表示腹部疼痛或不适的症状。

2. `HKCategoryTypeIdentifierAcne`:
   - **中文**: 痤疮(粉刺)
   - **说明**: 表示皮肤上的痤疮或粉刺症状。

3. `HKCategoryTypeIdentifierAppetiteChanges`:
   - **中文**: 食欲变化
   - **说明**: 表示食欲增加或减少的症状。

4. `HKCategoryTypeIdentifierBladderIncontinence`:
   - **中文**: 膀胱失禁
   - **说明**: 表示无法控制膀胱,导致尿失禁的症状。

5. `HKCategoryTypeIdentifierBloating`:
   - **中文**: 腹胀
   - **说明**: 表示腹部膨胀或不适的症状。

6. `HKCategoryTypeIdentifierBreastPain`:
   - **中文**: 乳房疼痛
   - **说明**: 表示乳房区域的疼痛症状。

7. `HKCategoryTypeIdentifierChestTightnessOrPain`:
   - **中文**: 胸部紧绷或疼痛
   - **说明**: 表示胸部感到紧绷或疼痛的症状。

8. `HKCategoryTypeIdentifierChills`:
   - **中文**: 寒战
   - **说明**: 表示感到寒冷或颤抖的症状。

9. `HKCategoryTypeIdentifierConstipation`:
   - **中文**: 便秘
   - **说明**: 表示排便困难或不频繁的症状。

10. `HKCategoryTypeIdentifierCoughing`:
    - **中文**: 咳嗽
    - **说明**: 表示咳嗽的症状。

11. `HKCategoryTypeIdentifierDiarrhea`:
    - **中文**: 腹泻
    - **说明**: 表示频繁排便且大便稀的症状。

12. `HKCategoryTypeIdentifierDizziness`:
    - **中文**: 头晕
    - **说明**: 表示头晕或失去平衡感的症状。

13. `HKCategoryTypeIdentifierDrySkin`:
    - **中文**: 皮肤干燥
    - **说明**: 表示皮肤缺乏湿润的症状。

14. `HKCategoryTypeIdentifierFainting`:
    - **中文**: 昏厥
    - **说明**: 表示意识丧失或昏倒的症状。

15. `HKCategoryTypeIdentifierFatigue`:
    - **中文**: 疲劳
    - **说明**: 表示极度疲倦或缺乏能量的症状。

16. `HKCategoryTypeIdentifierFever`:
    - **中文**: 发热
    - **说明**: 表示体温升高的症状。

17. `HKCategoryTypeIdentifierGeneralizedBodyAche`:
    - **中文**: 全身酸痛
    - **说明**: 表示全身性的肌肉或关节疼痛。

18. `HKCategoryTypeIdentifierHairLoss`:
    - **中文**: 脱发
    - **说明**: 表示头发异常脱落的症状。

19. `HKCategoryTypeIdentifierHeadache`:
    - **中文**: 头痛
    - **说明**: 表示头部疼痛的症状。

20. `HKCategoryTypeIdentifierHeartburn`:
    - **中文**: 胃灼热
    - **说明**: 表示胸部或喉咙的烧灼感。

21. `HKCategoryTypeIdentifierHotFlashes`:
    - **中文**: 潮热
    - **说明**: 表示突然感到身体特别是上半身非常热的症状。

22. `HKCategoryTypeIdentifierLossOfSmell`:
    - **中文**: 嗅觉丧失
    - **说明**: 表示嗅觉减退或丧失的症状。

23. `HKCategoryTypeIdentifierLossOfTaste`:
    - **中文**: 味觉丧失
    - **说明**: 表示味觉减退或丧失的症状。

24. `HKCategoryTypeIdentifierLowerBackPain`:
    - **中文**: 下背痛
    - **说明**: 表示下背部的疼痛。

25. `HKCategoryTypeIdentifierMemoryLapse`:
    - **中文**: 记忆失误
    - **说明**: 表示记忆力减退或遗忘的症状。

26. `HKCategoryTypeIdentifierMoodChanges`:
    - **中文**: 情绪变化
    - **说明**: 表示情绪状态的显著变化。

27. `HKCategoryTypeIdentifierNausea`:
    - **中文**: 恶心
    - **说明**: 表示有呕吐的感觉。

28. `HKCategoryTypeIdentifierNightSweats`:
    - **中文**: 盗汗
    - **说明**: 表示在睡眠中出汗的症状。

29. `HKCategoryTypeIdentifierPelvicPain`:
    - **中文**: 骨盆疼痛
    - **说明**: 表示骨盆区域的疼痛。

30. `HKCategoryTypeIdentifierRapidPoundingOrFlutteringHeartbeat`:
    - **中文**: 心跳快速或扑动
    - **说明**: 表示心跳异常快速、强烈或不规则。

31. `HKCategoryTypeIdentifierRunnyNose`:
    - **中文**: 流鼻涕
    - **说明**: 表示鼻腔分泌物增多的症状。

32. `HKCategoryTypeIdentifierShortnessOfBreath`:
    - **中文**: 呼吸急促
    - **说明**: 表示呼吸困难或不足。

33. `HKCategoryTypeIdentifierSinusCongestion`:
    - **中文**: 鼻窦充血
    - **说明**: 表示鼻窦区域的充血或堵塞。

34. `HKCategoryTypeIdentifierSkippedHeartbeat`:
    - **中文**: 心跳漏跳
    - **说明**: 表示心跳不规则,感觉像是漏跳了一次。

35. `HKCategoryTypeIdentifierSleepChanges`:
    - **中文**: 睡眠变化
    - **说明**: 表示睡眠模式或质量的变化。

36. `HKCategoryTypeIdentifierSoreThroat`:
    - **中文**: 喉咙痛
    - **说明**: 表示喉咙疼痛或刺激感。

37. `HKCategoryTypeIdentifierVaginalDryness`:
    - **中文**: 阴道干燥
    - **说明**: 表示阴道缺乏湿润的症状。

38. `HKCategoryTypeIdentifierVomiting`:
    - **中文**: 呕吐
    - **说明**: 表示将胃内容物强制从口中排出的症状。

39. `HKCategoryTypeIdentifierWheezing`:
    - **中文**: 喘息
    - **说明**: 表示呼吸时伴有的喘鸣声。

这些分类类型标识符允许开发者在健康应用程序中记录和分析用户的各种身体症状,从而帮助用户更好地了解和管理自己的健康状况。

/*--------------------------------------*/
/*   HKCharacteristicType Identifiers   */
/*--------------------------------------*/

typedef NSString * HKCharacteristicTypeIdentifier NS_STRING_ENUM;



### 个人特征 (Me)

1. `HKCharacteristicTypeIdentifierBiologicalSex`:
   - **中文**: 生物性别
   - **说明**: 表示用户的生理性别,如男性、女性或不指定。

2. `HKCharacteristicTypeIdentifierBloodType`:
   - **中文**: 血型
   - **说明**: 表示用户的血型,例如A型、B型、AB型或O型,以及Rh因子。

3. `HKCharacteristicTypeIdentifierDateOfBirth`:
   - **中文**: 出生日期
   - **说明**: 表示用户的出生日期,通常以 `NSDateComponents` 形式存储。

4. `HKCharacteristicTypeIdentifierFitzpatrickSkinType`:
   - **中文**: 菲茨帕特里克皮肤类型
   - **说明**: 表示用户的皮肤对紫外线敏感度的分类,用于评估皮肤类型和对阳光的反应。

5. `HKCharacteristicTypeIdentifierWheelchairUse`:
   - **中文**: 轮椅使用情况
   - **说明**: 表示用户是否使用轮椅,以及使用的原因和频率。


// Other
  HKCharacteristicTypeIdentifierActivityMoveMode     // HKActivityMoveModeObject

/*-----------------------------------*/
/*   HKCorrelationType Identifiers   */
/*-----------------------------------*/

typedef NSString * HKCorrelationTypeIdentifier NS_STRING_ENUM;

这段代码定义了苹果 HealthKit 框架中的 `HKCorrelationTypeIdentifier` 类型,这些标识符用于表示可以进行相关性分析的健康数据类型。以下是每个标识符的中文翻译和描述:

### 心脏 (Heart)

1. `HKCorrelationTypeIdentifierBloodPressure`:
   - **中文**: 血压
   - **说明**: 表示与血压测量相关的健康数据,通常包括收缩压和舒张压两个数值。这个标识符用于将血压测量与其他可能影响血压的健康数据(如心率、活动量或特定时间点的锻炼)进行相关性分析。

### 其他 (Other)

2. `HKCorrelationTypeIdentifierFood`:
   - **中文**: 食物
   - **说明**: 表示与食物摄入相关的健康数据,可以用于记录和分析用户的饮食情况。这个标识符可能用于将食物摄入与其他健康数据(如血糖水平、体重变化或营养摄入)进行相关性分析。

`HKCorrelationTypeIdentifier` 用于在 HealthKit 中创建数据点之间的相关性,这可以帮助用户和开发者更好地理解不同健康变量之间的关系。例如,通过分析血压和活动量之间的相关性,用户可能能更好地了解运动对血压的影响。同样,通过分析食物摄入和血糖水平之间的相关性,可以更好地管理饮食和血糖控制。

/*--------------------------------*/
/*   HKDocumentType Identifiers   */
/*--------------------------------*/

typedef NSString * HKDocumentTypeIdentifier NS_STRING_ENUM;

// Clinical Documents
HK_EXTERN HKDocumentTypeIdentifier const HKDocumentTypeIdentifierCDA 
中文: 临床文档交换格式(CDA)

/*-------------------------------*/
/*   HKWorkoutType Identifiers   */
/*-------------------------------*/

// Fitness
  HKWorkoutTypeIdentifier 

/*--------------------------------*/
/*   HKSeriesSample Identifiers   */
/*--------------------------------*/

// Fitness
  HKWorkoutRouteTypeIdentifier 

// Heart
  HKDataTypeIdentifierHeartbeatSeries 

/*--------------------------------------*/
/*   HKVisionPrescription Identifiers   */
/*--------------------------------------*/

// Body Measurements
  HKVisionPrescriptionTypeIdentifier 

/*----------------*/
/*   Deprecated   */
/*----------------*/

  HKCategoryTypeIdentifierAudioExposureEvent API_DEPRECATED_WITH_REPLACEMENT("HKCategoryTypeIdentifierEnvironmentalAudioExposureEvent", 

NS_ASSUME_NONNULL_END

  • 9
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值