How to monitor Spotify playback status when app is in background?

Hey everyone,

I’m working on an app that tracks what’s playing on Spotify. Right now, I’m using the Player model to check for changes and log the current song. It works fine when the app is open, but I’ve noticed a problem. When I switch to another app, it keeps working for about a minute, then stops. I’m guessing the system is putting my app to sleep or something.

Does anyone know how to keep my app running in the background so it can keep tracking songs? I’ve tried a few things but no luck so far. Any tips or tricks would be super helpful!

Thanks in advance for any advice you can share!

have u tried using background modes? go to capabilities in xcode n enable ‘background fetch’ or ‘audio’. also look into ‘beginBackgroundTask(withName:expirationHandler:)’ to extend runtime. might need to use silent push notifications too for longer tracking. good luck!