Game > Gamebase > Unreal SDKご利用ガイド > UI

ImageNotice

コンソールにイメージを登録した後、ユーザーに告知を表示できます。

ImageNotice Example

Show ImageNotices

イメージ告知を画面に表示します。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID UNREAL_WINDOWS

void ShowImageNotices(FGamebaseImageNoticeConfiguration& configuration, const FGamebaseErrorDelegate& onCloseCallback);
void ShowImageNotices(FGamebaseImageNoticeConfiguration& configuration, const FGamebaseErrorDelegate& onCloseCallback, const FGamebaseImageNoticeEventDelegate& onEventCallback);

Example

void Sample::ShowImageNotices(int32 colorR, int32 colorG, int32 colorB, int32 colorA, int64 timeOut)
{
    FGamebaseImageNoticeConfiguration configuration{ colorR, colorG, colorB, colorA, timeOut };

    IGamebase::Get().GetImageNotice().ShowImageNotices(configuration,
        FGamebaseErrorDelegate::CreateLambda([=](const FGamebaseError* error) {
            // Called when the entire imageNotice is closed.
            ...
        }),
        FGamebaseSchemeEventDelegate::CreateLambda([=](const FString& scheme, const FGamebaseError* error) {
            // Called when custom event occurred.
            ...
        })
    );
}

FGamebaseImageNoticeConfiguration

Parameter Values Description
colorR 0~255 バックグラウンドの色R
colorG 0~255 バックグラウンドの色G
colorB 0~255 バックグラウンドの色B
colorA 0~255 バックグラウンドの色Alpha
timeOut int64 イメージ告知最大ローディング時間(単位: millisecond)
default: 5000

Close ImageNotices

closeImageNotices APIを呼び出して現在表示中のイメージ告知を全て終了できます。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID

void CloseImageNotices();

Terms

Gamebaseコンソールに設定した約款を表示します。

TermsView Example

ShowTermsView APIは、Webビューで約款ウィンドウを表示します。 GameのUIに合った約款ウィンドウを直接製作したい場合には、QueryTerms APIを呼び出して、 Gamebaseコンソールに設定した約款項目を呼び出すことができます。 ユーザーが約款に同意した場合、各項目の同意有無をUpdateTerms APIを介してGamebaseサーバーに転送してください。

ShowTermsView

約款ウィンドウを画面に表示します。 ユーザーが約款に同意した場合、同意の有無をサーバーに登録します。 約款に同意した場合、ShowTermsView APIを再度呼び出しても約款ウィンドウが表示されず、すぐに成功コールバックが返されます。 ただし、Gamebaseコンソールで約款再同意項目を必要に変更すると、ユーザーが再度約款に同意するまでは約款ウィンドウが表示されます。

[注意]

  • FGamebasePushConfigurationは、約款ウィンドウが表示されていない場合にはnullです(約款ウィンドウが表示された場合、常に有効なオブジェクトが返されます。)。
  • FGamebasePushConfiguration.pushEnabled値は常にtrueです。
  • FGamebasePushConfigurationがnullではない場合、ログイン後に IGamebase::Get().GetPush().RegisterPush()を呼び出してください。

Optionalパラメータ

  • GamebaseTermsConfiguration : GamebaseTermsConfigurationオブジェクトを介して強制的に約款同意ウィンドウを表示するかどうかなどの設定を変更できます。
  • callback:約款同意後、約款ウィンドウが終了する時、ユーザーにコールバックで伝えます。コールバックで来るGamebaseResponse.DataContainerオブジェクトはGamebaseResponse.Push.PushConfiguration変換してログイン後、Gamebase.Push.RegisterPush APIに使用できます。

FGamebaseTermsConfiguration

API Mandatory(M) / Optional(O) Description
forceShow O 約款に同意した場合、showTermsView APIを再度呼び出しても約款ウィンドウが表示されませんが、これを無視して強制的に約款ウィンドウを表示します。
default : false
enableFixedFontSize O 約款ウィンドウのフォントサイズを固定するかどうかを決定します。
default:false
Android Only

