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 ID's 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 do it by scripting using this method:

GameCenterManager.registerAchievement (TEST_ACHIEVEMENT_1_ID);


The achievement ID's 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 is greater than those stored in PlayerPrefs.

Note: 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 when 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 is not yet authenticated with Game Center. 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, this 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 will 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 finished Action<ISN_ResultOnAuthFinished will be fired. The snippet bellow shows simple way to handle OnAuthFinished action.

GameCenterManager.OnAuthFinished += OnAuthFinished;

void OnAuthFinished (ISN_Result res) {
		if (res.IsSucceeded) {
			IOSNativePopUpManager.showMessage("Player Authored ", "ID: " + GameCenterManager.player.playerId + "\n" + "Alias: " + GameCenterManager.player.alias);
		} else {
			IOSNativePopUpManager.showMessage("Game Center ", "Player auth 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 restored 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  local player is authenticated


or underage


Here is the 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 generates 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 (ISN_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 ISN_PlayerSignatureResult object.

You can

Example Scenes

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

  • GameCenterGeneral
  • FriendsLoadExample
  • CustomLeaderBoardGUIExample