Widget timeline policy not working

I want to create a widget that updates every 15 minutes.

Here is my code:
Code Block
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:
Code Block language
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.

Replies

I would like to edit my question, but leave comments because it is impossible over time.
The above test succeeded after 15 minutes, but when set to 15 seconds, the desired result did not appear.

Here is my code:
Code Block language
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
    let currentDate = Date()
    print("@@timeline update. \(currentDate)")
    let next = Calendar.current.date(byAdding: .second, value: 15, to: currentDate)!
    let entry = FavoriteEntry(date: currentDate, item: mock_favorite)
    let timeline = Timeline<FavoriteEntry>(entries: [entry], policy: .after(next))
    completion(timeline)
  }


Result:
Code Block language
@@timeline update. 2020-07-19 07:28:47 +0000
2020-07-19 16:28:47.774261+0900 FavoriteExtension[12379:3302686] libMobileGestalt MobileGestaltCache.c:38: No persisted cache on this platform.
@@timeline update. 2020-07-19 07:28:47 +0000
@@timeline update. 2020-07-19 07:28:47 +0000
@@timeline update. 2020-07-19 07:28:47 +0000
@@timeline update. 2020-07-19 07:33:47 +0000
@@timeline update. 2020-07-19 07:33:47 +0000


I set it to 15 seconds, but why was it updated after 5 minutes?
Hi  amiability32, In order to ensure system performance and battery life widget updates are coordinated via a scheduler. Updating every 15 seconds would be far too frequent, so the system spaces the updates apart.
So what is the minimum timeline should we set? is 1 hour OK?
I think Apple is still deciding what this number should be and it is changing between betas. My hope is that at least a few times an hour should be possible.

I am in a a similar situation, similar to others in past.

BUT while debugging can we honestly WAIT 15 mins for every modification? not good.

At minimum today, 20 minutes between refreshes should keep you from hitting your daily limit. You can have as many entries as you'd like in each timeline so you shouldn't see a difference between refreshing every 15 or 20 minutes.