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 -> OSX 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:

OSXGameCenterManager.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 GAME_CENTER_ACHIEVEMENTS_LOADED event.

Action<ISN_Result> OnAchievementsLoaded


Examples of when enabling this option can be useful:

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

OSXGameCenterManager.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 OnAchievementsLoaded Action or even connecting to Game Center.


Initializing Game Center

To enable Game Center, call the following method when your app starts:


You can also call it later if you do not want your user to login on startup. This method will start authentication flow. If the user is logged out from Game Center he will see Game Center logging in window.

When authentication flow finished OnAuthFinished action will be fired.


OSXGameCenterManager.OnAuthFinished += OnAuthFinished;

void OnAuthFinished (ISN_Result res) {
		if (res.IsSucceeded) {
			OSXMessage.Create("Player Authored ", "ID: " + OSXGameCenterManager.player.playerId + "\n" + "Alias: " + OSXGameCenterManager.player.alias);
		} else {
			OSXMessage.Create("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.

The current player information is available. You can get OSXGameCenterPlayerTemplate class instance using:



The following data is available in the OSXGameCenterPlayerTemplate class:

public string playerId 
public string alias
public string displayNam
public Texture2D avatar 


For example, getting the current player id is performed like this:



But if you want to get the player avatar texture, make sure that you're checking if it's null or not - in case the player hasn't set up his avatar yet. Avatar loading will take a while after the user is connected so we will draw it only after instantiation to avoid null pointer check If you want to know exactly when the avatar is loaded, you can subscribe to the OSXGameCenterManager.OnUserInfoLoaded Action and check for a specific user ID.

if(OSXGameCenterManager.player.avatar != null) {
    GUI.DrawTexture(new Rect(10, 10, 75, 75), OSXGameCenterManager.player.avatar);



Authentication guidelines

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

You should call the init method at the start of your game:


This begins the authentication process - the user will see the login pop-up if he is not yet authenticated with Game Center.

Every time your app runs in the background, and restored from a background state, user authentication will be renewed -  the Game Center API will detect if the user has logged out. As a result, the Game Center API will try to sign in again and the user will see the Game Center authentication popup. 

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.

You can


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