I'm trying to find a working example of an app to background fetch a json document and then set a few datafields to values in the json. Is there anything out there that does this ?
I'm trying to find a working example of an app to background fetch a json document and then set a few datafields to values in the json. Is there anything out there that does this ?
Here's a whole thread about backgrounding, where this is discussed including a simple sample https://forums.garmin.com/developer/connect-iq/f/discussion/5287/very-simple-sample-of-a-watch-face-with-a-background-process
and a blog post about backgrounding in general https://developer.garmin.com/connect-iq/connect-iq-faq/how-do-i-create-a-connect-iq-background-service/#howdoicreateaconnectiqbackgroundservice
As far as an actual example of this, I'm not sure there are any, but once you understand how backgrounding works, and with tips in both these links, there's really not much to it. You do the makeWebRequest, and in the callback for that, do a Backround.exit() with the data you want to return to the main app.
There is the WebRequest sample in the SDK that demonstrates the basics of doing a makeWebRequest.
Thanks for the quick reply. Are you sure your 7 year old example code still works ? A lot has changed it seems.
Still works, though typechecking might complain (it was written long before type checking). I have a number of apps with background services, including a number that do makeWebRequests.
Here's a more recent watchface, where a background services is just one of the things it shows.