Partial fix for widgets & complications not showing correctly

I recently raised this post explaining how I couldn't seem to get watchOS 9 complications to work, and I've figured out a partial fix.

The original post details the issues with complications - and some are still valid - but this fix applies to both my complications and Home Screen / Lock Screen widgets.

I was following the various WWDC 2020/2022 videos and the Emoji Rangers sample code, adding bits here and there, and assuming they were completely valid. Sadly, this bit of code in the widget's dynamic intents IntentTimelineProvider getTimeline really just banjaxed everything:

// Create entries for one day, 15 minutes apart
let currentDate = Date()
for minuteOffset in stride(from: 0, to: 60 * 60 * 24, by: 15) {
	let entryDate = Calendar.current.date(byAdding: .minute, value: minuteOffset, to: currentDate)!
	entries.append(EventEntry(date: entryDate, event: event))
}

If I remove that, and generate a different timeline with specific dates and times (for example: now, in 10 mins, in 2 hours, in a day, etc.) the complications appear correctly, as do Home Screen and Lock Screen widgets.

The outstanding issues with complications are:

  1. The previews all use the same data, but getSnapshot() is supposed to return the data specific to that event from the configuration, i.e. if let theId = configuration.event?.identifier. "Christmas" is correct, but "Gallery Opening" is using Christmas's data.

  1. Once I've selected the event I want to use in a complication the edit screen shows it as totally blank, not even a placeholder:

I hope this little fix works for you guys. And, if you know how to fix the above issues, let me know.

(iOS 16.1 beta 1, Xcode 14.1 beta 1)

Post not yet marked as solved Up vote post of darkpaw Down vote post of darkpaw
1.9k views

Replies

I had already answered these questions on other question which author still you. Maybe you can try like this:

1.For question one, I'm also having this problem, and code is right definitely. Finally resolved by upgrading the watchOS version. Now watchOS version upgrade to 9.1(20S75) from 9.0.xx. ( iOS Version is 16.0, Xcode version is 14.0.)

2.When edit the complication, getSnapshot will called and return the entry. In my situation, the logic in getSnapshot and getTimeline almost same, except return different value. So you can try.

  • Your answers are literally: 1) Everything will fix itself after the update. 2) Just return the same value from getTimeline and getSnapshot. --- First they makes no sense, they're irrational, second none of them work. So instead of "I had already answered" it would be better to say "I had tried to answer".

Add a Comment