So I was starting to get really frustrated with this (almost magically, the deprecation warnings started showing up in my console yesterday). Apple doesn't seem to spell out how an object can be set as the thing that implements the new GKLocalPlayerListener protocol.
Here's how I did it. Just after authenticating my local player, I registered the object that implements the GKLocalPlayerListener protocol (in this case self) as the Listener. I tested how my app responds to the same Game Center events, and it has responded accordingly. I believe this is the proper way to do it, although I am still questioning which place is the best for registering the listener. I believe it makes sense to do it after the player is authenticated, but it may be more subtle than that.
NSLog(@"Authenticating local user...");
__weak GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler =
^(UIViewController *viewController,
NSError *error) {
[self setLastError:error];
if (localPlayer.isAuthenticated) {
[localPlayer registerListener:self];
} else if(viewController) {
[self presentViewController:viewController];
} else {
}
};
You also want to avoid registering the listener more than once. It's kinda like registering an observer for a local notification. If you do it more than once, your listener methods end up getting called more than once.
I believe the method that replaces:
-(void)handleInviteFromGameCenter:(NSArray *)playersToInvite;
Is the following:
-(void)player:(GKPlayer *)player didRequestMatchWithPlayers:(NSArray *)playerIDsToInvite;
From reading the documentation, there is mention of creating a GKMatchMakerViewController (or something similar that's a little more bespoke) when this is called. I know that's what I was doing in previous versions of my app, so it can't be that far off. The structure of the method is also quite similar.
More testing will confirm if this is indeed the right way of approaching the new protocol, but so far it seems to be correct. I'm gonna continue with this until directed otherwise.