`
`Language: Swift Y
`
`API changes: None
`
`Framework
`
`Core Motion
`
`Process accelerometer, gyroscope, pedometer, and environment-related events.
`
`iOS 4.0+
`
`iPadOS 4.0+ Mac Catalyst 13.0+ macOS10.15+
`
`visionOS1.0+
`
`watchOS 2.0+
`
`Overview
`
`Core Motion reports motion- and environment-related data from the availa
`iOS, iPadOS, watchOS, and visionOS devices. This hardware includes the
`and gyroscopes, and, when available, the pedometer, magnetometer, and
`in your app as input for user interactions, fitness tracking, health-related
`example, a game might use accelerometer and gyroscopeinput to control
`behavior.
`
`d hardware of
`
`celerometers
`
`Use this data
`
`more. For
`ame
`
`The services of this framework provide access to motion data either as ra
`
`and many services provide both types of values. Raw values reflect the un
`
`hardware, while processed values eliminate forms of bias that might adver
`your usage of
`caused by
`the data. For example, a processed accelerometer value reflects only the
`the user and not the acceleration caused by gravity.
`
`sed values,
`ata from the
`
`
`
`
`
`
`Notall services are available on all devices, and some services might be u
`ven on
`
`devices with the required hardware. For example, many Core Motion servi
`ilable to
`visionOS apps, but those services aren't available to compatible iPad and i
`s running in
`visionOS. Before you try to use any motion-related services, check the av
`those
`services using a CMMotionManager object.
`
`
`
`Page 1 of 7
`Page 1 of 7
`
`HAPTIC EX2019
`HAPTIC EX2019
`
`
`
`
`
`
`
`Important
`
`An iOS app must include usage description keys in its Info.plist file for the types of data it
`needs. If these keys aren’t present, the app crashes when you try to access the corresponding
`service. To access motion andfitness data, include NSMotionUsageDescription. To
`accessthefall-detection service, include NSFallDetectionUsageDescription.
`
`Topics
`
`Essentials
`
`(} Core Motion updates
`
`Learn about important changes to Core Motion.
`
`class CMMotionManager
`
`The object for starting and managing motion services.
`
`Device motion
`
`Accessacceleration, attitude, rotation, and magnetic field data that is adjusted for gravity and
`other forms of bias.
`
`(3 Getting processed device-motion data
`
`Retrieve motion data that the system processed to remove environmental bias, such as the
`effects of gravity.
`
`class CMDeviceMotion
`
`Encapsulated measurements of the attitude, rotation rate, and acceleration of a device.
`
`class CMAttitude
`
`The device's orientation relative to a known frame of referenceat a point in time.
`
`struct CMAttitudeReferenceFrame
`
`Constants that indicate the frame of reference for attitude-related motion data.
`
`class CMHeadphoneMotionManager
`
`Page 2 of 7
`
`Page 2 of 7
`
`
`
`An object that starts and manages headphone motion services.
`
`Accelerometers
`
`Access accelerometer data for all three axes of the device.
`
`(3 Getting raw accelerometer events
`
`Retrieve data from the onboard accelerometers.
`
`class CMAccelerometerData
`
`A data sample from the device's three accelerometers.
`
`class CMRecordedAccelerometerData
`
`A single piece of accelerometer data that was recorded by the device.
`
`class CMSensorRecorder
`
`An object that gathers and retrieves accelerometer data from a device.
`
`class CMSensorDataList
`
`A list of the accelerometer data recorded by the system.
`
`Gyroscopes
`
`Accessthe raw gyroscopedata.
`
`(3 Getting raw gyroscope events
`
`Retrieve data from the onboard gyroscopes.
`
`class CMGyroData
`
`A single measurement of the device's rotation rate.
`
`Magnetometer
`
`Access raw magnetometer data.
`
`class CMMagnetometerData
`
`Measurementsof the Earth's magnetic field relative to the device.
`
`Page 3 of 7
`
`Page 3 of 7
`
`
`
`Altitude data
`
`Accessaltitude data based on barometric sensor information.
`
`class CMAltimeter
`
`An object thatinitiates the delivery of altitude-related changes.
`
`class CMAbsoluteAltitudeData
`
`Data that records a change in absolute altitude.
`
`class CMAltitudeData
`
`Data for a recorded changein altitude.
`
`Ambient pressure
`
`class CMRecordedPressureData
`
`A recorded measurementof pressure data.
`
`class CMAmbientPressureData
`
`A measurement of the ambient pressure and temperature.
`
`Water submersion
`
`(5 Accessing submersion data
`
`Use a water-submersion manager to receive water pressure, temperature, and depth data on
`Apple Watch Ultra.
`
`class CMWaterSubmersionManager
`
`An object for managing the collection of pressure and temperature data during submersion.
`
`protocol CMWaterSubmersionManagerDelegate
`
`A delegate that receives updates about ambient pressure, water pressure, water temperature,
`and submersion events.
`
`class CMWaterSubmersionEvent
`
`An eventindicating that the device's submersion state has changed.
`
`Page 4 of 7
`
`Page 4 of 7
`
`
`
`class CMWaterSubmersionMeasurement
`
`An update that contains data about the pressure and depth.
`
`class CMWaterTemperature
`
`An update that contains data about the water temperature.
`
`Activity
`
`class CMMotionActivityManager
`
`An object that managesaccessto the motion data stored by the device.
`
`class CMHeadphoneActivityManager
`
`An object that starts and manages headphone activity services.
`
`class CMMotionActivity
`
`The data for a single motion update event.
`
`{} Getting motion-activity data from headphones
`
`Configure your app to listen for motion-activity changes from headphones.
`
`Pedometer and fitness
`
`Access step-counting data from the built-in motion processor.
`
`class CMPedometer
`
`An object for fetching the system-generatedlive walking data.
`
`class CMPedometerData
`
`Information about the distance traveled by a user on foot.
`
`class CMPedometerEvent
`
`A change in the user's pedestrian activity.
`
`class—GMStepGounter
`
`The number of steps the user has taken with the device.
`
`Deprecated
`
`class CMOdometerData
`
`Page 5 of 7
`
`Page 5 of 7
`
`
`
`A class that represents odometer data for workouts.
`
`class CMHighFrequencyHeartRateData
`
`A class that represents heart rate data collected at 1 Hz.
`
`Movementdisorder
`
`(§ Getting movementdisorder symptom data
`
`Retrieve data from the Apple Watch's movement disorder manager.
`
`(3 Adhering to the movementdisorderdata collection requirements
`
`Ensure that your users understand and have control over the data your app collects.
`
`[3 Movementdisorder algorithm changelog
`
`A chronological log of notable changes to the movementdisorder algorithm.
`
`class CMMovementDisorderManager
`
`A manager for recording and querying movementdisorder data.
`
`class CMTremorResult
`
`A result object that contains data about the presence and strength of tremors during a one-
`minute interval.
`
`class CMDyskineticSymptomResult
`
`A result object that contains data aboutthe likely presence of dyskinetic symptoms during a
`one-minuteinterval.
`
`Fall detection
`
`class CMFallDetectionManager
`
`An object for managing fall detection events.
`
`protocol CMFallDetectionDelegate
`
`A delegate that receives information aboutfall detection events and authorization status
`changes.
`
`class CMFallDetectionEvent
`
`An object that contains data about a fall detection event.
`
`Page 6 of 7
`
`Page 6 of 7
`
`
`
`NSFallDetectionUsageDescription
`
`A message to the user that explains the app’s request for permission to accessfall detection
`event data.
`
`Historical data
`
`Access recorded motion events to help you analyze movementpatterns.
`
`class CMBatchedSensorManager
`
`Common data
`
`class CMLogItem
`
`The baseclass for all motion-related data objects.
`
`Page 7 of 7
`
`Page 7 of 7
`
`