This document describes additional features supported by Gamebase.
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID ■ UNREAL_WINDOWS
FString GetDeviceLanguageCode() const;
[Note]
Gamebase client messages are available in English (en), Korean (ko), and Japanese (ja) only.
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 |
Each language code is defined in the GamebaseDisplayLanguageCode
class.
[Caution]
Gamebase-supported language codes are case-sensitive. Settings like 'EN' or 'zh-cn' may cause trouble.
namespace GamebaseDisplayLanguageCode
{
static const FString German(TEXT("de"));
static const FString English(TEXT("en"));
static const FString Spanish(TEXT("es"));
static const FString Finnish(TEXT("fi"));
static const FString French(TEXT("fr"));
static const FString Indonesian(TEXT("id"));
static const FString Italian(TEXT("it"));
static const FString Japanese(TEXT("ja"));
static const FString Korean(TEXT("ko"));
static const FString Portuguese(TEXT("pt"));
static const FString Russian(TEXT("ru"));
static const FString Thai(TEXT("th"));
static const FString Vietnamese(TEXT("vi"));
static const FString Malay(TEXT("ms"));
static const FString Chinese_Simplified(TEXT("zh-CN"));
static const FString Chinese_Traditional(TEXT("zh-TW"));
}
Display Language can be configured when Gamebase is initialized.
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID
void Initialize(const FGamebaseConfiguration& configuration, const FGamebaseLaunchingInfoDelegate& onCallback);
Example
void Sample::Initialize(const FString& appID, const FString& appVersion)
{
FGamebaseConfiguration configuration;
...
configuration.displayLanguageCode = displayLanguage;
...
IGamebase::Get().Initialize(configuration, FGamebaseLaunchingInfoDelegate::CreateLambda([=](const FGamebaseLaunchingInfo* launchingInfo, const FGamebaseError* error)
{
if (Gamebase::IsSuccess(error))
{
UE_LOG(GamebaseTestResults, Display, TEXT("Initialize succeeded."));
FString displayLanguage = IGamebase::Get().GetDisplayLanguageCode();
}
else
{
UE_LOG(GamebaseTestResults, Display, TEXT("Initialize failed."));
}
}));
}
Display Language can be changed from Gamebase initialization.
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID ■ UNREAL_WINDOWS
void SetDisplayLanguageCode(const FString& languageCode);
Example
void Sample::SetDisplayLanguageCode(cosnt FString& displayLanguage)
{
FString displayLanguage = IGamebase::Get().SetDisplayLanguageCode(displayLanguage);
}
Current Display Language can be queried.
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID ■ UNREAL_WINDOWS
FString GetDisplayLanguageCode() const;
Example
void Sample::GetDisplayLanguageCode()
{
FString displayLanguage = IGamebase::Get().GetDisplayLanguageCode();
}
Regarding how to add new language sets on Unreal Android or iOS platform, see the following guides:
When Display Language is set by initialization or SetDisplayLanguageCode API, the final value might be different from actual input.
en
is automatically set for Display Language. API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID
FString GetCountryCodeOfUSIM() const;
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID
FString GetCountryCodeOfDevice() const;
API
■ UNREAL_IOS ■ UNREAL_ANDROID
FString GetCountryCode() const;
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID ■ UNREAL_WINDOWS
FDelegateHandle AddHandler(const FGamebaseEventDelegate::FDelegate& onCallback);
void RemoveHandler(const FDelegateHandle& handle);
void RemoveAllHandler();
VO
struct GAMEBASE_API FGamebaseEventMessage
{
// Represents the type of an event.
// The value of the GamebaseEventCategory class is assigned.
FString category;
// JSON String data that can be converted into a VO that is appropriate for each category.
FString data;
};
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::IdPRevoked))
{
auto idPRevokedData = FGamebaseEventIdPRevokedData::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::LoggedOut))
{
auto loggedOutData = FGamebaseEventLoggedOutData::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::ServerPushAppKickOut) ||
message.category.Equals(GamebaseEventCategory::ServerPushAppKickOutMessageReceived) ||
message.category.Equals(GamebaseEventCategory::ServerPushTransferKickout))
{
auto serverPushData = FGamebaseEventServerPushData::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::ObserverLaunching))
{
auto observerData = FGamebaseEventObserverData::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::ObserverNetwork))
{
auto observerData = FGamebaseEventObserverData::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::ObserverHeartbeat))
{
auto observerData = FGamebaseEventObserverData::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::PurchaseUpdated))
{
auto purchasableReceipt = FGamebaseEventPurchasableReceipt::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::PushReceivedMessage))
{
auto pushMessage = FGamebaseEventPushMessage::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::PushClickMessage))
{
auto pushMessage = FGamebaseEventPushMessage::From(message.data);
}
else if (message.category.Equals(GamebaseEventCategory::PushClickAction))
{
auto pushAction = FGamebaseEventPushAction::From(message.data);
}
}));
}
Event type | GamebaseEventCategory | VO conversion method | Remarks |
---|---|---|---|
IdPRevoked | GamebaseEventCategory::IdPRevoked | FGamebaseEventIdPRevokedData::From(message.data) | - |
LoggedOut | GamebaseEventCategory::LoggedOut | FGamebaseEventLoggedOutData::From(message.data) | - |
ServerPush | GamebaseEventCategory::ServerPushAppKickOut GamebaseEventCategory::ServerPushAppKickOutMessageReceived GamebaseEventCategory::ServerPushTransferKickout |
FGamebaseEventServerPushData::From(message.data) | - |
Observer | GamebaseEventCategory::ObserverLaunching GamebaseEventCategory::ObserverNetwork GamebaseEventCategory::ObserverHeartbeat |
FGamebaseEventObserverData::From(message.data) | - |
Purchase - Promotion payment | GamebaseEventCategory::PurchaseUpdated | FGamebaseEventPurchasableReceipt::From(message.data) | - |
Push - Message received | GamebaseEventCategory::PushReceivedMessage | FGamebaseEventPushMessage::From(message.data) | |
Push - Message clicked | GamebaseEventCategory::PushClickMessage | FGamebaseEventPushMessage::From(message.data) | |
Push - Action clicked | GamebaseEventCategory::PushClickAction | FGamebaseEventPushAction::From(message.data) | Operates when the RichMessage button is clicked. |
[Note]
This is an event that can only occur when using iOS Appleid login.
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::IdPRevoked))
{
auto idPRevokedData = FGamebaseEventIdPRevokedData::From(message.data);
if (idPRevokedData.IsValid())
{
ProcessIdPRevoked(idPRevokedData);
}
}
}));
}
void Sample::ProcessIdPRevoked(const FGamebaseEventIdPRevokedData& data)
{
auto revokedIdP = data->idPType;
switch (data->code)
{
// Indicates that the user is logged in with a revoked IdP, and there is no list of mapped IdPs.
// Notifies the user that the current account has been deleted.
case GamebaseIdPRevokeCode::Withdraw:
{
IGamebase::Get().Withdraw(FGamebaseErrorDelegate::CreateLambda([=](const FGamebaseError* error)
{
...
}));
break;
}
case GamebaseIdPRevokeCode::OverwriteLoginAndRemoveMapping:
{
// Indicates that the user is logged in with a revoked IdP and IdPs other than the revoked IdP are mapped.
// Allows the user to select an IdP to login in to among the authMappingList, and removes mapping with the revoked IdP after login with the selected IdP.
auto selectedIdP = "the IdP selected by the user";
auto additionalInfo = NewObject<UGamebaseJsonObject>();
additionalInfo->SetBoolField(GamebaseAuthProviderCredential::IgnoreAlreadyLoggedIn, true);
IGamebase::Get().Login(selectedIdP, *additionalInfo, FGamebaseAuthTokenDelegate::CreateLambda([=](const FGamebaseAuthToken* authToken, const FGamebaseError* error)
{
if (Gamebase::IsSuccess(error))
{
IGamebase::Get().RemoveMapping(revokedIdP, FGamebaseErrorDelegate::CreateLambda([=](const FGamebaseError* error)
{
...
}));
}
}));
break;
}
case GamebaseIdPRevokeCode::RemoveMapping:
{
// Indicates that there is a revoked IdP among IdPs mapped to the current account.
// Notifies the user that mapping with the revoked IdP is removed from the current account.
IGamebase::Get().RemoveMapping(revokedIdP, FGamebaseErrorDelegate::CreateLambda([=](const FGamebaseError* error)
{
...
}));
break;
}
}
}
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::LoggedOut))
{
auto loggedOutData = FGamebaseEventLoggedOutData::From(message.data);
if (loggedData.IsValid() == true)
{
// There was a problem with the access token.
// Call login again.
}
}
}));
}
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::ServerPushAppKickOut) ||
message.category.Equals(GamebaseEventCategory::ServerPushAppKickOutMessageReceived) ||
message.category.Equals(GamebaseEventCategory::ServerPushTransferKickout))
{
auto serverPushData = FGamebaseEventServerPushData::From(message.data);
if (serverPushData.IsVaild())
{
CheckServerPush(message.category, *serverPushData);
}
}
}));
}
void Sample::CheckServerPush(const FString& category, const FGamebaseEventServerPushData& data)
{
if (message.category.Equals(GamebaseEventCategory::ServerPushAppKickOut))
{
// 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 (message.category.Equals(GamebaseEventCategory::ServerPushAppKickOutMessageReceived))
{
// Currently, the kickout pop-up is displayed.
// If your game is running, stop it.
}
else if (message.category.Equals(GamebaseEventCategory::ServerPushTransferKickout))
{
// 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.
}
}
struct GAMEBASE_API FGamebaseEventObserverData
{
// This information represents the status value.
int32 code;
// This information shows the message about status.
FString message;
// A reserved field for additional information.
FString extras;
}
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::ObserverLaunching))
{
auto observerData = FGamebaseEventObserverData::From(message.data);
if (observerData.IsVaild())
{
CheckLaunchingStatus(*observerData);
}
}
else if (message.category.Equals(GamebaseEventCategory::ObserverNetwork))
{
auto observerData = FGamebaseEventObserverData::From(message.data);
if (observerData.IsVaild())
{
CheckNetwork(*observerData);
}
}
else if (message.category.Equals(GamebaseEventCategory::ObserverHeartbeat))
{
auto observerData = FGamebaseEventObserverData::From(message.data);
if (observerData.IsVaild())
{
CheckHeartbeat(*observerData);
}
}
}));
}
void Sample::CheckLaunchingStatus(const FGamebaseEventObserverData& data)
{
switch (data.code)
{
case GamebaseLaunchingStatus::IN_SERVICE:
{
// Service is now normally provided.
break;
}
// ...
case GamebaseLaunchingStatus::INTERNAL_SERVER_ERROR:
{
// Error in internal server.
break;
}
}
}
void Sample::CheckNetwork(const FGamebaseEventObserverData& data)
{
switch ((GamebaseNetworkType)data.code)
{
case EGamebaseNetworkType::Not:
{
// Network disconnected.
break;
}
case EGamebaseNetworkType::Mobile:
case EGamebaseNetworkType::Wifi:
case EGamebaseNetworkType::Any:
{
// Network connected.
break;
}
}
}
void Sample::CheckHeartbeat(const FGamebaseEventObserverData& data)
{
switch (data.code)
{
case EGGamebaseErrorCode::INVALID_MEMBER:
{
// You can check the invalid user session in here.
// ex) After transferred account to another device.
break;
}
case EGGamebaseErrorCode::BANNED_MEMBER:
{
// You can check the banned user session in here.
break;
}
}
}
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::PurchaseUpdated))
{
auto purchasableReceipt = FGamebaseEventPurchasableReceipt::From(message.data);
if (purchasableReceipt.IsVaild())
{
// If the user got item by 'Promotion Code',
// this event will be occurred.
}
}
}));
}
VO
struct FGamebaseEventPushMessage
{
// The unique ID of a message.
FString id;
// The title of the push message.
FString title;
// The body of the push message.
FString body;
// You can check the custom information sent when sending a push in JSON format.
FString extras;
};
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::PushReceivedMessage))
{
auto pushMessage = FGamebaseEventPushMessage::From(message.data);
if (pushMessage.IsVaild())
{
// When you clicked 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.)
}
}
}));
}
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::PushClickMessage))
{
auto pushMessage = FGamebaseEventPushMessage::From(message.data);
if (pushMessage.IsVaild())
{
// When you clicked push message.
}
}
}));
}
VO
struct FGamebaseEventPushAction
{
// Button action type.
FString actionType;
// PushMessage data.
FGamebaseEventPushMessage message;
// User text typed in Push console.
FString userText;
};
Example
void Sample::AddEventHandler()
{
IGamebase::Get().AddEventHandler(FGamebaseEventDelegate::FDelegate::CreateLambda([=](const FGamebaseEventMessage& message)
{
if (message.category.Equals(GamebaseEventCategory::PushClickAction))
{
auto pushAction = FGamebaseEventPushAction::From(message.data);
if (pushAction.IsVaild())
{
// When you clicked action button by 'Rich Message'.
}
}
}));
}
Game indicators can be sent to Gamebase Server.
[Caution]
All APIs supported by Gamebase Analytics can be called after login.
[TIP]
When a purchase is completed by calling RequestPurchase API, indicators are automatically deliverd.
Regarding the usage of Analytics Console, see the following guide:
Level information of a game user can be delivered to indicators, after a user login.
[Caution]
If SetGameUserData API is not called after a login to game, level information might be missing from other indicators.
Following parameters are required to call APIs:
FGamebaseAnalyticsUserData
Name | Mandatory(M) / Optional(O) | Type | Desc. |
---|---|---|---|
userLevel | M | int32 | Refers to the level of a game user. |
channelId | O | FString | Indicates a channel. |
characterId | O | FString | Refers to the name of a character. |
characterClassId | O | FString | Indicates an occupation. |
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID ■ UNREAL_WINDOWS
void SetGameUserData(const FGamebaseAnalyticsUserData& gameUserData);
Example
void Sample::SetGameUserData(int32 userLevel, const FString& channelId, const FString& characterId, const FString& characterClassId)
{
FGamebaseAnalyticsUserData gameUserData{ userLevel, channelId, characterId, characterClassId };
IGamebase::Get().GetAnalytics().SetGameUserData(gameUserData);
}
Updated level information of a game user can be delivered to indicators.
Following paratemers are required to call APIs:
LevelUpData
Name | Mandatory(M) / Optional(O) | Type | Desc. |
---|---|---|---|
userLevel | M | int32 | Refers to the level of a game user. |
levelUpTime | M | int64 | Enter by Epoch Time. Enter by the millisecond. |
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID ■ UNREAL_WINDOWS
void TraceLevelUp(const FGamebaseAnalyticesLevelUpData& levelUpData);
Example
void Sample::TraceLevelUpNow(int32 userLevel)
{
FGamebaseAnalyticesLevelUpData levelUpData{ userLevel, FDateTime::Now().ToUnixTimestamp() };
IGamebase::Get().GetAnalytics().TraceLevelUp(levelUpData);
}
Gamebase provides features for customer response.
[TIP]
By integrating with NHN Cloud Contact, customer inquiries can be handled with more ease and convenience.
For more details on NHN Cloud Contact, see the guide as below: NHN Cloud Online Contact Guide
In the Gamebase Console > App > InApp URL > Service Center, you can choose from three different types of Customer Centers.
Customer Service Type | Required Login |
---|---|
Developer customer center | X |
Gamebase customer center | △ |
NHN Cloud Online Contact | O |
Gamebase SDK's Customer Center API uses the following URLs based on the type:
Displays the Customer Center WebView. URL is determined by the customer center type. You can pass the additional information to the URL using ContactConfiguration.
FGamebaseContactConfiguration
Parameter | Mandatory(M) / Optional(O) |
Values | Description |
---|---|---|---|
userName | O | FString | User name (nickname) default: "" |
additionalURL | O | FString | Additional URL appended to the developer's own customer center URL default: "" |
additionalParameters | O | TMap |
Additional parameters appended to the customer center URL default : EmptyMap |
extraData | O | TMap |
Passes the extra data wanted by the developer when opening the customer center default: EmptyMap |
API
Supported Platforms ■ UNREAL_IOS ■ UNREAL_ANDROID ■ UNREAL_WINDOWS
void OpenContact(const FGamebaseErrorDelegate& onCloseCallback);
void OpenContact(const FGamebaseContactConfiguration& configuration, const FGamebaseErrorDelegate& onCloseCallback);
ErrorCode
Error Code | Description |
---|---|
NOT_INITIALIZED(1) | Gamebase.initialize has not been called. |
NOT_LOGGED_IN(2) | The customer center type is 'NHN Cloud OC', and it was called before login. |
UI_CONTACT_FAIL_INVALID_URL(6911) | The Customer Center URL does not exist. Check the Customer Center URL of the Gamebase Console. |
UI_CONTACT_FAIL_ISSUE_SHORT_TERM_TICKET(6912) | Failed to issue a temporary ticket for user identification. |
UI_CONTACT_FAIL_ANDROID_DUPLICATED_VIEW(6913) | The Customer Center WebView is already being displayed. |
Example
void Sample::OpenContact()
{
IGamebase::Get().GetContact().OpenContact(FGamebaseErrorDelegate::CreateLambda([=](const FGamebaseError* error)
{
if (Gamebase::IsSuccess(error))
{
UE_LOG(GamebaseTestResults, Display, TEXT("OpenContact succeeded."));
}
else
{
UE_LOG(GamebaseTestResults, Display, TEXT("OpenContact failed. (errorCode: %d, errorMessage: %s)"), error->code, *error->message);
if (error->code == GamebaseErrorCode::WEBVIEW_INVALID_URL)
{
// Gamebase Console Service Center URL is invalid.
// Please check the url field in the NHN Cloud Gamebase Console.
auto launchingInfo = IGamebase::Get().GetLaunching().GetLaunchingInformations();
UE_LOG(GamebaseTestResults, Display, TEXT("csUrl: %s"), *launchingInfo->launching.app.relatedUrls.csUrl);
}
}
}));
}
[Caution]
Contacting the Customer Center may require file attachment. To do so, permissions for using the camera or using the storage must be acquired from the user at runtime.
Android user
For Unreal, activate the built-in Android Runtime Permission plugin in the engine, and then refer to the following API Reference to acquire necessary permissions. Unreal API Reference : AndroidPermission
iOS user
- Please set 'Privacy - Camera Usage Description', 'Privacy - Photo Library Usage Description' in info.plist.
Returns the URL used for displaying the Customer Center WebView.
API
void RequestContactURL(const FGamebaseContactUrlDelegate& onCallback);
void RequestContactURL(const FGamebaseContactConfiguration& configuration, const FGamebaseContactUrlDelegate& onCallback);
ErrorCode
Error Code | Description |
---|---|
NOT_INITIALIZED(1) | Gamebase.initialize has not been called. |
NOT_LOGGED_IN(2) | The customer center type is 'NHN Cloud OC', and it was called before login. |
UI_CONTACT_FAIL_INVALID_URL(6911) | The Customer Center URL does not exist. Check the Customer Center URL of the Gamebase Console. |
UI_CONTACT_FAIL_ISSUE_SHORT_TERM_TICKET(6912) | Failed to issue a temporary ticket for user identification. |
Example
void Sample::RequestContactURL(const FString& userName)
{
FGamebaseContactConfiguration configuration{ userName };
IGamebase::Get().GetContact().RequestContactURL(configuration, FGamebaseContactUrlDelegate::CreateLambda([=](FString url, const FGamebaseError* error)
{
if (Gamebase::IsSuccess(error))
{
// Open webview with 'contactUrl'
UE_LOG(GamebaseTestResults, Display, TEXT("RequestContactURL succeeded. (url = %s)"), *url);
}
else
{
UE_LOG(GamebaseTestResults, Display, TEXT("RequestContactURL failed. (errorCode: %d, errorMessage: %s)"), error->code, *error->message);
if (error->code == GamebaseErrorCode::UI_CONTACT_FAIL_INVALID_URL)
{
// Gamebase Console Service Center URL is invalid.
// Please check the url field in the NHN Cloud Gamebase Console.
}
else
{
// An error occur when requesting the contact web view url.
}
}
}));
}