Our app explicitly blocks user form using remote-control, e.g., old springboard from pre-iOS7, earbud, by becoming the first responder to the remote-control events. However, on iOS7, the same code fails to bypass the control centre music controls.
From out tests, control centre seems to have bypassed ALL music control events including UIEventSubtypeRemoteControlPause and UIEventSubtypeRemoteControlPlay, and UIEventSubtypeRemoteControlTogglePlayPause.
Is it that control centre has its own protocol for remote control or that the way to intercept remote-control events has changed in iOS7?
The same blocking code still works perfectly with iOS6 devices. Here is what we do:
Added a method in our appDelegate:
(BOOL)canBecomeFirstResponder { return YES; }
Call this in applicationDidBecomeActive:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
// Set itself as the first responder [self becomeFirstResponder];
Call this in applicationWillResignActive
// Turn off remote control event delivery [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
// Resign as first responder [self resignFirstResponder];
Finally added
(void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent {
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(@"Received: UIEventSubtypeRemoteControlTogglePlayPause\n");
break;
case UIEventSubtypeRemoteControlPreviousTrack:
NSLog(@"Received: UIEventSubtypeRemoteControlPreviousTrack\n");
break;
case UIEventSubtypeRemoteControlNextTrack:
NSLog(@"Received: UIEventSubtypeRemoteControlNextTrack\n");
break;
case UIEventSubtypeRemoteControlPlay:
NSLog(@"Received: UIEventSubtypeRemoteControlPlay\n");
break;
case UIEventSubtypeRemoteControlPause:
NSLog(@"Received: UIEventSubtypeRemoteControlPause\n");
break;
case UIEventSubtypeRemoteControlStop:
NSLog(@"Received: UIEventSubtypeRemoteControlStop\n");
break;
default:
NSLog(@"Received: Some remove control events\n");
break;
}
}
}
Any pointer will be appreciated.