When a user first installs my widget, when they select "Edit Widget", I'd like a default choice to show up instead of "Choose." This is a dynamic intent and the options are retrieved from a network call.
In my IntentHandler, there are two functions I am playing with:
extension IntentHandler: MyIntentHandling {
func provideMyValueOptionsCollection(for intent: MyIntent, with completion: @escaping (INObjectCollection<MyValue>?, Error?) -> Void) { }
func defaultMyValue(for intent: MyIntent) -> [MyValue]? { }
}
I can get the options via a network call for provideMyValueOptionsCollection
by calling the completion handler once the values have been retrieved. But defaultMyValue
is synchronous, so it won't accept a closure return value from a network call (get error: Cannot convert return expression of type '()' to return type '[MyValue]'
). Is there a way to provide a default value obtained from a network call to the Edit Widget screen?