[tags:wwdc20-10028]

146 results found

Post

Replies

Boosts

Views

Activity

Widget and Apple Health refresh rate
Hi there, If the Widget we are developing uses activity data from the Apple Watch via HealthKit, e.g. Active Energy, how can our App read up to date data from Healthkit when it is in the background. And if so how often does the widget refresh. As an experiment I’ve been looking at the Apple Activity widget provided in the ios14 beta, but it out of sync with the Apple Watch activity data over more than a 15 minute duration. I.e the widget had not updated for at least 15 minutes even though the Apple Watch Activity data is constantly updating. many thanks Tim
2
0
1.5k
Jun ’20
Reply to Widget and Apple Health refresh rate
I agree the Widget constraints are a joke. I can update the resource constrained apple watch but I can't update the BIG Battery phone that might even be plugged in. It's kind of a mess. But the apple watch did take several years to make it usable. Maybe it will do what it should have in iOS 17.4 I want to display a burst of detailed information (up to the second) that periodically occurs at unpredictable times. Like what if waze wanted to pop something on a widget about a road side emergency. But your out of budget. Or what if you have buy order on stock reaching a trigger. Updates every 15 minutes is crazy. I just coded up the UI portion of a Widget and started looking into the refresh methodology and was seriously disappointed and will probably dump the whole idea of offering a Widget. It's useless.
Jan ’21
How often do I schedule Widget updates?
Classically, the demo in the Meet WidgetKit video used a Calendar as an example, where clearly the times to update are simple to calculate based on when the users events will occur. I'd like to know about the Activity/Fitness Widget. There's no way to tell when a user will burn that next calorie and as far as I can tell, there's still no background observer in HealthKit you can use to call an update on changes. So, with that in mind, how often should I call to update? This same dilemma applies to ClockKit and WatchOS complications.
4
0
2.4k
Jun ’20
Reply to How often do I schedule Widget updates?
Edorphy, I'm not sure I can really comment on iOS 12.2, though I suspect Apple will only really investigate bugs with iOS 14 currently.... I've not bothered with a HKObserverQuery in the end as I wasn't able to get it to work reliably. Instead I just use the Widget update callbacks to do fresh HKSampleQueries. Regards Simon
Jan ’21
WidgetKit background like the system battery widget
Hello, is it possible to configure our widgets with a background like the inbuilt system battery widget? It looks like it's using a UIVisualEffectView as it's background which looks fantastic against the user's background. Especially as it transitions for dark mode. I've been through all the docs and designing for WidgetKit but can't figure out how to have anything but a fully opaque background. Setting the background to transparent on my SwiftUI view results in white showing as the background. Thanks, Greg
19
0
6.7k
Jun ’20
Reply to WidgetKit background like the system battery widget
I ran into this problem too. If you set your padding at the top or bottom too small you see the white canvas of the widget show through. I use a view background of black for instance (using below .background attached to the greatest View). I also noticed that the Preview in Xcode and the actualy rendered widget in the Simulator are not exactly the same. One can see the corners show up in the Preview but in the simulator they are gone. I think probably the only way around this is to use a padding sufficient enough to overlap those 'gaps'. which is messy. and probably a reason why Apple has some 'design' recommendations including a padding of 15px. EDIT: I just found the way to do it. You need to include Spacer() in the VStack to stretch to max size of canvas and similarly for the HStack if you are having gaps. This solved it for me...
Dec ’20
Display UIViewRepresentable in WidgetKit
Hi, I'm trying to Display a MapView like the sytem Maps app does in a Widget. I thought the best way would be to encapsulate the Mapview in a UIViewRepresentable like this: struct MapView: UIViewRepresentable { func makeUIView(context: UIViewRepresentableContext<MapView>) -> MKMapView { let mapView = MKMapView() return mapView } func updateUIView(_ view: MKMapView, context: UIViewRepresentableContext<MapView>) { } } And show it like this in my Widget: struct MapWidgetEntryView : View { var entry: Provider.Entry var body: some View { VStack { MapView() } } } Unfortunately this leads to this error: RemoteHumanReadableError: The operation couldn’t be completed. (BSServiceConnectionErrorDomain error 3.) BSServiceConnectionErrorDomain (3): ==BSErrorCodeDescription: OperationFailed I also tested this with other UIKit classes and it leads to the same error
2
0
2.1k
Jun ’20
Reply to Display UIViewRepresentable in WidgetKit
I've tried MKMapSnapshotter in the TimelineProvider as suggested in the accepted answer, but the completion handler of the start is never called (snapshot is a MKMapSnapshotter object and I have verified that the callback is called when this code runs on the actual app and not the widget TimelineProvider. What am I missing? let image = snapshot?.image // Image(uiImage: snapshot?.image) completionHandler(image) }
Nov ’20
Reply to How often do I schedule Widget updates?
Simon, Did you have any success with HKObserverQuery and reloading the timeline? I have a workout app that has a workout widget. Presently, I have an observer query listening to .workoutType() and I set the background update frequency to .immediate. On iOS 12.2 RC for my iPhone XS, I keep seeing the observer query getting invoked second after second--even though there is no new workout being saved. Have you experience anything like this where the observer query is getting hammered with updates more than you expect? I'm guessing it is some bug where the HKObserverQuery is getting invoked as if the app was entering foreground, and the widget being on screen is somehow tripping this. I filed a FB on this unexpected behavior in case anyone at Apple sees this and wants more details. FB8887079
Nov ’20
Would a countdown or timer widget be possible?
WidgetKit looks great, I love that it's SwiftUI and lightweight. I'm just trying to see if I understood everything correctly by using an example: Widgets are not mini apps, but really freeze-dried SwiftUI view hierarchies that are then thawed out by the system as needed. That being the case, a developer could not build a countdown or timer widget that would show a label with the current, accurate-to-the-second value of the countdown or timer, correct? While I could imagine that to be a real-world use-case, I do understand that the home screen should not have a lot of things animating and moving, but to be calm.
6
0
5.5k
Jun ’20
Reply to Would a countdown or timer widget be possible?
After some trial and error, it seems that the widget will auto update the date displayed but no re-layout will be done. Causing text to be truncated with ... when the display date grows longer. For example when using .relative style, display date could change from 1 sec to 1 min 20 sec which is much longer. If the original space doesn't fit 1 min 20 sec then it may become 1 mi... which looks quite bad. Quick workaround is to try allocating more space to Text element in advance.
Oct ’20