FGamebaseShowTermsViewResult

Parameter Values Description
isTermsUIOpened bool true:約款ウィンドウが表示され、ユーザーが同意して約款ウィンドウが終了しました。
false:すでに約款に同意していて、約款ウィンドウが表示されずに約款ウィンドウが終了しました。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID

void ShowTermsView(const FGamebaseDataContainerDelegate& onCallback);
void ShowTermsView(const FGamebaseTermsConfiguration& configuration, const FGamebaseDataContainerDelegate& onCallback);

ErrorCode

Error Error Code Description
NOT_INITIALIZED 1 Gamebaseが初期化されていません。
LAUNCHING_SERVER_ERROR 2001 ローンチサーバーからダウンロードした項目に約款関連内容がない場合に発生するエラーです。
正常な状況ではないため、Gamebase担当者にお問い合わせください。
UI_TERMS_ALREADY_IN_PROGRESS_ERROR 6924 以前に呼び出されたTerms APIがまだ完了していません。
しばらくしてから再度試行してください。
UI_TERMS_ANDROID_DUPLICATED_VIEW 6925 約款Webビューが終了していないのに再び呼び出されました。
WEBVIEW_TIMEOUT 7002 約款Webビューの表示中にタイムアウトが発生しました。
WEBVIEW_HTTP_ERROR 7003 約款Webビューのオープン中にHTTPエラーが発生しました。

Example

void Sample::ShowTermsView()
{
    FGamebaseTermsConfiguration configuration { true };

    IGamebase::Get().GetTerms().ShowTermsView(configuration,
        FGamebaseDataContainerDelegate::CreateLambda([=](const FGamebaseDataContainer* dataContainer, const FGamebaseError* error) {
            if (Gamebase::IsSuccess(error))
            {
                UE_LOG(GamebaseTestResults, Display, TEXT("ShowTermsView succeeded."));

                const auto result = FGamebaseShowTermsResult::From(dataContainer);
                if (result.IsValid())
                {
                    // Save the 'PushConfiguration' and use it for RegisterPush() after Login().
                    savedPushConfiguration = FGamebasePushConfiguration::From(dataContainer);
                }
            }
            else
            {
                UE_LOG(GamebaseTestResults, Display, TEXT("ShowTermsView failed. (error: %d)"), error->code);
            }
        })
    );
}

void Sample::AfterLogin()
{
    // Call RegisterPush with saved PushConfiguration.
    if (savedPushConfiguration != null)
    {
        Gamebase.Push.RegisterPush(savedPushConfiguration, (error) =>
        {
            ...
        });
    }
}

QueryTerms

Gamebaseは、単純な形式のWebビューで約款を表示します。 ゲームのUIに合った約款を直接製作したい場合、QueryTerms APIを呼び出してGamebaseコンソールに設定した約款情報を取得して活用できます。

ログイン後に呼び出す場合は、ゲームユーザーが約款に同意したかどうかも一緒に確認できます。

[注意]

  • GamebaseResponse.Terms.ContentDetail.requiredがtrueの必須項目はGamebaseサーバーに保存されないため、agreed値は常にfalseが返されます。
    • 必須項目は常にtrueで保存されるので、保存する意味がないためです。
  • プッシュ受信同意状況もGamebaseサーバーに保存されないため、agreed値は常にfalseが返されます。
    • ユーザーのプッシュ受信同意状況は、Gamebase.Push.QueryPush APIを通して確認してください。
  • コンソールで「基本約款設定」を行わない場合、約款言語と異なる国コードに設定された端末でqueryTerms APIを呼び出すと、UI_TERMS_NOT_EXIST_FOR_DEVICE_COUNTRY(6922)エラーが発生します。
    • コンソールで「基本約款設定」を行ったり、UI_TERMS_NOT_EXIST_FOR_DEVICE_COUNTRY(6922)エラーが発生した時は、約款を表示しないように処理してください。

