Post

Replies

Boosts

Views

Activity

What's the best way to emulate the Watch Activity Ring Reset?
Hi, I am working on a similar concept to when the Activity Ring resets at midnight, but I was wondering wha tis the best approach to take? Detecting the date change is not the issue. The tricky part that I see is that the device will probably be locked nor can I count on the app being in the background. I was looking at a few options that I do not believe will meet my needs: 1) A Silent Push Notification - The problem is that delivery is not certain by any means according to WWDC sessions / docs. 2) State Change - I can detect date change when user the user opens the app, is there a way to emulate the resetting the rings without the user having to launch the app? 3) Background Refresh - Now this is where I could be wrong, but from what I understand this is based on usage patterns fo the app only. So, I am not certain that I can count on this as well. So, I ask, any suggestions? Thanks.
0
0
674
Dec ’20
Widget works great in the Simulator, but not on the device.
Hello All, I have a Widget that is date based (updates at midnight) that works in the Simulator, but for some reason does not work on an actual device. I checked online and the suggestion that I found was to ensure that the OS version is the same, which they are, but still it's not working. Here's how I am testing on Simulator: 1) Set date time to 11:58. 2) Allow the system clock to roll over to midnight. 3) The widget updates - expected behavior. On Device: 1) Set screen auto lock to never. 2) Charge the phone. 3) Clock rolls to midnight, the Widget does not update. Which also brings me to my second question, is there a way to detect a Widget update when the phone is locked? Thank you
0
0
461
Dec ’20
WidgetKit: Refresh data based on a specific time?
Hi, Is it possible to dynamically update a Widget / show a View based on a specific time? For example, something like the following: func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { var entries: [SimpleEntry] = [] // Generate a timeline consisting of five entries an hour apart, starting from the current date. let currentDate = Date() // Get specific date / time to update then compare it to system's curren time. var components = DateComponents() components.hour = 12 components.month = 0 let midnight = Calendar.current.date(from: components) if midnight == currentDate { let entry = SimpleEntry(date: Date(), text: "", configuration: ConfigurationIntent()) entries.append(entry) let timeline = Timeline(entries: entries, policy: .atEnd) completion(timeline) } else { for hourOffset in 0 ..< 6 { let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! let entry = SimpleEntry(date: entryDate, text: update, configuration: ConfigurationIntent()) entries.append(entry) } let timeline = Timeline(entries: entries, policy: .atEnd) completion(timeline) } } } Thanks,
0
0
497
Nov ’20