首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过HRV跟踪心跳心跳苹果手表

通过HRV跟踪心跳心跳苹果手表
EN

Stack Overflow用户
提问于 2017-10-31 16:56:13
回答 3查看 2.5K关注 0票数 7

我在研究如何获得不同心跳间隔的节拍间隔。

我戴着苹果手表,现在可以出口

代码语言:javascript
复制
<Record type=“HKQuantityTypeIdentifierHeartRateVariabilitySDNN” sourceName=“Apple Watch” sourceVersion=“4.0” device=“&lt;&lt;HKDevice: 0x1c489da10&gt;, name:Apple Watch, manufacturer:Apple, model:Watch, hardware:Watch3,4, software:4.0&gt;” unit=“ms” creationDate=“2017-10-31 13:41:54 +0000" startDate=“2017-10-31 13:40:43 +0000” endDate=“2017-10-31 13:41:54 +0000" value=“92.7156”>
  <HeartRateVariabilityMetadataList>
   <InstantaneousBeatsPerMinute bpm=“69" time=“13:40:45.22”/>
   <InstantaneousBeatsPerMinute bpm=“74" time=“13:40:46.02”/>
   <InstantaneousBeatsPerMinute bpm=“71" time=“13:40:46.87”/>
   <InstantaneousBeatsPerMinute bpm=“64" time=“13:40:47.81”/>
   <InstantaneousBeatsPerMinute bpm=“54" time=“13:40:48.92”/>
   <InstantaneousBeatsPerMinute bpm=“57" time=“13:40:49.97”/>
   <InstantaneousBeatsPerMinute bpm=“65" time=“13:40:50.90”/>
   <InstantaneousBeatsPerMinute bpm=“63" time=“13:40:51.86”/>
   <InstantaneousBeatsPerMinute bpm=“60" time=“13:40:52.86”/>
   <InstantaneousBeatsPerMinute bpm=“57" time=“13:40:53.92”/>
   <InstantaneousBeatsPerMinute bpm=“57" time=“13:40:54.98”/>
   <InstantaneousBeatsPerMinute bpm=“61" time=“13:40:55.97”/>
   <InstantaneousBeatsPerMinute bpm=“70" time=“13:40:56.83”/>
   <InstantaneousBeatsPerMinute bpm=“72" time=“13:40:57.66”/>
   <InstantaneousBeatsPerMinute bpm=“69" time=“13:40:58.54”/>
   <InstantaneousBeatsPerMinute bpm=“58" time=“13:40:59.58”/>
   <InstantaneousBeatsPerMinute bpm=“58" time=“13:41:02.75”/>
   <InstantaneousBeatsPerMinute bpm=“63" time=“13:41:03.70”/>
   <InstantaneousBeatsPerMinute bpm=“70" time=“13:41:04.56”/>
   <InstantaneousBeatsPerMinute bpm=“70" time=“13:41:05.41”/>
   <InstantaneousBeatsPerMinute bpm=“69" time=“13:41:13.15”/>
   <InstantaneousBeatsPerMinute bpm=“71" time=“13:41:13.99”/>
   <InstantaneousBeatsPerMinute bpm=“63" time=“13:41:21.11”/>
   <InstantaneousBeatsPerMinute bpm=“69" time=“13:41:21.98”/>
   <InstantaneousBeatsPerMinute bpm=“73" time=“13:41:22.79”/>
   <InstantaneousBeatsPerMinute bpm=“65" time=“13:41:35.27”/>
   <InstantaneousBeatsPerMinute bpm=“67" time=“13:41:36.17”/>
   <InstantaneousBeatsPerMinute bpm=“71" time=“13:41:37.01”/>
   <InstantaneousBeatsPerMinute bpm=“77" time=“13:41:37.79”/>
   <InstantaneousBeatsPerMinute bpm=“79" time=“13:41:38.55”/>
  </HeartRateVariabilityMetadataList>
 </Record>

然而,当我得到一个heartRateVariabilitySDNN的样本时,我只得到两个值。