Requiredパラメータ

  • callback:API呼び出し結果をユーザーにコールバックで伝えます。コールバックで来るGamebaseResponse.Terms.QueryTermsResultでコンソールに設定された約款情報を取得できます。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID UNREAL_WINDOWS

void QueryTerms(const FGamebaseQueryTermsResultDelegate& onCallback);

ErrorCode

Error Error Code Description
NOT_INITIALIZED 1 Gamebaseが初期化されていません。
UI_TERMS_NOT_EXIST_IN_CONSOLE 6921 約款情報がコンソールに登録されていません。
UI_TERMS_NOT_EXIST_FOR_DEVICE_COUNTRY 6922 端末国コードに合った約款情報がコンソールに登録されていません。

Example

void Sample::QueryTerms()
{
    IGamebase::Get().GetTerms().QueryTerms(
        FGamebaseQueryTermsResultDelegate::CreateLambda([=](const FGamebaseQueryTermsResult* data, const FGamebaseError* error) {
            if (Gamebase::IsSuccess(error))
            {
                UE_LOG(GamebaseTestResults, Display, TEXT("QueryTerms succeeded."));
            }
            else
            {
                UE_LOG(GamebaseTestResults, Display, TEXT("QueryTerms failed. (error: %d)"), error->code);
            }
        })
    );
}

GamebaseResponse.Terms.QueryTermsResult

Parameter Values Description
termsSeq int32 約款全体KEY.
updateTerms APIの呼び出し時に必要な値です。
termsVersion FString 約款バージョン。
updateTerms APIの呼び出し時に必要な値です。
termsCountryType FString 約款タイプ。
- KOREAN:韓国約款
- GDPR:EU約款
- ETC:その他約款
contents TArray 約款項目情報

GamebaseResponse.Terms.ContentDetail

Parameter Values Description
termsContentSeq int32 約款項目KEY
name FString 約款項目名
required bool 同意必須かどうか
agreePush FString 広告性プッシュ同意状況
- NONE:同意しない
- ALL:全て同意
- DAY:1週間プッシュ同意
- NIGHT:夜間プッシュ同意
agreed bool 該当約款項目に対するユーザーの同意有無
node1DepthPosition int32 1段階項目表示順序。
node2DepthPosition int32 2段階項目表示順序。
ない場合 -1
detailPageUrl FString 約款詳細表示URL。
ない場合null

UpdateTerms

QueryTerms APIで取得した約款情報でUIを直接製作した場合、 ゲームユーザーが約款に同意した内容をUpdateTerms APIを通してGamebaseサーバーに転送してください。

選択約款同意をキャンセルするように、約款に同意した内容を変更する目的でも活用できます。

[注意]

プッシュ受信同意状況はGamebaseサーバーに保存されません。 プッシュ受信同意状況はログイン後に Gamebase.Push.RegisterPush APIを呼び出して保存してください。

Requiredパラメータ

  • configuration:サーバーに登録するユーザーの選択約款情報です。

Optionalパラメータ

  • callback:選択約款情報をサーバーに登録後、ユーザーにコールバックで伝えます。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID UNREAL_WINDOWS

void UpdateTerms(const FGamebaseUpdateTermsConfiguration& configuration, const FGamebaseErrorDelegate onCallback);

ErrorCode

Error Error Code Description
NOT_INITIALIZED 1 Gamebaseが初期化されていません。
UI_TERMS_UNREGISTERED_SEQ 6923 登録されていない約款Seq値を設定しました。
UI_TERMS_ALREADY_IN_PROGRESS_ERROR 6924 以前に呼び出されたTerms APIがまだ完了していません。
しばらくしてから再度試行してください。

Example

