Is it possible to make a battery level widget using scriptable?

I tried to place a battery level indicator on a widget I was building using the Device.batteryLevel() function but noticed that it did not reflect the true battery level as it was not updating like the native iOS battery widget did. I know we can use the refreshAfterDate to manually refresh the widget to an extent but my concern with that is, it might impact the users battery consumption. Has anyone tried making a battery widget with scriptable? Or have any suggestions?

While it is possible. it will not be on-par with the true battery level - even if you use refreshAfterDate. This is because the IOS will ultimately decide when to update the widget. refreshAfterDate only signals the system that it’s ready for a refresh but it doesn’t mean it will be done immediately.

1 Like

Yeah that makes sense. Thanks man

There is an example in the Scriptable Examples… from there i have extract a piece of code that i have added in my alarm script.
To update the widgets i use a shortcut which works very fast.


1 Like

That’s really smart. Thanks!