Skip to main content

Overview

RadarMotionProtocol defines the interface for motion activity detection providers that can be integrated with the Radar SDK. This protocol enables the SDK to receive motion activity updates, relative altitude updates, and absolute altitude updates from CoreMotion or custom motion providers. Implementing this protocol allows for custom motion detection backends or wrapping of Apple’s CoreMotion framework.

Required Methods

startActivityUpdatesToQueue(_:withHandler:)

Starts monitoring motion activity updates and delivers them to a specified queue.
NSOperationQueue
required
The operation queue on which to deliver motion activity updates.
CMMotionActivityHandler
required
The block to invoke with motion activity updates. The handler receives CMMotionActivity objects representing the user’s current activity state.
CMMotionActivityHandler is a block type defined as void (^)(CMMotionActivity *activity).

stopActivityUpdates

Stops monitoring motion activity updates.
Call this method when motion activity updates are no longer needed to conserve battery and system resources.

startRelativeAltitudeUpdatesToQueue(_:withHandler:)

Starts monitoring relative altitude changes and delivers them to a specified queue.
NSOperationQueue
required
The operation queue on which to deliver altitude updates.
CMAltitudeHandler
required
The block to invoke with relative altitude updates. The handler receives CMAltitudeData objects representing altitude changes relative to a starting point.
Relative altitude measures changes from when monitoring started, useful for detecting floor changes in buildings.

stopRelativeAltitudeUpdates

Stops monitoring relative altitude updates.

startAbsoluteAltitudeUpdatesToQueue(_:withHandler:)

Starts monitoring absolute altitude and delivers updates to a specified queue.
NSOperationQueue
required
The operation queue on which to deliver altitude updates.
CMAltitudeHandler
required
The block to invoke with absolute altitude updates. The handler receives CMAltitudeData objects representing altitude above sea level.
Absolute altitude provides elevation above sea level when available from device sensors.

stopAbsoluteAltitudeUpdates

Stops monitoring absolute altitude updates.

stringForMotionAuthorization

Returns a string representation of the current motion authorization status.
Returns: A string describing the current authorization status for motion and fitness data (e.g., “authorized”, “denied”, “notDetermined”).

Implementation Example

Here’s an example implementation using CoreMotion:

Usage Notes

Motion activity and altitude monitoring require user permission. Request authorization before starting updates and handle denied or restricted states appropriately.
  • Battery Impact: Motion and altitude updates can significantly impact battery life. Stop updates when not needed.
  • Authorization: Check CMMotionActivityManager.authorizationStatus() before starting updates.
  • Queue Management: Use an appropriate operation queue for your app’s threading model. For UI updates, use OperationQueue.main.
  • Data Quality: Altitude data accuracy depends on device sensors and environmental conditions.

See Also