Game Center Invitation handler, Where does it belo

2019-07-05 02:05发布

问题:

I already searched the site and found this:

GameCenter Invitation Handler

He says:

"

As stated in the docs

Your application should set the invitation handler as early as possible after your application is launched; an appropriate place to set the handler is in the completion block you provided that executes after the local player is authenticated.

"

.. OK, that's cool, but!

I would like Authenticate the player ONLY if an invitation was received .. Example:

Scenarios:

The player launches the game, plays single player mode, exits the game. [No Game center authentication].

The player accepts an invite, the game launches, invitation handler receives an invitation notification, authenticates the player, game starts.

The player chooses an online game, Game center authenticates the player.

..

So, My point is, I don't want to authenticate the player unnecessarily .. if possible. Which leads to the question, where should I place the invitation handler code? Obviously not after the authentication, since, as I already said, I don't want to authenticate the player unnecessarily ...

Thanks =)

回答1:

After days of thinking and searching, seems like you HAVE to authenticate the local player and initiate the invitation handler upon successful authentication .. This is the only way to support invitations in your game ..