Game > Gamebase > Android Developer's Guide > UI

ImageNotice

You can pop up a notice to users after registering an image to the console.

ImageNotice Example

Show ImageNotices

Show the image notice on the screen.

Required parameter

  • Activity: An activity where the image notice is exposed.

Optional parameter

  • ImageNoticeConfiguration: Can change the image notice settings.
  • GamebaseCallback: Informs the user with callback when the entire image notice is terminated.
  • GamebaseDataCallback: Informs the payload which is registered in the console as callback.

API

+ (void)Gamebase.ImageNotice.showImageNotices(@NonNull Activity activity,
                                              @Nullable GamebaseCallback onCloseCallback);
+ (void)Gamebase.ImageNotice.showImageNotices(@NonNull Activity activity,
                                              @Nullable ImageNoticeConfiguration configuration,
                                              @Nullable GamebaseCallback onCloseCallback,
                                              @Nullable GamebaseDataCallback<String> onEvent);

ErrorCode

Error Error Code Description
NOT_INITIALIZED 1 Gamebase.initialize has not been called.
UI_IMAGE_NOTICE_TIMEOUT 6901 Performs a force shutdown of all popup windows because timeout has occurred while displaying the image notice popup.

Example

Gamebase.ImageNotice.showImageNotices(getActivity(), null,
    new GamebaseCallback(){
        @Override
        public void onCallback(GamebaseException exception) {
            // Called when the entire imageNotice is closed.
            ...
        }
    },
    new GamebaseDataCallback<String>() {
        @Override
        public void onCallback(String payload, GamebaseException exception) {
            // Called when custom event occurred.
            ...
        }
    });

Custom ImageNotices

Pops up a customized image notice on the screen. You can use ImageNoticeConfiguration to create a customized image notice.

Example

ImageNoticeConfiguration configuration = ImageNoticeConfiguration.newBuilder()
        .setBackgroundColor("#FFFF0000")        // Red
        .setTimeout(10000L)                     // 10000ms == 10s
        .enableAutoCloseByCustomScheme(false)
        .build();
Gamebase.ImageNotice.showImageNotices(getActivity(), configuration, null, null);

ImageNoticeConfiguration

API Mandatory(M) / Optional(O) Description
newBuilder() M ImageNoticeConfiguration.Builder object can be created using the newBuilder() function.
build() M Converts the configured Builder to a Configuration object.
setBackgroundColor(int backgroundColor)
setBackgroundColor(String backgroundColor)
O Image notice background color.
This string uses a value converted into android.graphics.Color.parseColor(String) API.
default: #80000000
setTimeout(long timeoutMs) O Max time to load an image notice (in millisec)
default: 5000L (5s)
enableAutoCloseByCustomScheme(boolean enable) O Determine whether to force shutdown the image notice when a custom scheme event occurs.
default: true

Close ImageNotices

You can call the closeImageNotices API to terminate all image notices currently being displayed.

API

+ (void)Gamebase.ImageNotice.closeImageNotices(@NonNull Activity activity);

Terms

Shows the Terms and Conditions specified in the Gamebase Console.

TermsView Example

showTermsView API displays the terms and conditions window in WebView. If you want to create your own terms and conditions window appropriate for the Game UI, call the queryTerms API to load the terms and conditions set in the Gamebase console. If users agree to the terms and conditions, please use the updateTerms API to send the user consent of each item to the Gamebase server.

showTermsView

Shows the terms and conditions window on the screen. If users agree to the terms and conditions, register the user consent data in the server. If users agree to the terms and conditions, calling the showTermsView API again will immediately return the success callback without displaying the terms and conditions window. However, if the "Agree again to Terms and Conditions" item has been switched to Required, the terms and conditions window is displayed until users agree again to the terms and conditions.

Required parameter

  • Activity: An activity that prompts the terms and conditions window.

Optional parameter

  • GamebaseTermsConfiguration: Using the GamebaseTermsConfiguration object, you can change settings such as whether to forcibly display the terms and conditions agreement window.
  • GamebaseDataCallback: The user is notified through a callback when the terms and conditions window is closed after the user agreed to the terms and conditions. You can check additional information by converting the GamebaseDataContainer object passed by the callback to a GamebaseShowTermsViewResult.

API

+ (void)Gamebase.Terms.showTermsView(@NonNull Activity activity,
                                     @Nullable GamebaseDataCallback<GamebaseDataContainer> callback);
