获取点击事件锁定屏幕控制(MPRemoteCommandCenter)

问题描述 投票:1回答:1

我已经实现了播放音频的Avplayer。我使用MPRemoteCommandCenter在锁定屏幕上进行访问。我可以通过以下方式访问:

    let commandCenter = MPRemoteCommandCenter.shared()

    commandCenter.pauseCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
        //Update your button here for the pause command
        return .success
    }

    commandCenter.playCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
        //Update your button here for the play command
        return .success
    }

但我想检测用户何时从锁定屏幕点击音乐标题或徽标或播放器。它打开我们的应用程序有可能得到吗?

当用户从锁定屏幕点击音乐播放器时,我想打开一个控制器。

ios swift lockscreen mpremotecommandcenter
1个回答
1
投票

您可以在应用程序激活时进行响应,但无法知道它已被激活,因为用户点击了锁定屏幕中的音乐播放器。

© www.soinside.com 2019 - 2024. All rights reserved.