Search code examples
iosgame-centerachievements

Game Center achievement behavior for multiple account game


Let's say that you develop an iOS game that allows the user to login and log out of different accounts using in-house account system. For example, you could login using Facebook, or email/password combination.

What is the best way for this game to handle Game Center achievements? How should situations with logging in and out handled?


Solution

  • Regardless of your in-house account management system, the associated user will need to login to Game Center. Unfortunately you cannot force a Game Center logout via iOS; this is something the user will need to do on their own.

    As far as tracking achievements goes, let Game Center handle all of that. Your real challenge is going to be getting the user to explicitly launch the Game Center standalone application to sign-on & sign back in, either within the GC app or via your app's GC [login] presentation.

    In order to ensure proper achievement progress is reported across users' accounts, the user logged into your app with their in-house account must also be logged in with their Game Center account. One way to at least ensure you don't cross the streams regarding achievement tracking & reporting is to have the user enter their Game Center display name while logging in via the in-house system.

    Once past the in-house authentication, let Game Center player authentication take place, retrieve the local player's playerName and compare. If they match, flag this and track / report achievement progress normally.

    If they don't match, it's up to you whether to prompt the user again for this information to check again. At the very least you should communicate to them that the in-house account does not match the Game Center account, and to move forward they will need to launch the Game Center app to logout & login. Otherwise, flag the mismatch, and use this logic to bypass achievement reporting (and potentially other GC functionality).

    There's a post here with some more ideas.

    Good luck!