Overview
Motion detection enables:- Stop detection: Identify when a user has stopped moving
- Activity classification: Determine if the user is stationary, walking, running, biking, or driving
- Floor level detection: Detect changes in altitude for indoor positioning
- Battery optimization: Reduce location updates when the device is stationary
Enable motion detection
To enable motion detection, set theuseMotion property on your tracking options:
Motion detection requires the RadarSDKMotion framework to be integrated separately. The SDK will automatically detect its presence and enable motion features.
Request motion permissions
Motion & Fitness permissions are required to access activity data:Activity types
The SDK can detect the following activity types:| Activity | Description |
|---|---|
RadarActivityTypeStationary | Device is stationary |
RadarActivityTypeFoot | User is walking |
RadarActivityTypeRun | User is running |
RadarActivityTypeBike | User is biking |
RadarActivityTypeCar | User is driving |
RadarActivityTypeUnknown | Activity cannot be determined |
Stop detection
Configure stop detection parameters to determine when a user has stopped moving:stopDistance for at least stopDuration.
Optimize battery with stop detection
Reduce battery usage by stopping location updates when the device is stationary:Pressure sensor integration
Enable pressure sensor data to detect floor level changes:Pressure sensor data is available on devices with a barometer. The SDK uses both relative altitude (pressure-based) and absolute altitude (iOS 15+) when available.
Motion-aware tracking presets
The preset tracking options include motion detection:Responsive preset
Includes motion detection for optimal battery usage:Efficient preset
Uses visit detection which relies on motion sensors:Receive motion updates
Receive activity updates through the Radar delegate:Implementation details
The SDK manages motion detection through theRadarActivityManager class which:
- Initializes motion activity monitoring when
useMotionis enabled - Starts activity updates from CoreMotion’s
CMMotionActivityManager - Monitors relative altitude using
CMAltimeterwhenusePressureis enabled - On iOS 15+, also monitors absolute altitude using
CMAbsoluteAltitudeData - Automatically stops updates when tracking is stopped
Best practices
Request permission early
Request Motion & Fitness permission when your app launches or during onboarding to ensure smooth tracking.
Combine with geofencing
Use motion detection with
useStoppedGeofence to maximize battery efficiency.Test different activities
Test your app’s behavior while walking, driving, and stationary to ensure proper detection.
Handle permission denial
Gracefully handle cases where users deny Motion & Fitness permission.
Troubleshooting
Motion detection not working
Motion detection not working
- Verify the RadarSDKMotion framework is integrated
- Check that Motion & Fitness permissions are granted
- Ensure
useMotionis set totruein tracking options - Check logs for “RadarSDKMotion detected and initialized” message
Pressure data unavailable
Pressure data unavailable
Stop detection too sensitive/insensitive
Stop detection too sensitive/insensitive
Adjust the
stopDuration and stopDistance parameters:- Increase
stopDurationfor less sensitive detection - Decrease
stopDistancefor more precise stop detection - Typical values: 140 seconds and 70 meters