Refresh Interval (Widget)

Can you actually control the refresh interval of the widget yourself or the system does that itself.
Example, I entered a new appointment, how long will it take for it to be displayed in the widget?
Many Thanks

It is refreshed by the system.

It is also worth searching for the info. This question comes up a fair bit across the Internet at the moment, and I think the last mention on here was just a couple of days ago.


Because this does come up frequently, just for the heck of it, I wrote a script that writes a log to iCloud on every refresh. I ran for a bit with and without a “refreshAfterDate” statement. Take these results with a grain of salt:

WIthout refreshAfterDate, I saw a swing of anything from 4 minutes to as long as 7 minutes between refresh.

With a refreshAfterDate set at 30 seconds, I saw a swing from 61 seconds to about 3 minutes. I did see a handful of longer delays, but I think those are all from when the phone was asleep.

I didn’t do a lot of testing, but it does seem as though setting a refreshAfterDate does increase the refresh frequency a bit.

Here’s my test code (it creates a file called “log.txt” in the scriptable folder on iCloud.

// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-gray; icon-glyph: server;

let widget = simpleWidget()
function simpleWidget(){
	let w = new ListWidget()
	let nextRefresh = + 1000*30 // add 30 second to now
	w.refreshAfterDate = new Date(nextRefresh)
	let myGradient = new LinearGradient()

	w.backgroundColor = new Color("#933")
	myGradient.colors = [new Color("#44444466"), new Color("#88888855"), new Color("#66666655")]
	myGradient.locations = [0,0.8,1]
	w.backgroundGradient = myGradient
	let title = w.addText(logMessage("test_message"))
	title.textColor = Color.white()
	title.font = Font.semiboldSystemFont(10)
	title.minimumScaleFactor = 0.5

 return w

function logMessage(theMessage){
	let oldData = ""
	let logManager = FileManager.iCloud()
	const logPath = logManager.joinPath(logManager.documentsDirectory(), "log.txt")
	if (logManager.fileExists(logPath)){
		oldData = logManager.readString(logPath)+"\n"
	let logTime = new Date()
	oldData += + " : " + logTime.toLocaleDateString('en-US') + " " +logTime.toLocaleTimeString('en-US') + " : "+theMessage
	return logTime.toLocaleTimeString('en-US')

If you are interested in the details of how widgets are updated, it is covered in the Apple Developer documentation, though it is of course generic and provides no specifics for Scriptable.

(updating widget content section)
1 Like