My widget is supposed to connect to a server and fetch data every five minutes. Instead of being called for a new timeline after five minutes, timeline(with context: Context, completion: @escaping (Timeline<Self.Entry>) -> ()) method is called several times in a second. To figure out what I am doing wrong, I've simplified the method and added just a simple random number generator instead of calling the API.
The method is called several times in a second. I have no idea if I am doing something wrong or this is a bug in iOS 14?
Code Block func timeline(with context: Context, completion: @escaping (Timeline<Self.Entry>) -> ()) { let currentDate = Date() let futureDate = Calendar.current.date(byAdding: .minute, value: 5, to: currentDate)! let timeline = Timeline(entries: [ Entry(date: currentDate, city: "\(Int.random(in: 0...10))"), ], policy: .after(futureDate)) completion(timeline) }
The method is called several times in a second. I have no idea if I am doing something wrong or this is a bug in iOS 14?