+ (void)Gamebase.Terms.showTermsView(@NonNull Activity activity,
                                     @Nullable GamebaseTermsConfiguration configuration,
                                     @Nullable GamebaseDataCallback<GamebaseDataContainer> callback);

GamebaseTermsConfiguration

API Mandatory(M) / Optional(O) Description
newBuilder() M A GamebaseTermsConfiguration.Builder object can be created using the newBuilder() function.
build() M Converts the configured Builder to a Configuration object.
setForceShow(boolean forceShow) O If the user agreed to the terms, calling the showTermsView API again will not display the terms and conditions window, but ignore it and force the display of the terms and conditions window.
default : false
enableFixedFontSize(boolean enable) O Ignores the system font size and displays the terms and conditions in a fixed size.
default : false

GamebaseShowTermsViewResult

Field Type Nullable / NonNull Description
isTermsUIOpened boolean NonNull true: The terms and conditions window was displayed, and it was closed after the user agreed to the terms and conditions.
false: The user has already agreed to the terms and conditions, so the terms and conditions window was closed without being displayed.
pushConfiguration PushConfiguration Nullable If isTermsUIOpened is true and you have added consent to receive push notifications to the terms and conditions, then pushConfiguration will always have a valid object.
Otherwise it will be null.
When pushConfiguration is valid, the value of pushConfiguration.pushEnabled is always true.

ErrorCode

Error Error Code Description
NOT_INITIALIZED 1 Gamebase not initialized.
LAUNCHING_SERVER_ERROR 2001 This error occurs when the items downloaded from the launching server do not have any information about the terms and conditions.
This is not a usual case, and you should contact the Gamebase personnel.
UI_TERMS_ALREADY_IN_PROGRESS_ERROR 6924 The Terms API call has not been completed yet.
Please try again later.
UI_TERMS_ANDROID_DUPLICATED_VIEW 6925 Unfinished terms & conditions WebView has been called again.
WEBVIEW_TIMEOUT 7002 Timed out while displaying the terms and conditions WebView.
WEBVIEW_HTTP_ERROR 7003 An HTTP error has occurred while opening the terms and conditions WebView.

Example

static PushConfiguration savedPushConfiguration = null;
final GamebaseTermsConfiguration configuration = GamebaseTermsConfiguration.newBuilder()
        .setForceShow(true)
        .build();
Gamebase.Terms.showTermsView(activity, (container, exception) -> {
    if (Gamebase.isSuccess(exception)) {
        // Save the PushConfiguration and use it for Gamebase.Push.registerPush()
        // after Gamebase.login().
        GamebaseShowTermsViewResult termsViewResult = GamebaseShowTermsViewResult.from(container);
        if (termsViewResult != null) {
            savedPushConfiguration = termsViewResult.pushConfiguration;
        }
    } else {
        new Thread(() -> {
            // Wait for a while and try again.
            try { Thread.sleep(2000); }
            catch (Exception ignored) {}
            showTermsView(activity, callback);
        }).start();
    }
});
public void afterLogin(Activity activity) {
    // Call registerPush with saved PushConfiguration.
    if (savedPushConfiguration != null) {
        Gamebase.Push.registerPush(activity, savedPushConfiguration, exception -> {...});
    }
}

queryTerms

Gamebase displays the terms and conditions with a simple WebView. If you want to create the terms and conditions appropriate for the game UI, call the queryTerms API to download the terms and conditions information set in the Gamebase Console for later use.

Calling it after login also lets you see if the game user has agreed to the terms and conditions.

[Caution]

  • The required items with GamebaseTermsContentDetail.getRequired() set to true are not stored in the Gamebase server; therefore, false is always returned for the agreed value.
    • It is because there is no point in storing the required items since they are always stored as true.
  • The user consent for receiving the push notification is not stored in the Gamebase server either; therefore, the agreed value is always returned as false.
    • To see if the user has agreed to receive push, please use the Gamebase.Push.queryTokenInfo API.
  • If you do not touch the 'Terms and Conditions settings' in the console, UI_TERMS_NOT_EXIST_FOR_DEVICE_COUNTRY(6922) error occurs when you call the queryTerms API from the device with the country code different from the terms and conditions language.
    • If you complete the 'Terms and Conditions settings' in the console or if UI_TERMS_NOT_EXIST_FOR_DEVICE_COUNTRY(6922) error occurs, please make sure the terms and conditions are not displayed.

