Search code examples
swiftios8-today-widgettoday-extension

widgetPerformUpdateWithCompletionHandler called just once


I am implementing a today extension where I take some time to load the needed information, yet I found widgetPerformUpdateWithCompletionHandler is called just once finding no data and never afterwards to find the updated data; this is the piece of code I use:

func widgetPerformUpdateWithCompletionHandler(
    completionHandler: ((NCUpdateResult) -> Void)!) {
        downloadCloseBuses({(data, error) in
            self.resetContentSize()
            let process:NCUpdateResult=self.busCollection.count()>0 ? .NewData: .NoData
            completionHandler(process)
        })
}

Solution

  • I ended up saving the closure and calling it each time new data was available.