CMMotionActivityManager¶
Inherits: RefCounted < Object
Classifies the user’s current activity (walking, running, automotive, cycling, stationary).
Description¶
Wraps Apple’s CMMotionActivityManager. The system continuously classifies user activity in the background while motion permission is granted, so query_activity() can return historical data even from before your app launched.
Requires the ``NSMotionUsageDescription`` Info.plist key.
Platform availability: Real implementation on iOS. On other platforms is_activity_available() returns false and calls report unavailability via the callback or activity_failed.
See Apple’s CMMotionActivityManager reference.
Tutorials¶
Methods¶
authorization_status() static |
|
is_activity_available() static |
|
void |
query_activity(fromUnixTime: float, toUnixTime: float, callback: Callable) |
void |
|
void |
Signals¶
activity_failed(message: String) 🔗
Emitted when the API is unavailable on the current platform.
activity_updated(activity: CMMotionActivity) 🔗
Emitted on the main thread when the user’s classified activity changes.
Method Descriptions¶
int authorization_status() static 🔗
Returns Apple’s CMAuthorizationStatus integer (0 = notDetermined, 1 = restricted, 2 = denied, 3 = authorized).
bool is_activity_available() static 🔗
Returns true when the device has a motion coprocessor capable of activity classification.
void query_activity(fromUnixTime: float, toUnixTime: float, callback: Callable) 🔗
Returns historical activities recorded between two Unix-time stamps. callback is invoked on the main thread with callback(activities: Array, error: String); activities is an array of CMMotionActivity.
void start_activity_updates() 🔗
Begins live activity updates delivered via activity_updated. The signal fires whenever the classified activity changes.
void stop_activity_updates() 🔗
Stops live activity updates.