Required parameter

  • Activity: A top level activity at the time of API call.
  • GamebaseDataCallback: Uses a callback to inform users about the API call result. With the GamebaseQueryTermsResult that comes as callback, you can acquire the terms and conditions information set in the console.

API

+ (void)Gamebase.Terms.queryTerms(@NonNull Activity activity,
                                  @NonNull GamebaseDataCallback<GamebaseQueryTermsResult> callback);

ErrorCode

Error Error Code Description
NOT_INITIALIZED 1 Gamebase not initialized.
UI_TERMS_NOT_EXIST_IN_CONSOLE 6921 Terms & conditions information is not registered with the console.
UI_TERMS_NOT_EXIST_FOR_DEVICE_COUNTRY 6922 Terms & conditions information appropriate for the device's country code is not registered with the console.

Example

Gamebase.Terms.queryTerms(activity, new GamebaseDataCallback<GamebaseQueryTermsResult>() {
    @Override
    public void onCallback(GamebaseQueryTermsResult result, GamebaseException exception) {
        if (Gamebase.isSuccess(exception)) {
            // Succeeded.
            final int termsSeq = result.getTermsSeq();
            final String termsVersion = result.getTermsVersion();
            final String termsCountryType = result.getTermsCountryType();
            final List<GamebaseTermsContentDetail> contents = result.getContents();
        } else if (exception.getCode() == GamebaseError.UI_TERMS_NOT_EXIST_FOR_DEVICE_COUNTRY) {
            // Another country device.
            // Pass the 'terms and conditions' step.
        } else {
            // Failed.
        }
    }
});

GamebaseQueryTermsResult

API Values Description
getTermsSeq int KEY for the entire terms and conditions.
This value is required when calling updateTerms API.
getTermsVersion String T&C version.
This value is required when calling updateTerms API.
getTermsCountryType String Terms and conditions type.
- KOREAN: Korean T&C
- GDPR: European T&C
- ETC: Other countries
getContents List Details of each T&C

GamebaseTermsContentDetail

API Values Description
getTermsContentSeq int T&C KEY
getName String T&C Name
getRequired boolean Whether agreement is required
getAgreePush String Whether to accept advertisement push.
- NONE: Do not accept
- ALL: Accept all
- DAY: Accept push notification during daytime
- NIGHT: Accept push notification during night time
getAgreed boolean Whether users agree to the T&C.
- Always false before login.
- Always false for push items.
getNode1DepthPosition int Primary item exposure sequence.
getNode2DepthPosition int Secondary item exposure sequence.
If none, -1
getDetailPageUrl String URL for the full terms and conditions.
If none, null.

updateTerms

If the UI has been created manually with the terms and conditions info downloaded from the queryTerms API, please use the updateTerms API to send the game user's agreement history to the Gamebase server.

It can be used to terminate the agreement to optional terms and conditions as well as to revise the agreed T&C clauses.

[Caution]

Push accept status is not stored in the Gamebase server. Push accept status should be stored by calling the Gamebase.Push.registerPush API after login.

Required parameter

  • Activity: A top level activity at the time of API call.
  • GamebaseUpdateTermsConfiguration: Information of optional T&C of users who will be registered on the server.

Optional parameter

  • GamebaseCallback: Registers the information of optional terms and conditions on the server, and notifies user with a callback.

API

+ (void)Gamebase.Terms.updateTerms(@NonNull Activity activity,
                                   @NonNull GamebaseUpdateTermsConfiguration configuration,
                                   @Nullable GamebaseCallback callback);

ErrorCode

Error Error Code Description
NOT_INITIALIZED 1 Gamebase not initialized.
UI_TERMS_UNREGISTERED_SEQ 6923 Unregistered terms and conditions Seq value has been set.
UI_TERMS_ALREADY_IN_PROGRESS_ERROR 6924 The Terms API call has not been completed yet.
Please try again later.

Example

Gamebase.Terms.queryTerms(activity, new GamebaseDataCallback<GamebaseQueryTermsResult>() {
    @Override
    public void onCallback(GamebaseQueryTermsResult result, GamebaseException queryTermsException) {
        if (Gamebase.isSuccess(queryTermsException)) {
            // Succeeded to query terms.
            final int termsSeq = result.getTermsSeq();
            final String termsVersion = result.getTermsVersion();
            final List<GamebaseTermsContent> contents = new ArrayList<>();
            for (GamebaseTermsContentDetail detail : result.getContents()) {
                GamebaseTermsContent content = GamebaseTermsContent.from(detail);
                // TODO: Change agree value what you want.
                content.setAgreed(agreeOrNot);
                contents.add(content);
            }

            final GamebaseUpdateTermsConfiguration configuration =
                    GamebaseUpdateTermsConfiguration.newBuilder(termsSeq, termsVersion, contents)
                            .build();
            Gamebase.Terms.updateTerms(activity, configuration, new GamebaseCallback() {
                @Override
                public void onCallback(GamebaseException updateTermsException) {
                    if (Gamebase.isSuccess(updateTermsException)) {
                        // Succeeded to update terms.
                    } else {
                        // Failed to update terms.
                    }
                }
            });
        } else {
            // Failed to query terms.
        }
    }
});

