iOS widgets allow an app to provide instant access to meaningful data. They stay on the phone's home panel acting as glanceable windows into your app.
Simon Støvring's Scriptable uses iOS widget concept to enable iOS automation written in ECMAScript 6. Scriptable acts as the parent container app for your custom Javascript widget.
iOS reloads widgets periodically to update widget data. Update frequency depends on your usage pattern with faster reloads for frequently used apps. When your script uses location services, iOS reloads it after a significant location change.
This got me thinking - can I use the significant location change service to build a mileage expenses logger as a widget? The logic would be something like:
A quick prototype script is at https://gist.github.com/joyanujoy/19831b8849848f999e71333f15b94d40
Widget UI with light and dark modes:
The experiment didn't work as I had hoped. It appears iOS stops location updates to the widget if you haven't used it recently. See Accessing Location Information in Widgets. The need for opening the widget frequently prevents it from acting as a background geolocation logger.
Looks like I will need to build a native iOS app for logging mileage in the background. On the plus side, I could use the app to demo my geo filter API.