Playing scheduled alarm sounds while app is in background

I'm making an app that has an alarm clock function that allows a user to set a time for their alarm sound to play. I've seen apps like Alarmy and Sleep cycle be able to play sounds for an indefinite period of time even when the app is in the background or the phone is on DND, with notifications silenced. How can I ensure that the alarm will play while in the background, assuming that the user does not terminate the app?

I've looked the multiple types of background tasks available to developers, but I'm not too sure on which one to use, and none of them seem to serve this purpose. I know it's possible because of the current apps on the app store but I'm not sure what approach they're using.

With silent push notifications, the task seems to only be allowed to run for 30 seconds. Preferably, the sound would play until the user stops it.