首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从通知中心删除MPRemoteCommandCenter

如何从通知中心删除MPRemoteCommandCenter
EN

Stack Overflow用户
提问于 2019-09-13 14:51:00
回答 1查看 974关注 0票数 0

如何从通知中心删除MPRemoteCommandCenter.shared()。我尝试过此代码,但只有命令和操作处于禁用状态。我需要从通知中心删除完整的通知。当我们删除应用程序时,它不会出现在通知栏中,我希望当我移动到其他屏幕时也能做同样的事情。

代码语言:javascript
复制
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:)))
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-13 17:28:30

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57918609

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档