Apple Game Center
Provide an Apple Game Center sign-in option to enable players to authenticate using their Game Center accounts on Apple platforms.
์ฝ๋ ์๊ฐ 1๋ถ์ต๊ทผ ์
๋ฐ์ดํธ: 8๋ฌ ์
์ต์ SDK ๋ฒ์ : 2.4.0
์ด ๋ฌธ์์์๋ ๊ฒ์์์ Apple Game Center ํ๋ ์ด์ด ์๋ณ์๋ฅผ ์ฌ์ฉํด ํ๋ ์ด์ด์ ์ธ์ฆ์ ์ค์ ํ๋ ๋ค์ ์๋๋ฆฌ์ค์ ๋ํด ์ค๋ช
ํฉ๋๋ค.
- Apple Game Center ๋ก๊ทธ์ธ ์ค์
- ๊ธฐ์กด ์ฌ์ฉ์ ๋ก๊ทธ์ธ ๋๋ ์ ์ฌ์ฉ์ ์์ฑ
- ์ฌ์ฉ์๋ฅผ ์ต๋ช ๋ก๊ทธ์ธ์์ Apple Game Center ๊ณ์ ์ ํตํ ํ๋ซํผ ๋ก๊ทธ์ธ์ผ๋ก ์ ๋ฐ์ดํธ
๊ฒ์์์ ํ๋ ์ด์ด์๊ฒ Apple Game Center ๋ก๊ทธ์ธ ์ต์
์ ์ ๊ณตํ๋ ค๋ฉด ์ฑ์์ Apple Game Center ๋ก๊ทธ์ธ์ ํ์ฑํํ์ญ์์ค.
Unity ์๋ํฐ์์ ์ง์ ๋๋ Unity Dashboard์์ Apple Game Center๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค.
Apple Game Center ๋ก๊ทธ์ธ ์ค์
-
Apple Unity Plug-ins ์ ์ฅ์์์ Apple Game Kit Unity ํ๋ฌ๊ทธ์ธ์ ์ค์ ํ๊ณ ์ค์นํฉ๋๋ค. GameKit ํ๋ ์์ํฌ๋ ํ๋ ์ด์ด ID๋ฅผ ๋น๋กฏํ Apple Game Center ๊ธฐ๋ฅ์ ๊ตฌํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
-
Unity์ ID ์ ๊ณต์ ์ฒด๋ก Apple Game Center๋ฅผ ์ถ๊ฐํฉ๋๋ค.
- Unity ์๋ํฐ ๋ฉ๋ด์์ Edit > Project Settingsโฆ ๋ก ์ด๋ํ ํ, ๋ด๋น๊ฒ์ด์ ๋ฉ๋ด์์ Services > Authentication์ ์ ํํฉ๋๋ค.
- ID Providers๋ฅผ Apple Game Center๋ก ์ค์ ํ ํ, Add๋ฅผ ์ ํํฉ๋๋ค.
- Bundle ID ํ ์คํธ ํ๋์ Apple ๊ฐ๋ฐ์ ์ฝ์์ ๋ฒ๋ค ID๋ฅผ ์ ๋ ฅํ ํ, Save๋ฅผ ์ ํํฉ๋๋ค. ๋ฒ๋ค ID๋ 'com.something.somethingelse'์ ๊ฐ์ ํ์์ด์ด์ผ ํฉ๋๋ค.
์ฐธ๊ณ : ์ฐธ์กฐ๋ ํจํค์ง๋ Unity๊ฐ ๊ฐ๋ฐํ๊ฑฐ๋ ๋ณด์ , ์ด์ํ์ง ์์ต๋๋ค. Unity๊ฐ ์ ๊ณตํ์ง ์๋ ํจํค์ง์ ์ฌ์ฉ๋ฒ์ ๋ฒ ์คํธ ํ๋ํฐ์ค๋ฅผ ์ฐธ๊ณ ํ์ญ์์ค.
ํ์ํ ํ๋ฌ๊ทธ์ธ์ ์ค์นํ๊ณ ID ์ ๊ณต์
์ฒด๋ฅผ ์ค์ ํ ํ, ๋ค์ ์ํ ์ฝ๋๋ฅผ ๋ฐ๋ผ ID ํ์ธ์ ํ์ํ ํ๋ผ๋ฏธํฐ๋ฅผ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
using System;using System.Threading.Tasks;using UnityEngine;using Apple.GameKit;public class AppleGameCenterExampleScript : MonoBehaviour{ string Signature; string TeamPlayerID; string Salt; string PublicKeyUrl; string Timestamp; // Start is called before the first frame update async void Start() { await Login(); } public async Task Login() { if (!GKLocalPlayer.Local.IsAuthenticated) { // Perform the authentication. var player = await GKLocalPlayer.Authenticate(); Debug.Log($"GameKit Authentication: player {player}"); // Grab the display name. var localPlayer = GKLocalPlayer.Local; Debug.Log($"Local Player: {localPlayer.DisplayName}"); // Fetch the items. var fetchItemsResponse = await GKLocalPlayer.Local.FetchItems(); Signature = Convert.ToBase64String(fetchItemsResponse.GetSignature()); TeamPlayerID = localPlayer.TeamPlayerId; Debug.Log($"Team Player ID: {TeamPlayerID}"); Salt = Convert.ToBase64String(fetchItemsResponse.GetSalt()); PublicKeyUrl = fetchItemsResponse.PublicKeyUrl; Timestamp = fetchItemsResponse.Timestamp.ToString(); Debug.Log($"GameKit Authentication: signature => {Signature}"); Debug.Log($"GameKit Authentication: publickeyurl => {PublicKeyUrl}"); Debug.Log($"GameKit Authentication: salt => {Salt}"); Debug.Log($"GameKit Authentication: Timestamp => {Timestamp}"); } else { Debug.Log("AppleGameCenter player already logged in."); } }}
๊ธฐ์กด ํ๋ ์ด์ด ๋ก๊ทธ์ธ ๋๋ ์ ๊ท ํ๋ ์ด์ด ์์ฑ
SignInWithAppleGameCenterAsync- Apple Game Center ์๊ฒฉ ์ฆ๋ช ์ ์ฌ์ฉํด ์ Unity Authentication ํ๋ ์ด์ด ์์ฑ
- Apple Game Center ์๊ฒฉ ์ฆ๋ช ์ ์ฌ์ฉํด ๊ธฐ์กด ํ๋ ์ด์ด ๋ก๊ทธ์ธ
ํ๋ก์ ํธ์์ ์๊ฒฉ ์ฆ๋ช
๊ณผ ์ฐ๊ฒฐ๋ Unity Authentication ํ๋ ์ด์ด๊ฐ ์กด์ฌํ์ง ์๋ ๊ฒฝ์ฐ, ๊ฐ ์ ํ๋ ์ด์ด๋ฅผ ์์ฑํฉ๋๋ค. ํ๋ก์ ํธ์์ ์๊ฒฉ ์ฆ๋ช
๊ณผ ์ฐ๊ฒฐ๋ Unity Authentication ํ๋ ์ด์ด๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ, ๊ฐ ํด๋น ํ๋ ์ด์ด์ ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธํฉ๋๋ค. ์ด ๊ธฐ๋ฅ์ ์บ์๋ ํ๋ ์ด์ด๋ฅผ ๊ณ ๋ คํ์ง ์์ผ๋ฉฐ, ๊ฐ ์บ์๋ ํ๋ ์ด์ด๋ฅผ ๋์ฒดํฉ๋๋ค.
SignInWithAppleGameCenterAsyncSignInWithAppleCenterAsyncSignInWithAppleGameCenterAsyncasync Task SignInWithAppleGameCenterAsync(string signature, string teamPlayerId, string publicKeyURL, string salt, ulong timestamp){ try { await AuthenticationService.Instance.SignInWithAppleGameCenterAsync(signature, teamPlayerId, publicKeyURL, salt, timestamp); Debug.Log("SignIn is successful."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}
ํ๋ ์ด์ด๋ฅผ ์ต๋ช ๋ก๊ทธ์ธ์์ Apple Game Center ๊ณ์ ๋ก๊ทธ์ธ์ผ๋ก ์ ๋ฐ์ดํธ
์ต๋ช
์ธ์ฆ์ ์ค์ ํ ํ, ํ๋ ์ด์ด๊ฐ Apple Game Center ๊ณ์ ์ ์์ฑํ๊ณ Apple Game Center๋ฅผ ํตํด ๋ก๊ทธ์ธํ๋๋ก ์
๊ทธ๋ ์ด๋ํ๋ ค๋ ๊ฒฝ์ฐ, ๊ฒ์์ด ํ๋ ์ด์ด์๊ฒ Apple Game Center ๋ก๊ทธ์ธ ์ฐฝ์ ํ์ํ๊ณ GameKit๋ฅผ ํตํด ID ํ์ธ ํ๋ผ๋ฏธํฐ๋ฅผ ๊ฐ์ ธ์์ผ ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ API๋ฅผ ํธ์ถํด ํ๋ ์ด์ด๋ฅผ Apple Game Center teamPlayerID์ ์ฐ๊ฒฐํฉ๋๋ค.
LinkWithAppleGameCenterAsyncSDK์ ์บ์๋ ํ๋ ์ด์ด๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ, ์บ์๋ ํ๋ ์ด์ด๋ฅผ Apple Game Center ๊ณ์ ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.
- ๋ฅผ ์ฌ์ฉํด ์บ์๋ ํ๋ ์ด์ด์ ๊ณ์ ์ ๋ก๊ทธ์ธํฉ๋๋ค.
SignInAnonymouslyAsync - ๋ฅผ ์ฌ์ฉํด ์บ์๋ ํ๋ ์ด์ด์ ๊ณ์ ์ Apple ๊ณ์ ์ ์ฐ๊ฒฐํฉ๋๋ค.
LinkWithAppleGameCenterAsync
async Task LinkWithAppleGameCenterAsync(string signature, string teamPlayerId, string publicKeyURL, string salt, ulong timestamp){ try { await AuthenticationService.Instance.LinkWithAppleGameCenterAsync(signature, teamPlayerId, publicKeyURL, salt, timestamp); Debug.Log("Link is successful."); } catch (AuthenticationException ex) when (ex.ErrorCode == AuthenticationErrorCodes.AccountAlreadyLinked) { // Prompt the player with an error message. Debug.LogError("This user is already linked with another account. Log in instead."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}
Apple Game Center ๊ณ์ ์ฐ๊ฒฐ ํด์
ํ๋ ์ด์ด๊ฐ Apple Game Center ๊ณ์ ์ฐ๊ฒฐ์ ํด์ ํ ์ ์๋๋ก API๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ฐ๊ฒฐ์ด ํด์ ๋๋ฉด ๊ณ์ ์ด ๋ค๋ฅธ ID์ ์ฐ๊ฒฐ๋์ง ์์ ๊ฒฝ์ฐ ์ต๋ช
๊ณ์ ์ผ๋ก ์ ํ๋ฉ๋๋ค.
UnlinkAppleGameCenterAsyncasync Task UnlinkAppleGameCenterAsync(string idToken){ try { await AuthenticationService.Instance.UnlinkAppleGameCenterAsync(idToken); Debug.Log("Unlink is successful."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}