如何从通知中心删除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:)))
}发布于 2019-09-13 17:28:30
如果我们使用endReceivingRemoteControlEvents(),它将从通知中心消失
https://stackoverflow.com/questions/57918609
复制相似问题