Game > Gamebase > Unity SDK 사용 가이드 > ETC

Additional Features

Gamebase에서 지원하는 부가 기능을 설명합니다.

Device Language

  • 단말기에 설정된 언어 코드를 반환합니다.
  • 여러개의 언어가 등록된 경우, 우선권이 가장 높은 언어만을 반환합니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

static string GetDeviceLanguageCode()

[참고]

Editor on Windows, Standalone on Windows인 경우에는 CultureInfo를 참고하여 언어 코드를 반환합니다.

Editor on Mac, WebGL은 Application.systemLanguage 값을 참고하여 언어 코드를 반환합니다.
예를 들어, Application.systemLanguage == SystemLanguage.Korean인 경우에는 'ko'를 반환합니다.

Display Language

점검 팝업 창과 같이 Gamebase가 표시하는 언어는 단말기에 설정된 언어로 표시됩니다.

그런데 게임에서 표시하는 언어를 단말기에 설정된 언어가 아닌, 별도의 옵션으로 언어를 변경할 수 있는 게임이 있습니다. 예를 들어, 단말기에 설정된 언어는 영어 이지만 게임 표시 언어를 일본어로 변경한 경우, Gamebase 에서 표시하는 언어도 일본어로 변경하고 싶지만 Gamebase 가 표시하는 언어는 단말기에 설정된 언어인 영어로 표시됩니다.

이와 같이 단말기에 설정된 언어가 아닌, 다른 언어로 Gamebase 메시지를 표시하고 싶은 애플리케이션을 위해 Gamebase 는 Display Language 라는 기능을 제공합니다.

Gamebase 는 Display Language 로 설정한 언어로 Gamebase 메시지를 표시합니다. Display Language 에 입력하는 언어 코드는 반드시 아래의 표(Gamebase에서 지원하는 언어코드의 종류)에 지정된 코드만을 사용할 수 있습니다.

[주의]

  • Display Language 는 단말기 설정 언어와 무관하게 Gamebase 의 표시 언어를 변경하고 싶은 경우에만 사용하시기 바랍니다.
  • Display Language Code 는 ISO-639 형태의 값으로, 대소문자를 구분합니다. 'EN'이나 'zh-cn'과 같이 설정하면 문제가 발생할 수 있습니다.
  • 만일 Display Language Code 로 입력한 값이 아래의 표(Gamebase에서 지원하는 언어코드의 종류)에 존재하지 않는다면, Display Langauge Code 는 자동으로 기본값인 영어(en)로 지정됩니다.

[참고]

  • Gamebase의 클라이언트 메시지는 영어(en), 한글(ko), 일본어(ja)만 포함하고 있으므로 아래의 표에 존재하는 언어 코드라 할지라도 영어(en), 한글(ko), 일본어(ja) 이외의 언어를 지정하면 기본값인 영어(en)로 자동 설정됩니다.
  • Gamebase의 클라이언트에 포함되어 있지 않은 언어셋은 직접 추가할 수 있습니다. 신규 언어셋 추가 항목을 참조하시기 바랍니다.

Gamebase에서 지원하는 언어코드의 종류

Code Name
de German
en English
es Spanish
fi Finnish
fr French
id Indonesian
it Italian
ja Japanese
ko Korean
pt Portuguese
ru Russian
th Thai
vi Vietnamese
ms Malay
zh-CN Chinese-Simplified
zh-TW Chinese-Traditional

해당 언어코드는 GamebaseDisplayLanguageCode 클래스에 정의되어 있습니다.

namespace Toast.Gamebase
{
    public class GamebaseDisplayLanguageCode
    {
        public const string German = "de";
        public const string English = "en";
        public const string Spanish = "es";
        public const string Finnish = "fi";
        public const string French = "fr";
        public const string Indonesian = "id";
        public const string Italian = "it";
        public const string Japanese = "ja";
        public const string Korean = "ko";
        public const string Portuguese = "pt";
        public const string Russian = "ru";
        public const string Thai = "th";
        public const string Vietnamese = "vi";
        public const string Malay = "ms";
        public const string Chinese_Simplified = "zh-CN";
        public const string Chinese_Traditional = "zh-TW";
    }
}

Gamebase 초기화 시 Display Language 설정

Gamebase 초기화 시 Display Language를 설정할 수 있습니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

static void Initialize(GamebaseRequest.GamebaseConfiguration configuration, GamebaseCallback.GamebaseDelegate<GamebaseResponse.Launching.LaunchingInfo> callback)

Example

public void InitializeWithConfiguration()
{
    var configuration = new GamebaseRequest.GamebaseConfiguration();
    ...
    configuration.displayLanguageCode = displayLanguage;
    ...

    Gamebase.Initialize(configuration, (launchingInfo, error) =>
    {
        if (Gamebase.IsSuccess(error))
        {
            Debug.Log("Gamebase initialization succeeded.");
            string displayLanguage = Gamebase.GetDisplayLanguageCode();
        }
        else
        {
            Debug.Log(string.Format("Gamebase initialization failed. error is {0}", error));
        }
    });
}

Set Display Language

Gamebase 초기화 시 입력된 Display Language를 변경할 수 있습니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

