user3723595
user3723595

Reputation: 33

IntentHandler doesn't update

I have configurable widget with dynamic options. The user can select different options like "Widget1" or "Widget2" (image). The data are provided by UserDefault and can be modified in the main app.

When I change tеxt for "Widget1" in the main app and do an update to widget (WidgetCenter.shared.reloadAllTimelines()), the widget doesn't update its view and also selected option ("Widget1") is not selected anymore, until I select it again (and it will show the data I need).

Is it possible to update IntentHandler?

Any ideas are welcome! Thank you

IntentHadler file:

    class IntentHandler: INExtension, ChooseWidgetIntentHandling {
    
    func provideStylingOptionsCollection(for intent: ChooseWidgetIntent, with completion: @escaping (INObjectCollection<Styling>?, Error?) -> Void) {
        
        let stylingConfiguration: [Styling] = Widget.array.map { widget in
            let styling = Styling(identifier: widget.name, display: widget.name)
            styling.text = widget.text
            styling.category = widget.category as? NSNumber
            
            return styling
        }
        
        let collection = INObjectCollection(items: stylingConfiguration)
        
        completion(collection, nil)
    }
  1. Selected option - image
  2. After I changed data (text) and updated widget nothing changed - image
  3. Selected option ("Widget1") is not selected anymore - image
  4. When I select option it shows the data, that I need - image

Upvotes: 1

Views: 598

Answers (1)

user3723595
user3723595

Reputation: 33

Solution: after a few desperate weeks, I didn't find a solution, but I made it work. I'm changing the options of configuration in func getTimeline. To avoid making changes to all configurations (widgets in my case) I check the current configuration with a unique identifier (just one of my options, it can be a name of configuration or something like that) and change it only for one configuration.

Upvotes: 0

Related Questions