core-motion
Core Motion
Reading the device's motion and environmental sensors: raw accelerometer/gyro, fused device motion, steps, activity classification, headphone motion, and altitude. The deep API reference — every manager, the push/pull delivery models, attitude reference frames, permissions, and battery discipline — lives in references/guide.md. This file is the decision and discipline layer: read it first, open the guide for specifics.
Dials
Set these explicitly at the start; they change what "correct" means.
SENSOR—device-motion(default; fusedCMDeviceMotion— attitude, rotationRate, gravity, userAcceleration) ·raw-accel-gyro(unprocessed streams; only when you need raw signal) ·pedometer(steps/distance/floors viaCMPedometer) ·activity(CMMotionActivityManager) ·headphone(AirPods motion, iOS 14+) ·altimeter(relative altitude/pressure).DELIVERY—push-updates(default;start…Updates(to:withHandler:)on a backgroundOperationQueue, event-driven) ·pull-query(start…Updates()then read the snapshot from a render/timer tick; orqueryPedometerData/queryActivityStartingagainst the system cache).FREQUENCY— the update interval (…UpdateInterval, in seconds). Pick the lowest rate the feature needs: UI/parallax 30–60 Hz, gestures ~20 Hz, games 60 Hz. Don't max it.
When to use
Building or reviewing any feature that reads motion sensors: tilt/orientation UI, level/compass, shake or gesture detection, step counters and fitness tracking, activity-aware behavior, AirPods head tracking, or barometric altitude. If you only need device heading, prefer Core Location's heading API; Core Motion's north-referenced frames are heavier.