这是我用来获取示例的代码

代码语言:javascript
复制
  let healthStore = HKHealthStore()

    var typeHeart = HKQuantityType.quantityType(forIdentifier: .heartRateVariabilitySDNN)
    var startDate = Date() - 7 * 24 * 60 * 60 // start date is a week
    var predicate: NSPredicate? = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: HKQueryOptions.strictEndDate)

    let sampleType = HKSampleType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRateVariabilitySDNN)

    let sortDescriptor = NSSortDescriptor(key:HKSampleSortIdentifierStartDate, ascending: false)

    let sampleQuery = HKSampleQuery(sampleType: sampleType!, predicate: predicate, limit: 30, sortDescriptors: [sortDescriptor])
    { (sampleQuery, results, error ) -> Void in
        if(error == nil) {
            print(results)
        }
    }

这就是它所输出的一切:

代码语言:javascript
复制
Optional([92.3536 ms D7627860-F87C-4316-9943-522BC1D6734B "Apple Watch" (4.0), "Watch3,4" (4.0)"Apple Watch"  (2017-10-31 13:48:19 +0000 - 2017-10-31 13:53:30 +0000), 92.7156 ms EB0DBCB1-164A-4D50-9103-270F3F9FBCD1 "Apple Watch" (4.0), "Watch3,4" (4.0)"Apple Watch"  (2017-10-31 13:40:43 +0000 - 2017-10-31 13:41:54 +0000)])

它们基本上是两个值: 92.7ms和92.3ms。这是在“呼吸”应用期间的平均2次训练。

有人知道我如何获得InstantaneousBeatsPerMinute和/或HRV元数据吗?

编辑:似乎有一些有趣的事情在进行,输出的值看起来非常像XML中Record类型的打印语句。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-11-10 22:53:24

在向苹果( Apple )提交技术支持事件(TSI)后,他们表示,目前不可能做到这一点。

感谢您联系苹果开发者技术支持(DTS)。我们的工程师已经审查了您的要求,并得出结论,在当前的运输系统配置中,没有支持实现所需功能的方法。 如果你想让苹果公司考虑在将来增加对这些功能的支持,请通过https://developer.apple.com/bug-reporting/的Bug工具提交一个增强请求。

如果你想看到这个功能,请提交一个错误报告!

票数 3
EN

Stack Overflow用户

发布于 2019-11-26 07:23:04

在iOS 13中,苹果发布了新的心跳系列API。您可以在这里找到更多详细信息:

data https://developer.apple.com/documentation/healthkit/hkheartbeatseriessample https://developer.apple.com/documentation/healthkit/hkheartbeatseriesquery

这个相关的WWDC视频会话对于理解这个新API:https://developer.apple.com/videos/play/wwdc2019/218非常有用。

票数 3
EN

Stack Overflow用户

发布于 2017-11-07 20:34:31

如果你想获得瞬时心率,你的应用程序应该启动一个HKWorkoutSession。

代码语言:javascript
复制
    self.workoutSession = HKWorkoutSession(activityType: .Running, locationType: .Indoor)
    self.workoutSession!.delegate = self;

    self.healthStore.startWorkoutSession(self.workoutSession!)

Then, you can start a streaming query from HKHealthKit to give you updates as HealthKit receives them:

    let distanceType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning)
    let predicate = HKQuery.predicateForSamplesWithStartDate(workoutStartDate, endDate: nil, options: .None)
    let distanceQuery = HKAnchoredObjectQuery(type: distanceType!, predicate: predicate, anchor: 0, limit: 0) { (query, samples, deletedObjects, anchor, error) -> Void in
        // Handle when the query first returns results
        // TODO: do whatever you want with samples (note you are not on the main thread)
    }
    distanceQuery.updateHandler = { (query, samples, deletedObjects, anchor, error) -> Void in
        // Handle update notifications after the query has initially run
    }

    self.healthStore.executeQuery(distanceQuery)
票数 -3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47040640

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档