How to show progress indicator when loading objects for widget configuration intent?

Viewed 18

In my application, a user can show widget configuration and change some options by selecting them from a dynamic list that is handled by Intents Extension, but first it must be downloaded from the backend.

Fetch may take some time and until it is finished nothing happens, the user still sees the configuration panel. Therefore, I would like to show some progress indicator, but I'm not sure if it is possible.

The automatically generated protocol MyIntentHandling from .intentdefinition file provides only two possible methods to handle this case: provideMyOptionsCollection and handle.

However, the first one doesn't provide completion to indicate progress and the second one is never called. Below those methods:

extension IntentHandler: MyIntentHandling {
    func provideMyOptionsCollection(for intent: MyConfigurationIntent, searchTerm: String?, with completion: @escaping (INObjectCollection<IntentData>?, Error?) -> Void) {
        // fetch...
        completion(INObjectCollection(sections: fetchedData))
    }

    func handle(intent: MyConfigurationIntent, completion: @escaping (MyConfigurationIntentResponse) -> Void) {
        return .init(code: .inProgress, userActivity: nil)
    }
}

I think that provideMyOptionsCollection should automatically show progress, because this methods is meant for asynchronous operations. Therefore, it is quite strange that the system instead of showing progress indicator, it does nothing.

Here is an example of the feature that I'm implementing:

0 Answers
Related