void Sample::UpdateTerms(int32 termsSeq, const FString& termsVersion, int32 termsContentSeq, bool agreed)
{
    TArray<FGamebaseTermsContent> contents;
    contents.Add(FGamebaseTermsContent { termsContentSeq, agreed });

    IGamebase::Get().GetTerms().UpdateTerms(
        FGamebaseUpdateTermsConfiguration { termsSeq, termsVersion, contents },
        FGamebaseErrorDelegate::CreateLambda([=](const FGamebaseError* error) {
            if (Gamebase::IsSuccess(error))
            {
                UE_LOG(GamebaseTestResults, Display, TEXT("UpdateTerms succeeded."));
            }
            else
            {
                UE_LOG(GamebaseTestResults, Display, TEXT("UpdateTerms failed. (error: %d)"), error->code);
            }
        })
    );
}

GamebaseRequest.Terms.UpdateTermsConfiguration

Parameter Mandatory(M) / Optional(O) Values Description
termsVersion M FString 約款バージョン。
queryTerms APIを呼び出して取得した値を伝達する必要があります。
termsSeq M int32 約款全体KEY.
queryTerms APIを呼び出して取得した値を伝達する必要があります。
contents M List< Content > 選択約款ユーザー同意情報

GamebaseRequest.Terms.Content

Parameter Mandatory(M) / Optional(O) Values Description
termsContentSeq M int32 選択約款項目KEY
agreed M bool 選択約款項目同意状況

IsShowingTermsView

現在約款ウィンドウが画面に表示されているかどうかを知ることができます。

API

bool IsShowingTermsView();

Example

void Sample::IsShowingTermsView()
{
    bool isShowingTermsView = IGamebase::Get().GetTerms().IsShowingTermsView();
    UE_LOG(GamebaseTestResults, Display, TEXT("IsShowingTermsView : %s"), isShowingTermsView ? TEXT("true") : TEXT("false"));
}

Webview

Show WebView

WebViewを表示します。

Requiredパラメータ
  • url:パラメータに転送されるurlは、有効な値である必要があります。
Optionalパラメータ(現在はRequireパラメータですが、今後のバージョンでOptionalに変更予定)
  • configuration:GamebaseWebViewConfigurationでWebViewのレイアウトを変更できます。
  • closeCallback:WebViewが終了する時、ユーザーにコールバックで伝えます。
  • schemeList:ユーザーが受け取りたいカスタムSchemeリストを指定します。
  • schemeEvent:schemeListに指定したカスタムスキームを含むurlをコールバックで伝えます。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID UNREAL_WINDOWS

void ShowWebView(const FString& url, const FGamebaseWebViewConfiguration& configuration, FGamebaseErrorDelegate& onCloseCallback, const TArray<FString>& schemeList, const FGamebaseSchemeEventDelegate& onSchemeEvent);

Example

void Sample::ShowWebView(const FString& url)
{
    FGamebaseWebViewConfiguration configuration{ TEXT("Title"), GamebaseScreenOrientation::Unspecified, 128, 128, 128, 255, 40, true, "", "" };

    TArray<FString> schemeList{ TEXT("customScheme://openBrowser") };

    IGamebase::Get().GetWebView().ShowWebView(url, configuration,
        FGamebaseErrorDelegate::CreateLambda([=](const FGamebaseError* error) {
            Result(ANSI_TO_TCHAR(__FUNCTION__), TEXT("Close webview"));
        }),
        schemeList,
        FGamebaseSchemeEventDelegate::CreateLambda([=](const FString& scheme, const FGamebaseError* error) {
        if (Gamebase::IsSuccess(error))
        {
            Result(ANSI_TO_TCHAR(__FUNCTION__), true, *FString::Printf(TEXT("scheme= %s"), *scheme));
        }
        else
        {
            Result(ANSI_TO_TCHAR(__FUNCTION__), false, GamebaseJsonUtil::UStructToJsonObjectString(*error));
        }
    }));
}

FGamebaseWebViewConfiguration

