Initialize Game Center

After we've done the application setup, we can start working on the Game Center implementation.

Managing Game Center Settings

Before using Achievements functionality, register your achievement IDs in the plugin settings under the Game Center tab.

Open Window IOS Native Edit Settings

If you do not want to register your achievements using the plugin setting, you can script it using this method:

GameCenterManager.RegisterAchievement (TEST_ACHIEVEMENT_1_ID);


The achievement IDs can be obtained from iTunes Connect, see the screenshot below:

Use Requests Caching

If this option is enabled, submitAchievement requests will be stored when no internet connection is available and fired when the connection becomes available.

Save progress in PlayerPrefs

If this option is enabled, Achievement progress will be stored not only on the Game Center servers but also in the PlayerPrefs. PlayerPrefs values will be updated when you attempt to submit the achievement, and if after connecting to Game Center the values loaded from the Game Center servers are greater than those stored in PlayerPrefs.

Note: An achievement loaded request is sent automatically by the plugin after the player is logged in. You can find out when Achievement data is loaded by subscribing to the Action<ISN_Result> OnAchievementsLoaded.

Examples of enabling this option can be useful:

1) When you submit values like 88.66f. Example:

GameCenterManager.submitAchievement(88.66f, TEST_ACHIEVEMENT_2_ID,);

Game Center does not store the fractional part. So, after logging out from your game then loading the achievements progress on next login, Game Center will return 88.00. instead 88.66f.

Enabling Save progress in PlayerPrefs solves the problem.

2) Your Achievement progress data is stored locally and can always be accessed without waiting for  Action<ISN_Result> OnAchievementsLoaded  or even connecting to Game Center.

Initializing Game Center

iOS Native Game Center API doesn't have connect / disconnect methods.

It's recommended to authenticate user as soon as your app is launched, but you can also call it later if you do not want your user to login on startup.



It will start the authentication process - the user will see the login pop-up if he has not authenticated with Game Center yet. The only way for the user to disconnect your app from Game Center is to log out from the device settings.

If the pop-up is canceled, it triggers an authentication failed event with the following error description:

Error: Error Domain=GKErrorDomain Code=2 "The requested operation has been canceled or disabled by the user." UserInfo=0x1a0ef7e0 {NSLocalizedDescription=The requested operation has been canceled or disabled by the user.}


Apple allows showing Game Center authentication popup only once per session, so, if you try to connect again, then you will get the same error  - without showing authentication popup. That's why the plugin has only an init method and no connect / disconnect methods.

Starting from IOS8 you need to enable sandbox mode on you device before testing the Game Center connection. To do that, open Settings app, scroll down to  Game Center and enable Sandbox mode under the Developer settings:

When authentication flow is finished, Action<ISN_ResultOnAuthFinished will be fired. The snippet bellow shows simple way to handle OnAuthFinished action.

GameCenterManager.OnAuthFinished += OnAuthFinished;

void OnAuthFinished (SA.Common.Models.Result res) {
	if (res.IsSucceeded) {
		IOSNativePopUpManager.showMessage("Player Authed ", "ID: " + GameCenterManager.Player.Id + "\n" + "Alias: " + GameCenterManager.Player.Alias);
	} else {
		IOSNativePopUpManager.showMessage("Game Center ", "Player authentication failed");


Note: After authenticating their account on a device, that player remains connected on that device, even when the player switches to other applications or reboots the device. A player only disconnects from Game Center by launching the Game Center application and explicitly signing out.

Note: Every time when your app runs in the background and restoree from the background state, user authentication will be renewed, which means the OnAuthFinished action will be fired. 

Warning: Do not use any Game Center API until the user has successfully logged in.

After authorization is successful, you can use the other Game Center API described in the following guides.

Right after Game Center API is successfully initialized The current player information is available. You can get GK_Player class instance using:


Besides Player property you can also find out if a local player is authenticated


or underage


Here is an example of printing basic player info:

Debug.Log("Player.Id: " + GameCenterManager.Player.Id);
Debug.Log("Player.Id: " + GameCenterManager.Player.Alias);
Debug.Log("Player.Id: " + GameCenterManager.Player.DisplayName);

Authentication with third party servers

For third party server Authentication you should generate a signature that allows a third party server to authenticate the local player.

The following code snippet shows how to retrieve the player signature.

GameCenterManager.OnPlayerSignatureRetrieveResult += OnPlayerSignatureRetrieveResult;

void OnPlayerSignatureRetrieveResult (GK_PlayerSignatureResult result) {

	if(result.IsSucceeded) {

		Debug.Log("PublicKeyUrl: " + result.PublicKeyUrl);
		Debug.Log("Signature: " + result.Signature);
		Debug.Log("Salt: " + result.Salt);
		Debug.Log("Timestamp: " + result.Timestamp);

	} else {
		Debug.Log("Error code: " + result.error.code);
		Debug.Log("Error description: " + result.error.description);

	GameCenterManager.OnPlayerSignatureRetrieveResult -= OnPlayerSignatureRetrieveResult;


The result is represented as an GK_PlayerSignatureResult object.

You can

Example Scenes

Examples of using the Game Center API can be found in the following example scenes:

  • GameCenterGeneral
  • FriendsLoadExample
  • CustomLeaderBoardGUIExample