GKMatchMaker invite handler deprecated

后端 未结 4 977
我在风中等你
我在风中等你 2020-12-11 09:35

I have the following code that I have been using before to handle invitations:

[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NS         


        
4条回答
  •  再見小時候
    2020-12-11 10:09

    GKInviteEventHandler to the rescue, and in particular take a look at GKLocalPlayerListener.

    Conform to the GKLocalPlayerListener protocol and you should be OK. Below are the protocol methods, which look to be the intended replacement for invitationHandler, but split up in two parts.

    - (void)player:(GKPlayer *)player didAcceptInvite:(GKInvite *)invite
    - (void)player:(GKPlayer *)player didRequestMatchWithPlayers:(NSArray *)playerIDsToInvite
    

    After you set up some object to conform to that, you just make a call to registerListener:.

    [[GKLocalPlayer localPlayer] registerListener:yourObjectHere]
    

    Don't worry about registering it as soon as possible, as the system caches the invites/challenges/turn based stuff, if there's no one to handle those and lets your listener know as soon as you set it up.

提交回复
热议问题