If you are trying to make your audio app use control center (like spotify does) you need to use the MPNowPlayingInfoCenter to set the now playing item data (like:title, rate, duration, elapsedTime,...) it will be something like that:
MPNowPlayingInfoCenter.default().nowPlayingInfo = [
MPMediaItemPropertyTitle: title,
MPMediaItemPropertyArtist: artist,
MPNowPlayingInfoPropertyElapsedPlaybackTime: position,
MPMediaItemPropertyPlaybackDuration: duration,
MPNowPlayingInfoPropertyPlaybackRate: rate,
]
this will set the data of the played audio item in the media control center now in order to be able to use the controls button need to use the MPRemoteCommandCenter and set the target for each command you want to use for example for play/pause actions it can be done like that:
MPRemoteCommandCenter.shared().playCommand.addTarget(handler: playActionHandler)
MPRemoteCommandCenter.shared().pauseCommand.addTarget(handler: pauseActionHandler)
once all of this is done you will need to call the method bellow in order for your app to be able to receive the remote events and execute the needed action
UIApplication.shared.beginReceivingRemoteControlEvents()