View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Measure health with motion

    Discover how you can take your app's health monitoring to the next level with motion data. Meet Walking Steadiness for iPhone and the six-minute-walk metric for Apple Watch: Walking Steadiness can help your app interpret someone's quality of walking and risk of falling, while the six-minute-walk metric — along with the HealthKit estimate recalibration API — can track changes to walking endurance following acute events like surgery. We'll show you how you can support these metrics and help provide actionable health data to people who use your app, helping improve patient care and clinical trials, especially as more services must be delivered remotely.

    Ressources

    • HKAppleWalkingSteadinessClassification
    • appleWalkingSteadinessEvent
    • appleWalkingSteadiness
    • CMFallDetectionManager
    • Measuring Walking Quality Through iPhone Mobility Metrics
    • Using Apple Watch to Estimate Six-Minute Walk Distance
    • Using Apple Watch to Estimate Cardio Fitness with VO2 max
    • Getting movement disorder symptom data
    • Core Motion
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC20

    • Beyond counting steps
    • Getting started with HealthKit
  • Rechercher dans cette vidéo…
    • 0:01 - Grab authorization to read and share sixMinuteWalkTestDistance type

      // Grab authorization to read and share sixMinuteWalkTestDistance type
      
      let healthStore = HKHealthStore()
      let types: Set = [
          HKObjectType.quantityType(forIdentifier: .sixMinuteWalkTestDistance)!
      ]
      
      healthStore.requestAuthorization(toShare: types, read: types) { _, _ in }
    • 0:02 - Recalibrate Six-Minute Walk estimates

      // Recalibrate estimate
      
      let healthStore = HKHealthStore()
      let sixMinuteWalkType = HKSampleType.quantityType(forIdentifier: .sixMinuteWalkTestDistance)!
      
      if sixMinuteWalkType.allowsRecalibrationForEstimates {
      
          healthStore.recalibrateEstimates(sampleType: sixMinuteWalkType, date: surgeryDate) { 
              (success, error) in
              // Handle error
          }
      
      }
    • 0:03 - Get authorized for walkingSteadiness type

      // Get authorized
      
      let types: Set = [
          HKObjectType.quantityType(forIdentifier: .walkingSteadiness)!
      ]
      
      healthKitStore.requestAuthorization(toShare: nil, read: types) { _, _ in }
    • 0:04 - Construct a query for most recent walkingSteadiness score

      // Construct a query for most recent walkingSteadiness score
      
      let steadinessType = HKObjectType.quantityType(forIdentifier: .walkingSteadiness)
      let sortByEndDate = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false)
      
      let query = HKSampleQuery(sampleType: steadinessType,
                                predicate: nil,
                                limit: 1,
                                sortDescriptors: [sortByEndDate]) { (query, samples, error) in
      
          if let sample = samples?.first as? HKQuantitySample{
      
              let recentScore = sample.quantity.doubleValue(forUnit: .percentUnit)
      
              updateStatus(score: recentScore)
          }
      }
      
      self.healthStore.execute(query)
    • 0:05 - Construct a query for most recent walkingSteadiness classification

      // Construct a query for most recent walkingSteadiness classification
      
      let steadinessType = HKObjectType.quantityType(forIdentifier: .walkingSteadiness)
      
      let query = HKSampleQuery(sampleType: steadinessType,
                                predicate: nil,
                                limit: 1,
                                sortDescriptors: nil) { (query, samples, error) in
      
          if let sample = samples?.first as? HKQuantitySample{
              
              let recentScore = sample.quantity.doubleValue(forUnit: .percentUnit)
      
              // Use HealthKit API to classify a value as OK, Low, or Very Low
              let recentClassification = HKAppleWalkingSteadinessClassification(for: walkingSteadiness.quantity)
      
              updateStatus(classification: recentClassification, score: recentScore)
          }
      }
      
      self.healthStore.execute(query)
    • 0:06 - Get authorized .walkingSteadinessEvent

      // Get authorized
      
      let types: Set = [
          HKObjectType.categoryType(forIdentifier: .walkingSteadinessEvent)!
      ]
      
      healthKitStore.requestAuthorization(toShare: nil, read: types) { _, _ in }
    • 0:07 - Watch for walkingSteadiness notifications

      // Watch for walkingSteadiness notifications
      
      let notificationType = HKCategoryType.categoryType(forIdentifier: .appleWalkingSteadinessEvent)!
      
      let query = HKObserverQuery(sampleType: notificationType, predicate: nil) { 
          (query, completionHandler, errorOrNil) in
          
          if let error = errorOrNil {
              // Properly handle the error.
              return
          }
      
          promptCheckupForNotification()
      
          completionHandler()
      }
      
      self.healthStore.execute(query)
    • 0:08 - Query walking steadiness in the past 6 weeks

      // Query samples from HealthKit
      
      // Look back 6 weeks
      let end = Date()
      let start = Calendar.current.date(byAdding: .week, value: -6, to: end)
      
      let datePredicate = HKQuery.predicateForSamples(withStart: start, end: end, options: [])
      
      // Query walking steadiness
      let steadinessType = HKObjectType.quantityType(forIdentifier: .walkingSteadiness)
      let sortByEndDate = NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false)
      
      let query = HKSampleQuery(sampleType: steadinessType,
                                predicate: sortByEndDate,
                                limit: nil,
                                sortDescriptors:[sortByEndDate]) { (_, samples, _) in
      
          detectTrends(samples)
      }
      self.healthStore.execute(query)

Developer Footer

  • Vidéos
  • WWDC21
  • Measure health with motion
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines