1

I know how to use background refresh and methods to get data after some time interval.

Is there any possibility so that I can refresh data in 1hr of range in morning time? even if app will not open every day once.

Can I update background refresh time interval at completion of refresh method?

KrishnDip
  • 81
  • 10

1 Answers1

0

BackgroundTasks API which available from iOS 13 can create BGTaskRequest objects(BGAppRefreshTaskRequest or BGProcessingTaskRequest) for scheduling background tasks via BGTaskScheduler.

BGTaskRequest has earliestBeginDate property for schedule task at desired time. But this is just hint. IOS haven't 100% guarantee that it schedule task at this time.

  • Ok. I agree earliestBeginDate is the way to set time interval when iOS will begin background task. But in this scenario app needs to be open at least once a day, so that we can set approx time interval by calculation with current date. But what if user do not open app for 2-3 days. Is it possible to achieve? – KrishnDip Jun 07 '21 at 16:40
  • No, you can schedule next task from background for next date/time. – Dmytro Hrebeniuk Jun 07 '21 at 17:55
  • so at every completion of refresh task, I need to calculate timestamp for morning and re schedule new task. right? – KrishnDip Jun 09 '21 at 16:43