Skip to main content
Version: 6.0.0

SmartSwitchAuthenticateGameCenter

Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type. In event the current session was previously an anonymous account, the smart switch will delete that profile. Use this function to keep a clean designflow from anonymous to signed profiles

Authenticate the user using their Game Center id

Method Parameters

ParameterDescription
gameCenterIdThe user's Game Center ID — can be the PlayerId, GamePlayerId, or TeamPlayerId from the GKLocalPlayer object
forceCreateShould a new profile be created for this user if the account does not exist?
timestampThe timestamp value returned as part of the identity verification signature fetch from Game Center. Required for modern Game Center verification.
publicKeyUrlThe public key URL returned as part of the identity verification signature fetch from Game Center. Required for modern Game Center verification.
signatureThe raw signature bytes returned from Game Center (via GetSignature()). Required for modern Game Center verification.
saltThe raw salt bytes returned from Game Center (via GetSalt()). Required for modern Game Center verification.
teamPlayerIdOnly required when gameCenterId is set to a value other than TeamPlayerId.

Usage

http://localhost:3000
string gameCenterId = "userGameCenterId"; // PlayerId, GamePlayerId, or TeamPlayerId
bool forceCreate = true;
ulong timestamp = 0; // from GKLocalPlayer identity verification
string publicKeyUrl = ""; // from GKLocalPlayer identity verification
byte[] signature = null; // from GKLocalPlayer GetSignature()
byte[] salt = null; // from GKLocalPlayer GetSalt()
string teamPlayerId = ""; // only if gameCenterId is not TeamPlayerId

SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("[Authenticate Success] {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("[Authenticate Failed] {0} {1} {2}", status, code, error));
};
_bc.SmartSwitchAuthenticateGameCenter(
gameCenterId, forceCreate, timestamp, publicKeyUrl,
signature, salt, teamPlayerId,
successCallback, failureCallback);
JSON Response
var gameCenterId = "userGameCenterId";
var forceCreate = true;

_bc.smartSwitchAuthenticateGameCenter(gameCenterId, forceCreate, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});