Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMMotionActivity] The motion-related properties of this class aren’t mutually exclusive. #1408

Open
sikandernoori opened this issue Jan 15, 2025 · 0 comments

Comments

@sikandernoori
Copy link

sikandernoori commented Jan 15, 2025

Environment

  • Plugin version: 4.16.6
  • Platform: iOS
  • OS version: 18

Expected Behavior

Hello,

I’m using the plugin to access motion activity data, and I’ve noticed a potential discrepancy between the plugin's reported activity type and the native CMMotionActivity class in iOS. According to the documentation for CMMotionActivity, the properties like stationary, walking, running, automotive, cycling, and unknown aren’t mutually exclusive. This means that multiple properties can be true at the same time, depending on the situation. Apple Documentation

Here’s an example of the CMMotionActivity class properties:

open class CMMotionActivity : CMLogItem {
    open var confidence: CMMotionActivityConfidence { get }
    open var startDate: Date { get }
    open var unknown: Bool { get }
    open var stationary: Bool { get }
    open var walking: Bool { get }
    open var running: Bool { get }
    open var automotive: Bool { get }
    @available(iOS 8.0, *)
    open var cycling: Bool { get }
}

Actual Behavior

However, when using the plugin to get motion activity within the Location object, we currently receive a single activity type (e.g., still, walking, on_foot, running, on_bicycle, in_vehicle, unknown) along with the confidence level.

Steps to Reproduce

bg.BackgroundGeolocation.onMotionChange((bg.Location location) {
    print('[motionchange] - $location');
});

The Activity class in the plugin captures the motion type and confidence, but it does not expose the other potential activity states:

class Activity {
  /// The reported device motion activity.
  late String type;

  /// Confidence of the reported device motion activity in %.
  late int confidence;

  Activity(dynamic activity) {
    this.type = activity['type'];
    this.confidence = activity['confidence'];
  }
}

Context

For example, if the user was driving in a car and the car stopped at a red light, the update event associated with that change in motion would have both the automotive and stationary properties set to true. It’s also possible for all of the properties to be set to false when the device is in motion but the movement doesn’t correlate to walking, running, cycling, or automotive travel.

My Question:

Is it possible to access all properties of CMMotionActivity (e.g., stationary, walking, automotive, cycling, unknown) using this plugin?

Additionally, would it be possible to modify the plugin to return all the values (i.e., multiple properties of the CMMotionActivity object that could be true simultaneously), rather than just the single type value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant