I tried to set up a periodic timer in a Glance view. It works in the simulator on some devices, but on other devices such as Fenix 6S, it seems like the timer callback is never called.
I tried to set up a periodic timer in a Glance view. It works in the simulator on some devices, but on other devices such as Fenix 6S, it seems like the timer callback is never called.
If you look in the simulator.json for the f6s, you'll see this
"liveUpdates": false
On many devices, that will be true.
I'm thinking you want to update the screen with WatchUi.requestUpdate()
Here's what that means. See https://developer.garmin.com/connect-iq/core-topics/glances/#glances and Live UI Update and Background UI Update
For further context and for anyone who didn't click on the doc link:
- When a device supports live (glance) updates, glance views can be updated once per second and calls to WatchUi.requestUpdate() will be respected
- When a device doesn't support live glance updates, for glance views, WatchUi.requestUpdate() will be ignored and the system will update the view no faster than every 30 seconds
(Ofc this only applies to devices which support glances in the first place.)
In a device's simulator.json file, the JSON field which corresponds to live glance updates is glance.liveUpdates (or simply search for "liveUpdates":)
Note that the linked docs claim that music devices support live glances and non-music devices do not. While this is true in most cases, there's a few exceptions:
- first-gen MARQ devices support music, but live glance updates are not supported, according to simulator.json
- fr255 (not fr255m) lacks music support, but live glance updates are supported
- fr165 (not fr165m) lacks music support, but live glance updates are supported
(There may be other exceptions, I haven't checked)
In general it's better to check simulator.json (as jim_m_58 said) and/or test the glance update behavior in the sim.
There's no explicit way to programmatically check for live glance update support in the API, so if you need different versions of your glance view for devices which support live updates and devices which do not, you'll need to hardcode that logic in your app (e.g. using jungle exclusions or hardcoded device checks in your app.)
For example, I have a stopwatch app which shows the live stopwatch timer in the glance view, but only for devices which support live glance updates. (It would be misleading that show a frozen timer for the non-live update devices, imo.) So I hardcoded the list of devices which support live glance updates in my app, based on simulator.json. Ofc, maybe another way I could've done this would be to just show the app name and icon on the first update, and only show the timer on the second update (as long as it was within 2 seconds of the first one.) But I figured that wouldn't be the best UX, and it might not be a foolproof method of detecting whether live updates are enabled (what if the user quickly scrolls up and down through the glance list, somehow causing the app glance to be updated more quickly than normally possible.)
(NOTE: at one point there was actually an error where the original Enduro was configured in simulator.json as supporting live updates, but in reality, it doesn't support them. I only mention this because you can't always rely on the simulator to be configured correctly.)