Hello! I'm trying to retrieve activity history data using the following code. This has been put together based on various posts in the dev forum. I'm not using the simulator for this and deploy my Watch Face through iConnect as a Beta version.
I have physically recorded, saved and synced activities on my Fenix 5S, so I know there is activity data. However, when I check for UserActivity using the has getUserActivity check, it returns FALSE.
I'm using SDK 7.2.1 on MacOS Sonoma 14.5 and a Fenix 5S. Minimum support API for my Watch Face is 3.0.0.
Here is the code I use for this. It sits in a function that is called from onUpdate().
Any guidance would be much apprectiated!
var hasActivityHistory = (Toybox.UserProfile.UserActivity has :getUserActivityHistory); if (hasActivityHistory == true) { var userActivityIterator = UserProfile.getUserActivityHistory(); var activityData = userActivityIterator.next(); while (activityData != null) { if (activityData.type == Activity.SPORT_WALKING) {walkDistance = walkDistance + activityData.distance;} //run if (activityData.type == Activity.SPORT_RUNNING) {runDistance = runDistance + activityData.distance;} //run if (activityData.type == Activity.SPORT_CYCLING) {cycleDistance = cycleDistance + activityData.distance;} //cycle if (activityData.type == Activity.SPORT_SWIMMING) {swimDistance = swimDistance + activityData.distance;} //swim activityData = userActivityIterator.next(); } }