Alarmy (iOS app) has a neat feature that plays alarms even when in background. This is what their FAQ says about it:
Due to Apple's technical policy, applications are not authorized to ring if they are not running in the background. To prevent this, Alarmy is by default configured to constantly run in the background, and this may consume additional battery. You can save battery by going in to our in-app battery-saving mode, but note that in this configuration, alarms will not ring when the phone is in Silent or Do Not Disturb mode!
How can I write an app that can run in the background this way?