I am attempting to use the lock screen/now playing controls for my app but am not receiving any events. The documentation makes it seem pretty straight forward so I was a bit a surprised when I didn't get any results. My app needs to receive the remote control events for purposes outside of playing audio on the device. I tried to test this by just having it print out some confirmation with NSLog. Do I need to be using an audio or media framework that wasn't mentioned in the documentation? I am not receiving any warnings or errors so I don't think there should be any issues with that... Any insight concerning why the remote control events aren't registering would be greatly appreciated
Here is the relevant code:
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//Register for lock screen controls
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
//Unregister lock screen controls
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
- (BOOL)canBecomeFirstResponder{
return YES;
}
//Lock screen controls
- (void)remoteControlReceivedWithEvent:(UIEvent *)event{
NSLog(@"RECEIVED");
if (event.type == UIEventTypeRemoteControl) {
switch (event.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(@"RECEIVED");
break;
case UIEventSubtypeRemoteControlPreviousTrack:
NSLog(@"RECEIVED");
break;
case UIEventSubtypeRemoteControlNextTrack:
NSLog(@"RECEIVED");
break;
default:
break;
}
}
}