static void SetDisplayLanguageCode(string languageCode)

Example

public void SetDisplayLanguageCode()
{
    Gamebase.SetDisplayLanguageCode(GamebaseDisplayLanguageCode.English);
}

Get Display Language

현재 적용된 Display Language를 조회할 수 있습니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

static string GetDisplayLanguageCode()

Example

public void GetDisplayLanguageCode()
{
    string displayLanguage = Gamebase.GetDisplayLanguageCode();
}

신규 언어셋 추가

UnityEditor 및 Unity Standalone, WebGL 플랫폼 서비스 시, Gamebase에서 제공하는 기본 언어(ko, en) 외 다른 언어를 사용하려면 Assets > StreamingAssets > Gamebase에 있는 localizedstring.json 파일에 값을 추가해야 합니다.

localizedstring.json

localizedstring.json에 정의되어 있는 형식은 아래와 같습니다.

{
  "en": {
    "common_ok_button": "OK",
    "common_cancel_button": "Cancel",
    ...
    "launching_service_closed_title": "Service Closed"
  },
  "ko": {
    "common_ok_button": "확인",
    "common_cancel_button": "취소",
    ...
    "launching_service_closed_title": "서비스 종료"
  },
  "ja": {
    "common_ok_button": "確認",
    "common_cancel_button": "キャンセル",
    ...
    "launching_service_closed_title": "サービス終了"
  },
}

다른 언어셋을 추가해야 할 경우에는 localizedstring.json 파일에 "${언어 코드}":{"key":"value"} 형태로 값을 추가하면 됩니다.

{
  "en": {
    "common_ok_button": "OK",
    "common_cancel_button": "Cancel",
    ...
    "launching_service_closed_title": "Service Closed"
  },
  "ko": {
    "common_ok_button": "확인",
    "common_cancel_button": "취소",
    ...
    "launching_service_closed_title": "서비스 종료"
  },
  "ja": {
    "common_ok_button": "確認",
    "common_cancel_button": "キャンセル",
    ...
    "launching_service_closed_title": "サービス終了"
  },
  "${언어코드}": {
      "common_ok_button": "...",
      ...
  }
}

Unity Android, iOS 플랫폼에서의 신규 언어셋 추가 방법은 아래 가이드를 참고하십시오.

Display Language 우선순위

초기화 및 SetDisplayLanguageCode API를 통해 Display Language를 설정할 경우, 최종 적용되는 Display Language는 입력한 값과 다르게 적용될 수 있습니다.

  1. 입력된 languageCode가 localizedstring.json 파일에 정의되어 있는지 확인합니다.
  2. Gamebase 초기화 시, 단말기에 설정된 언어코드가 localizedstring.json 파일에 정의되어 있는지 확인합니다.(이 값은 초기화 이후, 단말기에 설정된 언어를 변경하더라도 유지됩니다.)
  3. Display Language의 기본값인 en이 자동으로 설정됩니다.

Country Code

  • Gamebase는 System의 국가 코드를 다음과 같은 API로 제공하고 있습니다.
  • 각 API 마다 특징이 있으니 쓰임새에 맞는 API를 선택하시기 바랍니다.

USIM Country Code

  • USIM에 기록된 국가 코드를 반환합니다.
  • USIM에 잘못된 국가 코드가 기록되어 있다 하더라도 추가적인 체크 없이 그대로 반환합니다.
  • 값이 비어있는 경우 'ZZ'를 반환합니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID

static string GetCountryCodeOfUSIM()

Device Country Code

  • OS로부터 전달받은 단말기 국가 코드를 추가적인 체크 없이 그대로 반환합니다.
  • 단말기 국가 코드는 '언어' 설정에 따라 OS가 자동으로 결정합니다.
  • 여러 개의 언어가 등록된 경우, 우선권이 가장 높은 언어로 국가 코드를 결정합니다.
  • 값이 비어있는 경우 'ZZ'를 반환합니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID

static string GetCountryCodeOfDevice()

Intergrated Country Code

  • USIM, 단말기 언어 설정의 순서로 국가 코드를 확인하여 반환합니다.
  • GetCountryCode API는 다음 순서로 동작합니다.
    1. USIM에 기록된 국가 코드를 확인하고, 값이 존재한다면 추가적인 체크 없이 그대로 반환합니다.
    2. USIM 국가 코드가 빈 값이라면 단말기 국가 코드를 확인하고, 값이 존재한다면 추가적인 체크 없이 그대로 반환합니다.
    3. USIM, 단말기 국가 코드가 모두 빈 값이라면 'ZZ' 를 반환합니다.

observer

[참고]

Editor on Windows, Standalone on Windows인 경우에는 CultureInfo를 참고하여 국가 코드를 반환합니다.

Editor on Mac, WebGL은 Application.systemLanguage 값을 참고하여 국가 코드를 반환합니다.
예를 들어,Application.systemLanguage == SystemLanguage.Korean인 경우에는 'KR'을 반환합니다.

API

UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

public static string GetCountryCode()