Parameter Values Description
title FString WebViewのタイトル
orientation GamebaseScreenOrientation::Unspecified 未指定(default)
GamebaseScreenOrientation::Portrait 縦モード
GamebaseScreenOrientation::Landscape 横モード
GamebaseScreenOrientation::LandscapeReverse 横モードを180度回転
contentMode GamebaseWebViewContentMode::Recommended 現在のプラットフォームの推薦ブラウザ(default)
GamebaseWebViewContentMode::Mobile モバイルブラウザ
GamebaseWebViewContentMode::Desktop デスクトップブラウザ
colorR 0~255 ナビゲーションバーの色相R
default : 18
colorG 0~255 ナビゲーションバーの色相G
default : 93
colorB 0~255 ナビゲーションバーの色相B
default : 230
colorA 0~255 ナビゲーションバーの色相Alpha
default : 255
barHeight height ナビゲーションバーの高さ
Android Only
isNavigationBarVisible true or false ナビゲーションバー有効/無効
default : true
isBackButtonVisible true or false 戻るボタン有効/無効
default : true
backButtonImageResource ID of resource 戻るボタンのイメージ
closeButtonImageResource ID of resource 閉じるボタンのイメージ
enableFixedFontSize true or false 約款ウィンドウの文字サイズを固定するかどうかを決定します。
default: false
Android限定
renderOutSideSafeArea true or false Safe Area領域外までレンダリングするかどうかを決定します。
default: false
Android限定

[TIP]

iPadOS 13以上でWebViewは基本的にデスクトップモードです。 contentMode =GamebaseWebViewContentMode::MOBILE設定でモバイルモードに変更できます。

Predefined Custom Scheme

Gamebaseで指定しておいたスキームです。

scheme 用途
gamebase://dismiss WebViewを閉じる
gamebase://getMaintenanceInfo メンテナンス内容をWebPageに表示
gamebase://getUserId 現在ログインしているゲームユーザーのユーザーIDを表示
gamebase://goBack WebView戻る

Close WebView

次のAPIを利用して、表示されているWebViewを閉じることができます。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID UNREAL_WINDOWS

void CloseWebView();

ExampleCloseWebview

void Sample::CloseWebView()
{
    IGamebase::Get().GetWebView().CloseWebView();
}

Open External Browser

次のAPIを通して外部ブラウザーを開くことができます。パラメータに転送されるurlは有効な値である必要があります。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID

void OpenWebBrowser(const FString& url);

Example

void Sample::OpenWebBrowser(const FString& url)
{
    IGamebase::Get().GetWebView().OpenWebBrowser(url);
}

Alert

システム通知を表示できます。 システム通知にコールバックを登録することもできます。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID

void ShowAlert(const FString& title, const FString& message);
void ShowAlert(const FString& title, const FString& message, const FGamebaseAlertCloseDelegate& onCloseCallback);

Example

void Sample::ShowAlert(const FString& title, const FString& message)
{
    IGamebase::Get().GetUtil().ShowAlert(title, message);
}

void Sample::ShowAlertEvent(const FString& title, const FString& message)
{
    IGamebase::Get().GetUtil().ShowAlert(title, message, FGamebaseAlertCloseDelegate::CreateLambda([=]()
    {
            UE_LOG(GamebaseTestResults, Display, TEXT("ShowAlert ButtonClick."));
    }));
}

Toast

次のAPIを使用して、簡単にメッセージを表示できます。

API

Supported Platforms UNREAL_IOS UNREAL_ANDROID

void ShowToast(const FString& message, EGamebaseToastExposureTime exposureTimeType);

Example

void Sample::ShowToast(const FString& message, EGamebaseToastExposureTime exposureTimeType)
{
    IGamebase::Get().GetUtil().ShowToast(message, exposureTimeType);
}

Error Handling

Error Error Code Description
UI_IMAGE_NOTICE_TIMEOUT 6901 イメージ告知の表示中タイムアウトが発生しました。
UI_UNKNOWN_ERROR 6999 不明なエラーです(定義されていないエラーです)。
  • エラーコードの一覧は、次の文書を参照してください。
TOP