Sorry to get back to this old issue.
We tested blocking iOS7 control centre music remote-control by intercepting remote control events, but control centre seems to have bypassed ALL music control events including UIEventSubtypeRemoteControlPause and UIEventSubtypeRemoteControlPlay, and UIEventSubtypeRemoteControlTogglePlayPause.
The same blocking code still works perfectly with iOS6 devices.
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? Here is what we do:
1. Added a method in our appDelegate:
- (BOOL)canBecomeFirstResponder {
return YES;
}
2. Call this in applicationDidBecomeActive:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
// Set itself as the first responder
[self becomeFirstResponder];
3. Call this in applicationWillResignActive
// Turn off remote control event delivery
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
// Resign as first responder
[self resignFirstResponder];
4. 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.