Search code examples
widgetios8ios-app-extension

iOS 8 today widget stops working after a while


I've made a today widget for the german ice hockey league DEL.

I'm loading the next games from our server an show them in a tableView. The loading process is started in the proposed method "widgetPerformUpdateWithCompletionHandler". Initially i'm loading some cached data in "viewWillAppear".

Everything works great so far!

Screenshot of the working widget.

But after a while (one day) the widget stops working. When I open the notification center the widget appears normal, but it is never updated again. I have to remove the widget from the notification center and have to add it again. After that the widget works for a day and then again it stops working.

To see what the widget ist doing, I've added a simple white view with a status text above the table view while loading the data in "widgetPerformUpdateWithCompletionHandler" to see if the widget is doing anything. The white view appears when the widget is working. When it is not working the status view doesn't appear. So I think the method "widgetPerformUpdateWithCompletionHandler" isn't called after the widget is active in the notification center for a while.

I've got no clue what causes the widget to stop working. Any ideas?


Solution

  • I've got the same problem and I resolved it by calling completionHandler(NCUpdateResultNoData); right after your network request even when the response hasn't been returned. I found that if completion handler is not called the widgetPerformUpdateWithCompletionHandler will no longer get invoked, and therefore there won't be any more updates. Also make sure you call completion handler in all branches after your request call returns.