Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Question about BGAppRefreshTask approach for medication scheduling app

I'm developing a medication scheduling app similar to Apple Health's Medications feature, and I'd like some input on my current approach to background tasks.

In my app, when a user creates a medication, I generate ScheduledDose objects (with corresponding local notifications) for the next 2 weeks and save them to SwiftData. To ensure this 2-week window stays current, I've implemented a BGAppRefreshTask that runs daily to generate new doses as needed.

My concern is whether BGAppRefreshTask is the appropriate mechanism for this purpose. Since I'm not making any network requests but rather generating and storing local data, I'm questioning if this is the right approach.

I'm also wondering how Apple Health's Medications feature handles this kind of scheduling. Their app seems to maintain future doses regardless of app usage patterns.

Has anyone implemented something similar or can suggest the best background execution API for this type of scenario? Thanks for any guidance you can provide.

Answered by DTS Engineer in 834962022

Lemme start you out with iOS Background Execution Limits. Please read that through and then come back with your follow-up questions.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Lemme start you out with iOS Background Execution Limits. Please read that through and then come back with your follow-up questions.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@DTS Engineer After reading your post on iOS Background Execution Limits it sounds like I can't rely on BGAppRefreshTaskRequest to ensure a scheduled dose window of 2 weeks for my users. That is because "... there are common scenarios where it won’t grant you any background execution time at all!".

How does Apple's Medications app ensure this 2 week window along with Local Notifications? Do they have access to an api that I don't to make it possible?

I could always create an idempotent function that ensures the user's dosing schedule is generated when the app is loaded. But if the user doesn't open the app for awhile, Local Notifications will be exhausted and the user wont receive any more notifications until the app loads and updates the schedule. Do you understand my concern?

Question about BGAppRefreshTask approach for medication scheduling app
 
 
Q