来自 iOS 锁定屏幕的应用程序中的自定义远程事件处理

Custom remote event handling in app from iOS lock screen

Spotify 如何处理自定义远程事件?当前在 iPhone 6 运行 iOS 8.1.3 和 spotify 版本 2.4.0.1822 上,当我打开 spotify 收音机时,我会在锁定屏幕上看到以下控件。我试过阅读所有与远程事件有关的文档,但我找不到任何允许从锁定屏幕自定义远程事件的资源。

也许是用 MPRemoteCommandCenter 实现的。 这是示例...

MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[[remoteCommandCenter skipForwardCommand] addTarget:self action:@selector(skipForward)];
[[remoteCommandCenter togglePlayPauseCommand] addTarget:self action:@selector(togglePlayPause)];
[[remoteCommandCenter pauseCommand] addTarget:self action:@selector(pause)];
[[remoteCommandCenter likeCommand] addTarget:self action:@selector(like)];

执行此代码,在您的应用程序上播放音乐,并锁定您的 iPhone。您可能会看到一个自定义的锁定屏幕。

注意 - 菜单可以自定义标签,但不能自定义图标图片和行数。