gpt4 book ai didi

ios - 如何从通知中心删除 MPRemoteCommandCenter

转载 作者:行者123 更新时间:2023-11-29 05:28:28 25 4
gpt4 key购买 nike

如何从通知中心删除 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(),它就会从通知中心消失

关于ios - 如何从通知中心删除 MPRemoteCommandCenter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57918609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com