如何从通知中心移除 MPRemoteCommandCenter

How to remove MPRemoteCommandCenter from Notification Center

如何从通知中心删除 MPRemoteCommandCenter.shared()。我试过这段代码,但只有命令和动作被禁用。我需要从通知中心删除完整的通知。当我们杀死应用程序时,它不会出现在通知栏中,我希望在移动到其他屏幕时完成同样的事情。

func removeCommanCenter() {

let commadCenter = MPRemoteCommandCenter.shared()

    commandCenter.previousTrackCommand.isEnabled = false
    commandCenter.nextTrackCommand.isEnabled = false
    commandCenter.playCommand.isEnabled = false
    commandCenter.pauseCommand.isEnabled = false
    commandCenter.changePlaybackPositionCommand.isEnabled = false

    commandCenter.nextTrackCommand.removeTarget(self, action: #selector(self.loadNextVideos))
    commandCenter.previousTrackCommand.removeTarget(self, action: #selector(self.loadPrevoiusVideos))
    commandCenter.playCommand.removeTarget(self, action: #selector(self.audioPlayerView.customPlayer?.togglePlay(_:)))
    commandCenter.pauseCommand.removeTarget(self, action: #selector(self.audioPlayerView.customPlayer?.togglePlay(_:)))
    commandCenter.changePlaybackPositionCommand.removeTarget(self, action: #selector(self.audioPlayerView.customPlayer?.handleChangePlaybackPositionCommandEvent(event:)))
}

它会从通知中心消失,如果我们使用endReceivingRemoteControlEvents()