GamebaseUpdateTermsConfiguration

Builder

API Description
newBuilder(String termsVersion, int termsSeq, List contents) Creates a Builder to create Configuration objects.
build() Converts the configured Builder to a Configuration object.
Parameter Mandatory(M) / Optional(O) Type Description
termsSeq M int KEY for the entire terms and conditions.
The queryTerms API must be called to pass the downloaded value.
termsVersion M String T&C version.
The queryTerms API must be called to pass the downloaded value.
contents M List Info on whether user agrees to the optional terms and conditions

GamebaseTermsContent

Constructor

API Description
GamebaseTermsContent(int termsContentSeq, boolean agreed) GamebaseTermsContent creator.
from(GamebaseTermsContentDetail) Factory method which creates the GamebaseTermsContent object from the GamebaseTermsContentDetail object.
setAgreed(boolean) Changes the agreed value of the object.
Parameter Mandatory(M) / Optional(O) Values Description
termsContentSeq M int KEY for optional terms and conditions
agreed M boolean Info on whether user agrees to optional terms and conditions

isShowingTermsView

Determines whether the terms and conditions window is currently displayed or not.

API

+ (boolean)Gamebase.Terms.isShowingTermsView();

WebView

Gamebase supports a default WebView.

Show WebView

Shows a WebView.

Required Parameters
  • activity: Shows WebView.
  • url: The url delivered as a parameter should be valid.
Optional Parameters
  • configuration: Changes WebView layout by using GamebaseWebViewConfiguration.
  • GamebaseCallback: Notifies users when a WebView is closed.
  • schemeList: Specifies the list of customized schemes a user wants.
  • gamebaseDataCallback: Notifies url including customized scheme specified by the schemeList with a callback.

API

+ (void)Gamebase.WebView.showWebView(Activity activity,
                String urlString,
                GamebaseWebViewConfiguration configuration,
                GamebaseCallback onCloseCallback,
                List<String> schemeList,
                GamebaseDataCallback<String> onEvent);

Example

Gamebase.WebView.showWebView(activity, "https://www.toast.com");

Webview Example

Custom WebView

Shows a customized WebView.
Can configure a customzed WebView by using GamebaseWebViewConfiguration.

GamebaseWebViewConfiguration configuration
        = new GamebaseWebViewConfiguration.Builder()
            .setTitleText("title")                              // Set Title
            .setScreenOrientation(ScreenOrientation.PORTRAIT)   // Set Screen Orientation
            .setNavigationBarColor(Color.RED)                   // Set Navigation Bar Color
            .setNavigationBarHeight(40)                         // Set Navigation Bar Height
            .setBackButtonVisible(true)                         // Set Go Back Button Visibility
            .setBackButtonImageResource(R.id.back_button)       // Set Go Back Button Image
            .setCloseButtonImageResource(R.id.close_button)     // Set Close Button Image
            .build();
GamebaseWebView.showWebView(activity, "https://www.toast.com", configuration);

Custom Schema

With schema on the webpage loaded by Gamebase WebView, specific features become available or webpage can be changed.

Predefined Custom Schema

Gamebase has the following schemas

Schema Usage
gamebase://dismiss Close WebView
gamebase://goBack Go back to previous page on WebView
gamebase://getUserId Show ID of current logged-in user
gamebase://showwebview?link={URLEncodedURL} Open the URL of the link parameter with the WebView.
URLEncodedURL: Column URL with the WebView.
Requires URL decoding.
gamebase://openbrowser?link={URLEncodedURL} Open the URL of the link parameter with an external browser.
URLEncodedURL: Column URL with the WebView.
Requires URL decoding.

User Custom Schema

By specifying the name and block of a schema for Gamebase, features may be added in need.

GamebaseWebViewConfiguration configuration = new GamebaseWebViewConfiguration.Builder()
        .setTitleText(title)
        .build();
