I have a watchOS WidgetKit complication that needs the user's location to show the nearest transit station, but the widget never gets location permission and CLLocationManager times out.
Setup:
NSWidgetWantsLocation = YES in Widget Extension's Info.plist
NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription in Widget Extension's Info.plist
Watch App successfully has location authorization
Problem:
The system never presents a location permission prompt for my widget. Apple's own World Clock widget does get one on watchOS (see screenshot) — I can't figure out what triggers it.
When the widget tries to get location via CLLocationManager, the request times out and never returns a location.
Questions:
What triggers the system location prompt for a watchOS widget? Is NSWidgetWantsLocation sufficient or is something else required?
Why would CLLocationManager time out and never return a location inside a widget extension? Is there a specific pattern required for requesting location in a WidgetKit timeline provider?
Screenshots
Sorry for swedish, but it says "Do you allow widgets from World Clock to use your location services?"
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
WatchKit
watchOS
Core Location
WidgetKit