Prior to iOS 7.1 the UIApplication’s beginReceivingRemoteControlEvents method needed to be called and remoteControlReceivedWithEvent implemented where you’d handle remote control events by the event type that is received. In iOS 7.1 MPRemoteCommandCenter is introduced. With command center it is much more convenient to handle the remote control events.
beginReceivingRemoteControlEvents method description:
Tells the app to begin receiving remote-control events.
In iOS 7.1 and later, use the shared MPRemoteCommandCenter object to register for remote control events. You do not need to call this method when using the shared command center object.
The MPRemoteCommandCenter shared instance should be used to handle remote control events sent by external accessories and system transport controls. For each type of remote control event (e.g. play, pause, etc.), there is a MPRemoteCommand object property (playCommand, pauseCommand, etc.). To respond to those events you simply register a handler with that appropriate MPRemoteCommand object.
MPNowPlayingInfoCenter is used to display additional information regarding a currently playing track.
To find out more check out the sample audio player application with lock screen controls written in Swift that is available on my GitHub repo: https://github.com/lukagabric/LGAudioPlayerLockScreen
If you liked this blog post I’d appreciate if you followed me on Twitter