Hello everyone,
I’m developing an alarm app in Swift 5, and I’m running into an issue with playing custom alarm sounds. Here’s the setup:
I’m using AVAudioPlayer to play a custom sound when the alarm goes off.
I’m triggering the alarm through a local notification, which works perfectly while the app is in the foreground.
However, when the app is in the background or the screen is locked, the custom alarm sound doesn’t play.
I’ve looked at other apps on the App Store, like Alarmy, which seem to play alarms even when the iPhone is locked or the app is in the background. I’m trying to achieve similar functionality but haven’t been successful.
If anyone has experience with creating alarm apps or has a workaround for playing sounds in the background/lock screen, I’d really appreciate your insights. Are there specific permissions or settings I need to enable, or a different approach to handling sound playback?
Thank you so much in advance for your help!