Gamebase에서 지원하는 부가 기능을 설명합니다.
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'를 반환합니다.
점검 팝업 창과 같이 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의 클라이언트에 포함되어 있지 않은 언어셋은 직접 추가할 수 있습니다. 신규 언어셋 추가 항목을 참조하시기 바랍니다.
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를 설정할 수 있습니다.
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));
}
});
}
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);
}
현재 적용된 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에 정의되어 있는 형식은 아래와 같습니다.
{
"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 플랫폼에서의 신규 언어셋 추가 방법은 아래 가이드를 참고하십시오.
초기화 및 SetDisplayLanguageCode API를 통해 Display Language를 설정할 경우, 최종 적용되는 Display Language는 입력한 값과 다르게 적용될 수 있습니다.
en
이 자동으로 설정됩니다.API
Supported Platforms ■ UNITY_IOS ■ UNITY_ANDROID
static string GetCountryCodeOfUSIM()
API
Supported Platforms ■ UNITY_IOS ■ UNITY_ANDROID
static string GetCountryCodeOfDevice()
[참고]
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()
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;
}
}
}
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 버튼 클릭 시 동작합니다. |
[참고]
iOS Appleid 로그인을 사용하는 경우에만 발생할 수 있는 이벤트입니다.
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;
}
}
}
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;
}
}
}
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.
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
Game지표를 Gamebase Server로 전송할 수 있습니다.
[주의]
Gamebase Analytics에서 지원하는 모든 API는 로그인 후에 호출할 수 있습니다.
[TIP]
Gamebase.Purchase.RequestPurchase API를 호출하여 결제를 완료하면, 자동으로 지표를 전송합니다.
Analytics Console 사용법은 아래 가이드를 참고하십시오.
게임 로그인 이후 게임 유저 레벨 정보를 지표로 전송할 수 있습니다.
[주의]
게임 로그인 이후 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);
}
레벨업이 되었을 경우 게임 유저 레벨 정보를 지표로 전송할 수 있습니다.
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);
}
Gamebase 는 고객 문의 대응을 위한 기능을 제공합니다.
[TIP]
NHN Cloud Contact 서비스와 연동해서 사용하면 보다 쉽고 편리하게 고객 문의에 대응할 수 있습니다. 자세한 NHN Cloud Contact 서비스 이용법은 아래 가이드를 참고하시기 바랍니다. NHN Cloud Online Contact Guide
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 을 사용합니다.
고객 센터 웹뷰를 표시합니다. 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 사용자
Unity 사용자는 아래 가이드를 참조하여 구현할 수 있습니다. Unity Guide : Requesting Permissions
iOS 사용자
- info.plist에 'Privacy - Camera Usage Description', 'Privacy - Photo Library Usage Description' 설정을 해주시기 바랍니다.
고객 센터 웹뷰를 표시하는데 사용되는 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.
}
});
}