List<String> schemeList = new ArrayList<>();
schemeList.add("mygame://test");
schemeList.add("mygame://opensomebrowser");
schemeList.add("closemywebview://");
showWebView(activity, urlString, configuration,
        new GamebaseCallback() {
            @Override
            public void onCallback(GamebaseException exception) {
                // When closed WebView, this callback will be called.
            }
        },
        schemeList,
        new GamebaseDataCallback<String>() {
            @Override
            public void onCallback(String fullUrl, GamebaseException exception) {
                if (Gamebase.isSuccess(exception)) {
                    if (fullUrl.contains("mygame://test")) {
                        // Do something.
                    } else if (fullUrl.contains("mygame://opensomebrowser")) {
                        Gamebase.WebView.openWebBrowser(someUrl);
                    } else if (fullUrl.contains("closemywebview://")) {
                        // We will close webview.
                        Gamebase.WebView.closeWebView(activity);
                    }
                } else {
                    // Something went wrong.
                }
            }
        });

GamebaseWebViewConfiguration

Method Values Description
setTitleText(String title) title Title of WebView
setScreenOrientation(int orientation) ScreenOrientation.PORTRAIT Portrait mode
ScreenOrientation.LANDSCAPE Landscape mode
ScreenOrientation.LANDSCAPE_REVERSE Reverse landscape
setNavigationBarVisible(boolean enable) true or false Activate or deactivate Navigation Bar.
default: true
setNavigationBarColor(int color) Color.argb(a, r, b, b) Color of Navigation Bar
setNavigationBarHeight(int height) height Height of Navigation Bar
setBackButtonVisible(boolean visible) true or false Activate or deactivate Go Back Button.
default: true
setBackButtonImageResource(int resourceId) ID of resource Image of Go Back Button
setCloseButtonImageResource(int resourceId) ID of resource Image of Close Button
enableAutoCloseByCustomScheme(boolean enable) true or false WebView is automatically closed when the custom scheme works.
default: true
enableFixedFontSize(boolean enable) true or false Display a webview at a fixed size, ignoring system font size.
default: false
setRenderOutsideSafeArea(boolean render) true or false Ignore safe area and render cutout area.
default: false

Close WebView

Close currently displayed WebView by using the following API.

API

+ (void)Gamebase.WebView.closeWebView(Activity activity);

Open External Browser

Open an external browser by using the following API. The URL delivered as a parameter should be valid.

API

+ (void)Gamebase.WebView.openWebBrowser(Activity activity, String urlString);

Alert

Displays a system alert API.

Simple Alert Dialog

Shows a simple alert dialogue by entering title and message only.

API

+ (void)Gamebase.Util.showAlertDialog(Activity activity, String title, String message);

Alert Dialog Example

Alert Dialog with Listener

Use the following API to receive callbacks on processing results after an alert dialog is displayed.

API

+ (void)Gamebase.Util.showAlertDialog(Activity activity,
                            String title,                                   // Title text.
                            String messsage,                                // Message text.
                            String okButtonText,                            // Positive button text.
                            DialogInterface.OnClickListener clickListener); // Listener called when pressing a positive button.

Toast

Displays Android Toast messages, by using the following API.
The type of time parameter to display message is provided in int format and will be displayed during time as below, as the Android SDK NotificationManagerService class is defined.

Type of Time (int) Display Time
Toast.LENGTH_SHORT 2 seconds
Toast.LENGTH_LONG 3.5 seconds
0 Toast.LENGTH_SHORT => 2 seconds
1 Toast.LENGTH_LONG => 3.5 seconds
All the rest values Toast.LENGTH_SHORT => 2 seconds

API

+ (void)Gamebase.Util.showToast(Activity activity,
                        String message,     // Message text to display
                        int duration);      // Type of time to display message (Toast.LENGTH_SHORT or Toast.LENGTH_LONG)

Custom Maintenance Page

Click 'Detail' in maintenance status to change maintenance page.

  • Register a customized web page as a maintenance page
    • Set meta-data with "com.gamebase.maintenance.detail.url" as key value to AndroidManifest.xml.
    • Enter .html file or URL with android:value.
<meta-data
    android:name="com.gamebase.maintenance.detail.url"
    android:value="file:///android_asset/html/gamebase-maintenance.html"/>

Error Handling

Error Error Code Description
UI_UNKNOWN_ERROR 6999 Unknown error (Undefined error).
TOP