Skip to content

Conversation

Wunsz
Copy link

@Wunsz Wunsz commented Aug 16, 2022

@christocracy Update activity key in MotionActivityEvent and migrate string to actual union type of possible activities.

Fixes #1523

@Wunsz
Copy link
Author

Wunsz commented Nov 10, 2022

@christocracy Any progress?

@rmacd
Copy link

rmacd commented Nov 28, 2022

Same here with v4.9.3 of plugin

TS definition:

interface MotionActivityEvent {
    activity: string;
    confidence: number;
}

Actual location object:

{
  "activity": {
    "confidence": 100, 
    "type": "unknown"
  },
  ...
}

Compiles with error TS2339: Property 'type' does not exist on type 'MotionActivityEvent'.

@tsachit
Copy link
Contributor

tsachit commented Dec 30, 2022

any update on this?

@transistorsoft transistorsoft deleted a comment from Wunsz Dec 30, 2022
@transistorsoft transistorsoft deleted a comment from rmacd Dec 30, 2022
@Wunsz
Copy link
Author

Wunsz commented Dec 30, 2022

@christocracy instead of removing our comments please read our code and either reject PRs with a valid reason or merge them in. We are trying to help and build this community.

@dziobakwszafie
Copy link

any update on this?

@christocracy
Copy link
Member

The typescript API is shared with two other versions of the plugin (cordova-background-geolocation and capacitor-background-geolocation). It can be troublesome to carelessly merge Typescript API changes without carefully testing against the other two versions of the plugin.

@tsachit
Copy link
Contributor

tsachit commented Jan 13, 2023

The typescript API is shared with two other versions of the plugin (cordova-background-geolocation and capacitor-background-geolocation). It can be troublesome to carelessly merge Typescript API changes without carefully testing against the other two versions of the plugin.

Did you test it?

@christocracy
Copy link
Member

This PR is insufficient. The problem is deeper.

The problem is that the schema of location.activity and the MotionActivityEvent delivered to onActivityChange are different though share the same MotionActivityEvent interface.

BackgroundGeolocation.onLocation((location) => {
  console.log('*** onLocation: ', location.activity);
});

BackroundGeolocation.onActivityChange((event) => {
  console.log('***onActivityChange: ', event);
});
- *** onActivityChange:    { confidence: 100, activity: 'running' }
- *** onLocation:               { confidence: 100, type: 'still' }

Also, the proposed type type Activity = 'still' | 'on_foot' | 'walking' | 'running' | 'in_vehicle' | 'on_bicycle'; does not account for the valid type "unknown".

I will close this and fix it myself.

@david-gettins
Copy link

@christocracy Did you fix this in the end? It seems as thought the Location type still uses the onActivityChange activity motion type.

@christocracy
Copy link
Member

This has not yet been released. It might be released tomorrow.

  • in onLocation, the docs will be changed to location.activity.type
  • in onActivityChange, it will be as currently documented: motionActivityEvent.activity

@david-gettins
Copy link

Thank you :)

@christocracy
Copy link
Member

This is now released to 4.9.5

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

Successfully merging this pull request may close these issues.

Invalid Typescript interface MotionActivityEvent
6 participants