HealthKit之实战读取本人消息

- (void)requestHealthAuthorization

{

    if (![HKHealthStore isHealthDataAvailable])

    {

        NSLog(@"设备不支持healthKit"); return;

    }

    _healthStore = [[HKHealthStore alloc] init];

    HKObjectType *type1 = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierBiologicalSex]; // 性别

    HKObjectType *type2 = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierBloodType];//血型

    HKObjectType *type3 = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth];//出生日期

    HKObjectType *type4 = [HKObjectType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierFitzpatrickSkinType];//日光反应型皮肤类型

    

    NSSet *set = [NSSet setWithObjects:type1, type2, type3, type4, nil]; // 读集合

   

    __weak typeof (&*self) weakSelf = self;

    [_healthStore requestAuthorizationToShareTypes:nil readTypes:set completion:^(BOOL success, NSError * _Nullable error) {

        if (success)

        {

            [weakSelf readHealthPersonInfo];

        } else

        {

            NSLog(@"healthkit不允许读写");

        }

    }];

}

//查询数据

- (void)readHealthPersonInfo

{

    if ([UIDevice currentDevice].systemVersion.floatValue >=9.0)

    {

        NSLog(@"\n\n");

        NSLog(@"数据从这天%@才能读到”, [_healthStore earliestPermittedSampleDate]);

    }

    NSError *error = nil;

    NSDate *b = [_healthStore dateOfBirthWithError:&error];

    if (!error) NSLog(@"出生日期=%@", b);

    else NSLog(@"出生日期error=%@", error);

    

    error = nil;

    HKBiologicalSexObject *s = [_healthStore biologicalSexWithError:&error];

    if (!error) {

        NSLog(@"性别=%@", @(s.biologicalSex));

    } else {

        NSLog(@"性别error=%@",error);

    }

    

    error = nil;

    HKBloodTypeObject *blood = [_healthStore bloodTypeWithError:&error];

    if (!error) {

        NSLog(@"血型=%@", @(blood.bloodType));

    } else {

        NSLog(@"血型error=%@",error);

    }

    

    error = nil;

    HKFitzpatrickSkinTypeObject *fitz = [_healthStore fitzpatrickSkinTypeWithError:&error];

    if (!error) {

        NSLog(@"日光反应型皮肤类型=%@", @(fitz.skinType));

    } else {

        NSLog(@"日光反应型皮肤类型error=%@",error);

    }

}

时间: 2024-09-10 10:43:49

HealthKit之实战读取本人消息的相关文章

HealthKit之实战读取步数、活动时长、运动距离、已爬楼层、活动能量、健身记录

- (void)queryStepCount {     if (![HKHealthStore isHealthDataAvailable])     {         NSLog(@"设备不支持healthKit"); return;     }     _healthStore = [[HKHealthStore alloc] init];     HKObjectType *type1 = [HKObjectType quantityTypeForIdentifier:HKQ

MSMQ如何异步一次性读取所有消息

问题描述 我用System.Messaging.Messagem=mq.EndReceive(asyncResult.AsyncResult);只能依依取出消息,我要一次性取出所有的消息 解决方案 解决方案二:没有人会吗解决方案三:这年头还有人用MSMQ么!?LZ要做么?提高性能也可以用其他方法的解决方案四:MSMQ很落后吗?我还以为多先进的呢解决方案五:MessageEnumeratormyEnumerator=mq.GetMessageEnumerator(); 一次性读取所有消息似乎不存在

HealthKit之实战锚点读取

- (void)queryStepCount {     if (![HKHealthStore isHealthDataAvailable])     {         NSLog(@"设备不支持healthKit"); return;     }     _healthStore = [[HKHealthStore alloc] init];     HKObjectType *type1 = [HKObjectType quantityTypeForIdentifier:HKQ

.NET C# 异步读取Windows消息队列无法实现

问题描述 场景:由于项目需求,在WCF与WindowsService之间需要用到Windows消息队列这个东西WindowsService可以正常写入队列消息,但是,在WCF服务中要去异步读取消息队列中的数据,却不能正常访问得到数据并处理.WindowsService在创建队列实例时已将将权限给到了最高级别Everyone了错误提示:消息队列系统的访问被拒绝.求各位大神,帮帮忙吧,很着急-- 解决方案 解决方案二:遇到同样的问题.求大神解答..

HealthKit之实战写入和删除

- (void)queryStepCount {     if (![HKHealthStore isHealthDataAvailable])     {         NSLog(@"设备不支持healthKit"); return;     }     _healthStore = [[HKHealthStore alloc] init];     HKObjectType *type1 = [HKObjectType categoryTypeForIdentifier:HKC

Android 中怎么读取离线消息的接口是哪个??求源码

问题描述 解决方案 环信demo都写好了.注册监听,有回调EventOfflineMessage

Sparkstreaming读取Kafka消息再结合SparkSQL,将结果保存到HBase

亲自摸索,送给大家,原创文章,转载注明哦. import org.apache.hadoop.hbase.HBaseConfiguration import org.apache.hadoop.hbase.mapreduce.TableOutputFormat import org.apache.spark.SparkConf import org.apache.spark.sql._ import org.apache.spark.streaming.kafka.KafkaUtils impo

cxf webservice SOAP消息获取问题求救

问题描述 最近在做与平台对接的项目,要求能够提供webservice接口给平台,当有用户通过平台操作业务是,平台能够从我们的业务系统中获取相关数据,其中平台方提供的接口要求如下:接口位置函数名所在WSDLgetDepartmentInfoAppointmentRegisterWebService.wsdl发送参数数据项目数据类型格式说明发送数据SOAPHeader<soapenv:Header><Authorization><userid></userid&g

C#实现异步消息队列

原文:C#实现异步消息队列 拿到新书<.net框架设计>,到手之后迅速读了好多,虽然这本书不像很多教程一样从头到尾系统的讲明一些知识,但是从项目实战角度告诉我们如何使用我们的知识,从这本书中提炼了一篇,正好符合我前几篇的"数据驱动框架"设计的问题: 消息队列 消息队列(英语:Message queue)是一种进程间通信或同一进程的不同线程间的通信方式,软件的贮列用来处理一系列的输入,通常是来自使用者.消息队列提供了异步的通信协议,每一个贮列中的纪录包含详细说明的资料,包含发