In my iOS 14 widget with a single custom intent, when the user selects one intent, then changes to another, my getTimeline method is called multiple times for each intent on each refresh - including previously-selected ones.
I would expect getTimeline to only be called with the currently-selected intent. Is there a way to check whether the intent is the currently-selected intent? I make a network request in the getTimeline method and I do not want to make multiple requests when the widget only shows one intent.
As an example, I downloaded the Emoji Ranger sample code and added a print statement to the getTimeline method. I then:
- Run the app and open it once.
- Add a widget to the home screen.
- Run the widget extension target on the simulator.
- Select the character Egghead.
- Select the character Cake.
This is what prints on the next widget refresh (usually ~15 mins):
- Timeline: nil
- Timeline: Optional("Egghead")
- Timeline: Optional("Cake")
Any help is much appreciated, thanks!