Gamebase Event Handler

  • Gamebase는 각종 이벤트를 GamebaseEventHandler라는 하나의 이벤트 시스템에서 모두 처리할 수 있습니다.
  • GamebaseEventHandler는 아래 API를 통해 간단하게 Listener를 추가/제거할 수 있습니다.

API

UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

public static void Gamebase.AddEventHandler(GamebaseCallback.DataDelegate<GamebaseResponse.Event.GamebaseEventMessage> eventHandler);
public static void Gamebase.RemoveEventHandler(GamebaseCallback.DataDelegate<GamebaseResponse.Event.GamebaseEventMessage> eventHandler);
public static void Gamebase.RemoveAllEventHandler();

VO

public class GamebaseEventMessage 
{
    // Event 종류를 나타냅니다.
    // GamebaseEventCategory 클래스의 값이 할당됩니다.
    public string category;

    // 각 category 에 맞는 VO 로 변환할 수 있는 JSON String 데이터입니다.
     public string data;
}

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.IDP_REVOKED:
            {
                GamebaseResponse.Event.GamebaseEventIdPRevokedData idPRevokedData = GamebaseResponse.Event.GamebaseEventIdPRevokedData.From(message.data);
                if (idPRevokedData != null)
                {
                    ProcessIdPRevoked(idPRevokedData);
                }
                break;
            }
        case GamebaseEventCategory.LOGGED_OUT:
            {
                GamebaseResponse.Event.GamebaseEventLoggedOutData loggedData = GamebaseResponse.Event.GamebaseEventLoggedOutData.From(message.data);
                if (loggedData != null)
                {
                    // There was a problem with the access token.
                    // Call login again.
                }
                break;
            }
        case GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT_MESSAGE_RECEIVED:
        case GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT:
        case GamebaseEventCategory.SERVER_PUSH_TRANSFER_KICKOUT:
            {
                GamebaseResponse.Event.GamebaseEventServerPushData serverPushData = GamebaseResponse.Event.GamebaseEventServerPushData.From(message.data);
                if (serverPushData != null)
                {
                    CheckServerPush(message.category, serverPushData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_LAUNCHING:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if(observerData != null)
                {
                    CheckLaunchingStatus(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_NETWORK:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if (observerData != null)
                {
                    CheckNetwork(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_HEARTBEAT:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if (observerData != null)
                {
                    CheckHeartbeat(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_WEBVIEW:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if (observerData != null)
                {
                    CheckWebView(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_INTROSPECT:
            {
                // Introspect error
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                int errorCode = observerData.code;
                string errorMessage = observerData.message;
                break;
            }
        case GamebaseEventCategory.PURCHASE_UPDATED:
            {
                GamebaseResponse.Event.PurchasableReceipt purchasableReceipt = GamebaseResponse.Event.PurchasableReceipt.From(message.data);
                if (purchasableReceipt != null)
                {
                    // If the user got item by 'Promotion Code',
                    // this event will be occurred.
                }
                break;
            }
        case GamebaseEventCategory.PUSH_RECEIVED_MESSAGE:
            {
                GamebaseResponse.Event.PushMessage pushMessage = GamebaseResponse.Event.PushMessage.From(message.data);
                if (pushMessage != null)
                {
                    // When you received push message.

                    // By converting the extras field of the push message to JSON,
                    // you can get the custom information added by the user when sending the push.
                    // (For Android, an 'isForeground' field is included so that you can check if received in the foreground state.)
                }
                break;
            }
        case GamebaseEventCategory.PUSH_CLICK_MESSAGE:
            {
                GamebaseResponse.Event.PushMessage pushMessage = GamebaseResponse.Event.PushMessage.From(message.data);
                if (pushMessage != null)
                {
                    // When you clicked push message.
                }
                break;
            }
        case GamebaseEventCategory.PUSH_CLICK_ACTION:
            {
                GamebaseResponse.Event.PushAction pushAction = GamebaseResponse.Event.PushAction.From(message.data);
                if (pushAction != null)
                {
                    // When you clicked action button by 'Rich Message'.
                }
                break;
            }
    }
}
  • Category 는 GamebaseEventCategory 클래스에 정의되어 있습니다.
  • 이벤트는 크게 IdPRevoked, LoggedOut, ServerPush, Observer, Purchase, Push로 나뉘며, 각 Category에 따라 아래 표와 같은 방법으로 GamebaseEventMessage.data를 VO로 변환할 수 있습니다.
Event 종류 GamebaseEventCategory VO 변환 방법 비고
IdPRevoked GamebaseEventCategory.IDP_REVOKED GamebaseResponse.Event.GamebaseEventIdPRevokedData.from(message.data) -
LoggedOut GamebaseEventCategory.LOGGED_OUT GamebaseResponse.Event.GamebaseEventLoggedOutData.from(message.data) -
ServerPush GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT_MESSAGE_RECEIVED
GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT
GamebaseEventCategory.SERVER_PUSH_TRANSFER_KICKOUT
GamebaseResponse.Event.GamebaseEventServerPushData.from(message.data) -
Observer GamebaseEventCategory.OBSERVER_LAUNCHING
GamebaseEventCategory.OBSERVER_NETWORK
GamebaseEventCategory.OBSERVER_HEARTBEAT
GamebaseResponse.Event.GamebaseEventObserverData.from(message.data) -
Purchase - 프로모션 결제 GamebaseEventCategory.PURCHASE_UPDATED GamebaseResponse.Event.PurchasableReceipt.from(message.data) -
Push - 메시지 수신 GamebaseEventCategory.PUSH_RECEIVED_MESSAGE GamebaseResponse.Event.PushMessage.from(message.data)
Push - 메시지 클릭 GamebaseEventCategory.PUSH_CLICK_MESSAGE GamebaseResponse.Event.PushMessage.from(message.data)
Push - 액션 클릭 GamebaseEventCategory.PUSH_CLICK_ACTION GamebaseResponse.Event.PushAction.from(message.data) RichMessage 버튼 클릭 시 동작합니다.

IdP Revoked

[참고]

iOS Appleid 로그인을 사용하는 경우에만 발생할 수 있는 이벤트입니다.

  • IdP에서 해당 서비스를 삭제하였을 때 발생하는 이벤트입니다.
  • 유저에게 IdP가 사용 중지된 것을 알리고, 동일한 IdP로 로그인할 때 userID를 새로 발급 받을 수 있도록 구현해야 합니다.
  • GamebaseEventIdPRevokedData.code: GamebaseIdPRevokedCode 값을 의미합니다.
    • WITHDRAW : 600
      • 현재 사용 중지된 IdP로 로그인되어 있고, 매핑된 IdP 목록이 없을 때를 의미합니다.
      • Withdraw API를 호출하여 현재 계정을 탈퇴 처리해야 합니다.
    • OVERWRITE_LOGIN_AND_REMOVE_MAPPING : 601
      • 현재 사용 중지된 IdP로 로그인되어 있고, 사용 중지된 IdP 외에 다른 IdP가 매핑되어 있는 경우를 의미합니다.
      • 매핑된 IdP 중 하나의 IdP로 로그인을 하고 RemoveMapping API를 호출하여 사용 중지된 IdP에 대해 연동을 해제해야 합니다.
    • REMOVE_MAPPING : 602
      • 현재 계정에 매핑된 IdP 중 사용 중지된 IdP가 있을 경우를 의미합니다.
      • RemoveMapping API를 호출하여 사용 중지된 IdP에 대해 연동을 해제해야 합니다.
  • GamebaseEventIdPRevokedData.idpType: 사용 중지된 IdP 타입을 의미합니다.
  • GamebaseEventIdPRevokedData.authMappingList: 현재 계정에 매핑되어 있는 IdP 목록을 의미합니다.

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.IDP_REVOKED:
            {
                GamebaseResponse.Event.GamebaseEventIdPRevokedData idPRevokedData = GamebaseResponse.Event.GamebaseEventIdPRevokedData.From(message.data);
                if (idPRevokedData != null)
                {
                    ProcessIdPRevoked(idPRevokedData);
                }
                break;
            }
        default:
            {
                break;
            }
    }
}

private void ProcessIdPRevoked(string category, GamebaseResponse.Event.GamebaseEventIdPRevokedData data)
{
    var revokedIdP = data.idPType;
    switch (data.code)
    {
        case GamebaseIdPRevokedCode.WITHDRAW:
            {
                // 현재 사용 중지된 IdP로 로그인되어 있고, 매핑된 IdP 목록이 없을 때를 의미합니다.
                // 유저에게 현재 계정이 탈퇴 처리된 것을 알려 주세요.
                Gamebase.Withdraw((error) =>
                {
                    ...
                });
                break;
            }
        case GamebaseIdPRevokedCode.OVERWRITE_LOGIN_AND_REMOVE_MAPPING:
            {
                // 현재 사용 중지된 IdP로 로그인되어 있고, 사용 중지된 IdP 외에 다른 IdP가 매핑되어 있는 경우를 의미합니다.
                // 유저가 authMappingList 중 다시 로그인할 IdP를 선택하도록 하고, 선택한 IdP로 로그인한 뒤에는 사용 중지된 IdP의 연동을 해제해 주세요.
                var selectedIdP = "유저가 선택한 IdP";
                var additionalInfo = new Dictionary<string, object>()
                {
                    { GamebaseAuthProviderCredential.IGNORE_ALREADY_LOGGED_IN, true }
                };

                Gamebase.Login(selectedIdP, additionalInfo, (authToken, loginError) =>
                {
                    if (Gamebase.IsSuccess(loginError) == true)
                    {
                        Gamebase.RemoveMapping(revokedIdP, (mappingError) =>
                        {
                            ...
                        });
                    }
                });
                break;
            }
        case GamebaseIdPRevokedCode.REMOVE_MAPPING:
            {
                // 현재 계정에 매핑된 IdP 중 사용 중지된 IdP가 있을 경우를 의미합니다.
                // 유저에게 현재 계정에서 사용 중지된 IdP가 연동 해제됨을 알려 주세요.
                Gamebase.RemoveMapping(revokedIdP, (error) =>
                {
                    ...
                });
                break;
            }
    }
}

Logged Out

  • Gamebase Access Token이 만료되어 네트워크 세션을 복구하기 위해 로그인 함수 호출이 필요한 경우 발생하는 이벤트입니다.

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.LOGGED_OUT:
            {
                GamebaseResponse.Event.GamebaseEventLoggedOutData loggedData = GamebaseResponse.Event.GamebaseEventLoggedOutData.From(message.data);
                if (loggedData != null)
                {
                    // There was a problem with the access token.
                    // Call login again.
                }
                break;
            }
    }
}

Server Push

  • Gamebase 서버에서 클라이언트 단말기로 보내는 메시지입니다.
  • Gamebase 에서 지원하는 Server Push Type 은 다음과 같습니다.
    • GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT_MESSAGE_RECEIVED
      • NHN Cloud Gamebase 콘솔의 Operation > Kickout 에서 킥아웃 ServerPush 메시지를 등록하면 Gamebase와 연결된 모든 클라이언트에서 킥아웃 메시지를 받게 됩니다.
      • 클라이언트 단말기에서 서버 메시지를 수신했을 때 바로 동작하는 이벤트입니다.
      • '오토 플레이'와 같이 게임이 동작 중인 경우, 게임을 일시 정지시키는 목적으로 활용할 수 있습니다.
    • GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT
      • NHN Cloud Gamebase 콘솔의 Operation > Kickout 에서 킥아웃 ServerPush 메시지를 등록하면 Gamebase와 연결된 모든 클라이언트에서 킥아웃 메시지를 받게 됩니다.
      • 클라이언트 단말기에서 서버 메시지를 수신했을 때 팝업 창을 표시하는데, 유저가 이 팝업 창을 닫았을 때 발생하는 이벤트입니다.
    • GamebaseEventCategory.SERVER_PUSH_TRANSFER_KICKOUT
      • Guest 계정을 다른 단말기로 이전을 성공하게 되면 이전 단말기에서 킥아웃 메시지를 받게 됩니다.

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT_MESSAGE_RECEIVED:
        case GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT:
        case GamebaseEventCategory.SERVER_PUSH_TRANSFER_KICKOUT:
            {
                GamebaseResponse.Event.GamebaseEventServerPushData serverPushData = GamebaseResponse.Event.GamebaseEventServerPushData.From(message.data);
                if (serverPushData != null)
                {
                    CheckServerPush(message.category, serverPushData);
                }
                break;
            }
        default:
            {
                break;
            }
    }
}

private void CheckServerPush(string category, GamebaseResponse.Event.GamebaseEventServerPushData data)
{
    if (category.Equals(GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT) == true)
    {
        // Kicked out from Gamebase server.(Maintenance, banned or etc.)
        // And the game user closes the kickout pop-up.
        // Return to title and initialize Gamebase again.
    }
    else if (category.Equals(GamebaseEventCategory.SERVER_PUSH_APP_KICKOUT_MESSAGE_RECEIVED) == true)
    {
        // Currently, the kickout pop-up is displayed.
        // If your game is running, stop it.
    }
    else if (category.Equals(GamebaseEventCategory.SERVER_PUSH_TRANSFER_KICKOUT) == true)
    {
        // If the user wants to move the guest account to another device,
        // if the account transfer is successful,
        // the login of the previous device is released,
        // so go back to the title and try to log in again.
    }
}

Observer

  • Gamebase Gamebase의 각종 상태 변동 이벤트를 처리하는 시스템입니다.
  • Gamebase 에서 지원하는 Observer Type 은 다음과 같습니다.
    • GamebaseEventCategory.OBSERVER_LAUNCHING
      • 점검이 걸리거나 풀린 경우, 새로운 버전이 배포되어 업데이트가 필요한 경우와 같이, Launching 상태가 변경되었을 때 동작합니다.
      • GamebaseEventObserverData.code: LaunchingStatus 값을 의미합니다.
        • LaunchingStatus.IN_SERVICE: 200
        • LaunchingStatus.RECOMMEND_UPDATE: 201
        • LaunchingStatus.IN_SERVICE_BY_QA_WHITE_LIST: 202
        • LaunchingStatus.REQUIRE_UPDATE: 300
        • LaunchingStatus.BLOCKED_USER: 301
        • LaunchingStatus.TERMINATED_SERVICE: 302
        • LaunchingStatus.INSPECTING_SERVICE: 303
        • LaunchingStatus.INSPECTING_ALL_SERVICES: 304
        • LaunchingStatus.INTERNAL_SERVER_ERROR: 500
    • GamebaseEventCategory.OBSERVER_HEARTBEAT
      • 탈퇴 처리 되거나 이용 정지로 인하여 사용자 계정 상태가 변했을 때 동작합니다.
      • GamebaseEventObserverData.code: GamebaseError 값을 의미합니다.
        • GamebaseError.INVALID_MEMBER: 6
        • GamebaseError.BANNED_MEMBER: 7
    • GamebaseEventCategory.OBSERVER_NETWORK *Android, iOS에 한합니다.
      • 네트워크 변동 사항 정보를 받을 수 있습니다.
      • 네트워크가 끊기거나 연결되었을 때, 혹은 Wifi에서 셀룰러 네트워크로 변경되었을 때 동작합니다.
      • GamebaseEventObserverData.code: NetworkManager 값을 의미합니다.
        • NetworkManager.TYPE_NOT: -1
        • NetworkManager.TYPE_MOBILE: 0
        • NetworkManager.TYPE_WIFI: 1
        • NetworkManager.TYPE_ANY: 2
    • GamebaseEventCategory.OBSERVER_WEBVIEW
      • Standalone에 한합니다.
      • Standalone에서 웹뷰를 열고 닫을 때 동작합니다.
        • GamebaseWebViewEventType.OPENED: 1
        • GamebaseWebViewEventType.CLOSED: 2
    • GamebaseEventCategory.OBSERVER_INTROSPECT
      • Standalone, WebGL에 한합니다.
      • 로그인 후 세션 연장에 실패할 때 동작합니다.

VO

public class GamebaseEventObserverData 
{
    // 상태값을 나타내는 정보입니다.
    public int code;

    // 상태에 관련된 메시지 정보입니다.
    public string message;

    // 추가 정보용 예비 필드입니다.
    public string extras;
}

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.OBSERVER_LAUNCHING:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if(observerData != null)
                {
                    CheckLaunchingStatus(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_NETWORK:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if (observerData != null)
                {
                    CheckNetwork(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_HEARTBEAT:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if (observerData != null)
                {
                    CheckHeartbeat(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_WEBVIEW:
            {
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                if (observerData != null)
                {
                    CheckWebView(observerData);
                }
                break;
            }
        case GamebaseEventCategory.OBSERVER_INTROSPECT:
            {
                // Introspect error
                GamebaseResponse.Event.GamebaseEventObserverData observerData = GamebaseResponse.Event.GamebaseEventObserverData.From(message.data);
                int errorCode = observerData.code;
                string errorMessage = observerData.message;
                break;
            }
        default:
            {
                break;
            }
    }
}

private void CheckLaunchingStatus(GamebaseResponse.Event.GamebaseEventObserverData observerData)
{
    switch (observerData.code)
    {
        case GamebaseLaunchingStatus.IN_SERVICE:
            {
                // Service is now normally provided.
                break;
            }
        // ... 
        case GamebaseLaunchingStatus.INTERNAL_SERVER_ERROR:
            {
                // Error in internal server.
                break;
            }
    }
}

private void CheckNetwork(GamebaseResponse.Event.GamebaseEventObserverData observerData)
{
    switch ((GamebaseNetworkType)observerData.code)
    {
        case GamebaseNetworkType.TYPE_NOT:
            {
                // Network disconnected.
                break;
            }
        case GamebaseNetworkType.TYPE_MOBILE:
        case GamebaseNetworkType.TYPE_WIFI:
        case GamebaseNetworkType.TYPE_ANY:
            {
                // Network connected.
                break;
            }
    }
}

private void CheckHeartbeat(GamebaseResponse.Event.GamebaseEventObserverData observerData)
{
    switch (observerData.code)
    {
        case GamebaseErrorCode.INVALID_MEMBER:
            {
                // You can check the invalid user session in here.
                // ex) After transferred account to another device.
                break;
            }
        case GamebaseErrorCode.BANNED_MEMBER:
            {
                // You can check the banned user session in here.
                break;
            }
    }
}

private void CheckWebView(GamebaseResponse.Event.GamebaseEventObserverData observerData)
{
    switch (observerData.code)
    {
        case GamebaseWebViewEventType.OPENED:
            {
                // WebView opened.
                break;
            }
        case GamebaseWebViewEventType.CLOSED:
            {
                // WebView closed.
                break;
            }
    }
}

Purchase Updated

  • Promotion 코드 입력을 통해 상품을 획득한 경우 발생하는 이벤트입니다.
  • 결제 영수증 정보를 획득할 수 있습니다.

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.PURCHASE_UPDATED:
            {
                GamebaseResponse.Event.PurchasableReceipt purchasableReceipt = GamebaseResponse.Event.PurchasableReceipt.From(message.data);
                if (purchasableReceipt != null)
                {
                    // If the user got item by 'Promotion Code',
                    // this event will be occurred.
                }
                break;
            }
        default:
            {
                break;
            }
    }
}

Push Received Message

  • Push 메시지가 도착했을때 발생하는 이벤트입니다.
  • extras 필드를 JSON으로 변환하여, Push 발송 시 전송했던 커스텀 정보를 얻을 수도 있습니다.
    • Android에서는 isForeground 필드를 통해 포그라운드에서 메시지를 수신했는지, 백그라운드에서 메시지를 수신했는지 구분할 수 있습니다.

VO

public class PushMessage 
{
    // 메시지 고유의 id입니다.
    public string id;

    // Push 메시지 제목입니다.
    public string title;

    // Push 메시지 본문 내용입니다.
    public string body;

    // JSON 형식으로 Push 발송 시 전송했던 커스텀 정보를 확인할 수 있습니다.
    public string extras;
}

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.PUSH_RECEIVED_MESSAGE:
            {
                GamebaseResponse.Event.PushMessage pushMessage = GamebaseResponse.Event.PushMessage.From(message.data);
                if (pushMessage != null)
                {
                    // When you received push message.

                    // By converting the extras field of the push message to JSON,
                    // you can get the custom information added by the user when sending the push.
                    // (For Android, an 'isForeground' field is included so that you can check if received in the foreground state.
                }
                break;
            }
        default:
            {
                break;
            }
    }
}

Push Click Message

  • 수신한 Push 메시지를 클릭했을때 발생하는 이벤트입니다.
  • 'GamebaseEventCategory.PUSH_RECEIVED_MESSAGE'와는 다르게 Android에서 extras 필드에 isForeground 정보가 존재하지 않습니다.

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {
        case GamebaseEventCategory.PUSH_CLICK_MESSAGE:
            {
                GamebaseResponse.Event.PushMessage pushMessage = GamebaseResponse.Event.PushMessage.From(message.data);
                if (pushMessage != null)
                {
                    // When you clicked push message.
                }
                break;
            }
        default:
            {
                break;
            }
    }
}

Push Click Action

  • Rich Message 기능을 통해 생성한 버튼을 클릭했을때 발생하는 이벤트입니다.
  • actionType 은 다음 항목이 제공됩니다.
    • "OPEN_APP"
    • "OPEN_URL"
    • "REPLY"
    • "DISMISS"

VO

class PushAction 
{
    // 버튼 액션 종류입니다.
    public string actionType;

    // PushMessage 데이터입니다.
    public PushMessage message;

    // Push 콘솔에서 입력한 사용자 텍스트입니다.
    public string userText;
}

Example

public void AddEventHandlerSample()
{
    Gamebase.AddEventHandler(GamebaseEventHandler);
}

private void GamebaseEventHandler(GamebaseResponse.Event.GamebaseEventMessage message)
{
    switch (message.category)
    {    
        case GamebaseEventCategory.PUSH_CLICK_ACTION:
            {
                GamebaseResponse.Event.PushAction pushAction = GamebaseResponse.Event.PushAction.From(message.data);
                if (pushAction != null)
                {
                    // When you clicked action button by 'Rich Message'.
                }
                break;
            }
        default:
            {
                break;
            }
    }
}

Analytics

Game지표를 Gamebase Server로 전송할 수 있습니다.

[주의]

Gamebase Analytics에서 지원하는 모든 API는 로그인 후에 호출할 수 있습니다.

[TIP]

Gamebase.Purchase.RequestPurchase API를 호출하여 결제를 완료하면, 자동으로 지표를 전송합니다.

Analytics Console 사용법은 아래 가이드를 참고하십시오.

Game User Data Settings

게임 로그인 이후 게임 유저 레벨 정보를 지표로 전송할 수 있습니다.

[주의]

게임 로그인 이후 SetGameUserData API를 호출하지 않으면 다른 지표에서 Level 정보가 누락될 수 있습니다.

API 호출에 필요한 파라미터는 아래와 같습니다.

GameUserData

Name Mandatory(M) / Optional(O) type Desc
userLevel M int 게임 유저 레벨을 나타내는 필드입니다.
channelId O string 채널을 나타내는 필드입니다.
characterId O string 캐릭터 이름을 나타내는 필드입니다.
characterClassId O string 직업을 나타내는 필드입니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

static void SetGameUserData(GamebaseRequest.Analytics.GameUserData gameUserData)

Example

public void SetGameUserData(int userLevel, string channelId, string characterId, string characterClassId)
{
    GamebaseRequest.Analytics.GameUserData gameUserData = new GamebaseRequest.Analytics.GameUserData(userLevel);
    gameUserData.channelId = channelId;
    gameUserData.characterId = characterId;
    gameUserData.characterClassId = characterClassId;

    Gamebase.Analytics.SetGameUserData(gameUserData);
}

Level Up Trace

레벨업이 되었을 경우 게임 유저 레벨 정보를 지표로 전송할 수 있습니다.

API 호출에 필요한 파라미터는 아래와 같습니다.

LevelUpData

Name Mandatory(M) / Optional(O) type Desc
userLevel M int 게임 유저 레벨을 나타내는 필드입니다.
levelUpTime M long Epoch Time으로 입력합니다.
Millisecond 단위로 입력 합니다.

API

Supported Platforms UNITY_IOS UNITY_ANDROID UNITY_STANDALONE UNITY_WEBGL UNITY_EDITOR

static void TraceLevelUp(GamebaseRequest.Analytics.LevelUpData levelUpData)

Example

public void TraceLevelUp(int userLevel, long levelUpTime)
{
    GamebaseRequest.Analytics.LevelUpData levelUpData = new GamebaseRequest.Analytics.LevelUpData(userLevel, levelUpTime);

    Gamebase.Analytics.TraceLevelUp(levelUpData);
}

Contact

Gamebase 는 고객 문의 대응을 위한 기능을 제공합니다.

[TIP]

NHN Cloud Contact 서비스와 연동해서 사용하면 보다 쉽고 편리하게 고객 문의에 대응할 수 있습니다. 자세한 NHN Cloud Contact 서비스 이용법은 아래 가이드를 참고하시기 바랍니다. NHN Cloud Online Contact Guide

Customer Service Type

Gamebase 콘솔 > App > InApp URL > Service center 에서는 아래와 같이 3가지 유형의 고객 센터를 선택할 수 있습니다.

Customer Service Type Required Login
Developer customer center X
Gamebase customer center
NHN Cloud Online Contact

각 유형에 따라 Gamebase SDK 의 고객 센터 API 는 다음 URL 을 사용합니다.

  • 개발사 자체 고객 센터(Developer customer center)
    • 고객 센터 URL 에 입력한 URL.
  • Gamebase 제공 고객 센터(Gamebase customer center)
    • 로그인 전 : 유저 정보가 없는 고객 센터 URL.
    • 로그인 후 : 유저 정보가 포함된 고객 센터 URL.
  • NHN Cloud 조직 상품(Online Contact)
    • 로그인 전 : 유저 정보가 없는 고객 센터 URL.
    • 로그인 후 : 유저 정보가 포함된 고객 센터 URL.

Open Contact WebView

고객 센터 웹뷰를 표시합니다. URL은 고객 센터 유형에 따라 결정됩니다. ContactConfiguration으로 URL에 추가 정보를 전달할 수 있습니다.

GamebaseRequest.Contact.Configuration

Parameter Mandatory(M) /
Optional(O)
Values Description
userName O string 사용자 이름(닉네임)
default: null
additionalURL O string 개발사 자체 고객 센터 URL 뒤에 붙는 추가적인 URL
default: null
additionalParameters O Dictionary 고객 센터 URL 뒤에 붙는 추가적인 파라미터
default: null
extraData O Dictionary 개발사가 원하는 extra data를 고객 센터 오픈 시에 전달
default: null

API

Supported Platforms UNITY_IOS UNITY_ANDROID UNITY_STANDALONE

static void OpenContact(GamebaseCallback.ErrorDelegate callback);
static void OpenContact(GamebaseRequest.Contact.Configuration configuration, GamebaseCallback.ErrorDelegate callback);

ErrorCode

Error Code Description
NOT_INITIALIZED(1) Gamebase.initialize가 호출되지 않았습니다.
UI_CONTACT_FAIL_INVALID_URL(6911) 고객 센터 URL 이 존재하지 않습니다.
Gamebase 콘솔의 고객 센터 URL 을 확인하세요.
UI_CONTACT_FAIL_ISSUE_SHORT_TERM_TICKET(6912) 사용자 식별을 위한 임시 티켓 발급에 실패하였습니다.
UI_CONTACT_FAIL_ANDROID_DUPLICATED_VIEW(6913) 고객 센터 웹뷰가 이미 표시중입니다.

Example

public void SampleOpenContact()
{
    Gamebase.Contact.OpenContact((error) =>
    {
        if (Gamebase.IsSuccess(error) == true)
        {
            // A user close the contact web view.
        }
        else if (error.code == GamebaseErrorCode.UI_CONTACT_FAIL_INVALID_URL)  // 6911
        {
            // TODO: Gamebase Console Service Center URL is invalid.
            // Please check the url field in the TOAST Gamebase Console.
        } 
        else if (error.code == GamebaseErrorCode.UI_CONTACT_FAIL_ANDROID_DUPLICATED_VIEW) // 6913
        { 
            // The customer center web view is already opened.
        } 
        else 
        {
            // An error occur when opening the contact web view.
        }
    });
}

[주의]

고객 센터 문의 시 파일 첨부가 필요할 수 있습니다. 이를 위해 사용자로부터 카메라 촬영이나 Storage 저장에 대한 권한을 런타임에 획득하여야 합니다.

Android 사용자

iOS 사용자

  • info.plist에 'Privacy - Camera Usage Description', 'Privacy - Photo Library Usage Description' 설정을 해주시기 바랍니다.

Request Contact URL

고객 센터 웹뷰를 표시하는데 사용되는 URL 을 반환합니다.

API

static void RequestContactURL(GamebaseCallback.GamebaseDelegate<string> callback);
static void RequestContactURL(GamebaseRequest.Contact.Configuration configuration, GamebaseCallback.GamebaseDelegate<string> callback);

ErrorCode

Error Code Description
NOT_INITIALIZED(1) Gamebase.initialize가 호출되지 않았습니다.
UI_CONTACT_FAIL_INVALID_URL(6911) 고객 센터 URL 이 존재하지 않습니다.
Gamebase 콘솔의 고객 센터 URL 을 확인하세요.
UI_CONTACT_FAIL_ISSUE_SHORT_TERM_TICKET(6912) 사용자를 식별을 위한 임시 티켓 발급에 실패하였습니다.

Example

public void SampleRequestContactURL()
{
    var configuration = new GamebaseRequest.Contact.Configuration()
                            {
                                userName = "User Name"
                            };

    Gamebase.Contact.RequestContactURL(configuration, (url, error) => 
    {
        if (Gamebase.IsSuccess(error) == true) 
        {
            // Open webview with 'contactUrl'
        } 
        else if (error.code == GamebaseErrorCode.UI_CONTACT_FAIL_INVALID_URL) // 6911
        { 
            // TODO: Gamebase Console Service Center URL is invalid.
            // Please check the url field in the TOAST Gamebase Console.
        } 
        else 
        {
            // An error occur when requesting the contact web view url.
        }
    });
}
TOP