Search code examples
iosobjective-ccocoa-touchuikituiresponder

Custom remote event handling in app from iOS lock screen


How does spotify handle custom remote events? Currently on iPhone 6 running iOS 8.1.3 and spotify version 2.4.0.1822 I get the following controls on the lock screen when I turn on spotify radio. Ive tried reading all docs pertaining to remote events, and I'm unable to find any resources which allow custom remote events from the lock screen.

enter image description here enter image description here


Solution

  • Maybe that is implemented with MPRemoteCommandCenter. Here is example...

    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)];
    

    Implement this code, play music on your app, and lock your iPhone. You will probably see a customized lock screen.

    Note - Menu can be customized label, but it can not customize icon image and number of row.