Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Device API: User-Activity

ANSWERED

I'm creating a watch face and was trying to include steps (and likely other device oriented api data). I saw a post on here about a similar issue, however i think my question may be based upon permissions possibly.

Here is a snippet:

import * as ua from "user-activity";
console.log(JSON.stringify(ua));

This is the output in the console:

[9:25:05 PM]{"today":{"local":{"adjusted":true},"adjusted":{"adjusted":true}},"goals":{}}

I'm not certain why there isn't more to this object. I've also ran a more specific import but with no better results:

import { today } from "user-activity";
console.log((today.local.steps || 0) + " steps");

 

Thanks in advance.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Try this:

 

import userActivity from "user-activity";
const metric = "steps";  // distance, calories, elevationGain, activeMinutes
const amount = userActivity.today.local[metric] || 0;
console.log(amount);

View best answer in original post

Best Answer
5 REPLIES 5

Try this:

 

import userActivity from "user-activity";
const metric = "steps";  // distance, calories, elevationGain, activeMinutes
const amount = userActivity.today.local[metric] || 0;
console.log(amount);
Best Answer

(Accidental Duplicate Message Removed)

Best Answer
0 Votes

I know this issue was marked solved, but this solution seems to have stopped working on the latest firmware update?

 

I'm getting undefined with that exact code snippet for steps.

Or am I perhaps missing more imports or setup the fetch the step count from user-activity?

Best Answer
0 Votes

lol, feel a bit like an idiot, but to possibly assist someone else running into this issue of mine..

 

Go to the package.json and enable the "Activity" permission.

Best Answer

Thank you!!!!! I couldn't figure that out for the longest time! I was seriously going crazy...

Best Answer
0 Votes