I want to create a widget that updates every 15 minutes.
Here is my code:
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
let currentDate = Date()
print("@@timeline update. \(currentDate)")
let next = Calendar.current.date(byAdding: .minute, value: 15, to: currentDate)!
let entry = FavoriteEntry(date: currentDate, item: mock_favorite)
let timeline = Timeline<FavoriteEntry>(entries: [entry], policy: .after(next))
completion(timeline)
}
Result:
timeline update. 2020-07-19 07:11:27 +0000
2020-07-19 16:11:28.005325+0900 FavoriteExtension[12206:3240076] libMobileGestalt MobileGestaltCache.c:38: No persisted cache on this platform.
@@timeline update. 2020-07-19 07:11:28 +0000
@@timeline update. 2020-07-19 07:11:28 +0000
@@timeline update. 2020-07-19 07:11:28 +0000
But My widget is not updated since it was first created.
Please let me know what I did wrong.