IOS remoteControlReceivedWithEvent not called

In .plist I added normal: http://tinyurl.com/c7e9joy And when the iPhone is locked or I'm outside the application and open the remote buttons, I see the application logo and title there, but they do not respond. (I'm testing my iPhone).

// Makes sure we are able to connect to the media buttons on the lock screen.
- (BOOL) canBecomeFirstResponder
{
return YES;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}

- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
NSLog(@"REMOTE");
if (receivedEvent.type == UIEventTypeRemoteControl) {

    switch (receivedEvent.subtype) {

        case UIEventSubtypeRemoteControlTogglePlayPause:
            [self playBtnPressed:nil];

            break;

        case UIEventSubtypeRemoteControlPreviousTrack:
            [self skipTrack:nil];
            break;

        case UIEventSubtypeRemoteControlNextTrack:
            [self skipTrack:nil];
            break;

        default:
            break;
    }
}
}
+3
source share
2 answers

You do not register for events in viewWillDisapear, which means that at any time this view is not displayed on the phone, which you will not register for events. I would change where you register and unregister to hookDesignDownLoad and viewDidUnload.

+2
source

You probably also need to add:

- (BOOL)canBecomeFirstResponder {
    return YES;
}

UIResponder , .

+2

All Articles