I am working on an app that makes a custom alarm so I am using long music from outsourced platforms like Spotify, everything is done but the current issue is when I try to play the music when the phone is locked it doesn't work on a physical device but works on the simulator!, what I am doing is schedule a local notification to turn on the screen at this time then play the music from a scheduled timer.
Here is the snippet of the code responsible for this.
let timer = Timer(timeInterval: time.timeIntervalSinceNow, repeats: false) { timer in
// Doing the task here!
playAlarm()
}
RunLoop.current.add(timer, forMode: .common)
Note: To run this task when the phone is locked I am sending a local notification at this time to turn on the screen to make it possible to run this task.
Please let me know if this is possible as I see some apps doing this