MPRemoteCommandCenter calls the handler block multiple times and causes unnecessary calls to selector methods.
Here is code snippet:
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[commandCenter.nextTrackCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
NSLog(@"NEXTTTTTT");
return MPRemoteCommandHandlerStatusSuccess;
}];
[commandCenter.previousTrackCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
NSLog(@"PREVIOUSSS");
return MPRemoteCommandHandlerStatusSuccess;
}];
When user clicks on next or previous button from the music player dock while screen is locked it causes multiple times to call the above blocks.