Documentation Search
Godot Apple Plugins Class

CMPedometer

Inherits: RefCounted < Object

Step, distance, and floor counts from the system pedometer.

Description

Wraps Apple’s CMPedometer. Supports both historical queries (already-recorded data from the system) and live updates.

Requires the ``NSMotionUsageDescription`` Info.plist key. On iOS the system records pedometer data continuously while motion permission is granted, so query_pedometer_data() can return data even from before your app launched.

Platform availability: Real implementation on iOS. On other platforms the is_*_available static methods return false and calls report unavailability through their callback or pedometer_failed.

See Apple’s CMPedometer reference.

Tutorials

Methods

int

authorization_status() static

bool

is_cadence_available() static

bool

is_distance_available() static

bool

is_floor_counting_available() static

bool

is_pace_available() static

bool

is_step_counting_available() static

void

query_pedometer_data(fromUnixTime: float, toUnixTime: float, callback: Callable)

void

start_updates(fromUnixTime: float)

void

stop_updates()


Signals

pedometer_failed(message: String) 🔗

Emitted when CoreMotion reports an error on a live updates stream, or when the API is unavailable on the current platform.


pedometer_updated(data: CMPedometerData) 🔗

Emitted on the main thread with the latest cumulative pedometer reading since start_updates() was called.


Method Descriptions

int authorization_status() static 🔗

Returns the current authorization status using Apple’s CMAuthorizationStatus integer (0 = notDetermined, 1 = restricted, 2 = denied, 3 = authorized).


bool is_cadence_available() static 🔗

Returns true when the device can report cadence.


bool is_distance_available() static 🔗

Returns true when the device can estimate walked/run distance.


bool is_floor_counting_available() static 🔗

Returns true when the device can count floors ascended/descended.


bool is_pace_available() static 🔗

Returns true when the device can report pace.


bool is_step_counting_available() static 🔗

Returns true when the device can count steps. Step counting is the minimum requirement for any pedometer functionality.


void query_pedometer_data(fromUnixTime: float, toUnixTime: float, callback: Callable) 🔗

Queries pedometer data recorded between two Unix-time stamps. callback is invoked on the main thread with callback(data: CMPedometerData, error: String); data is null when error is set.


void start_updates(fromUnixTime: float) 🔗

Begins live pedometer updates accumulating from fromUnixTime (Unix seconds). Subsequent samples arrive via pedometer_updated. Use Time.get_unix_time_from_system() for “now”.


void stop_updates() 🔗

Stops live pedometer updates.