Gamebase SDK for Android  2.39.0
NHN Cloud Gamebase Platform
Gamebase.Terms Class Reference

This class provides functionality related to terms of use view. More...

Collaboration diagram for Gamebase.Terms:
Collaboration graph

Static Public Member Functions

static void showTermsView (@NonNull Activity activity, @Nullable GamebaseDataCallback< GamebaseDataContainer > callback)
 Show terms and conditions web view. More...
 
static void showTermsView (@NonNull Activity activity, @Nullable GamebaseTermsConfiguration configuration, @Nullable GamebaseDataCallback< GamebaseDataContainer > callback)
 Show terms and conditions web view. More...
 
static void queryTerms (@NonNull Activity activity, @NonNull GamebaseDataCallback< GamebaseQueryTermsResult > callback)
 Request terms and conditions items list from Gamebase console. More...
 
static void updateTerms (@NonNull Activity activity, @NonNull GamebaseUpdateTermsConfiguration configuration, @Nullable GamebaseCallback callback)
 Send the agreement to the terms and conditions to the Gamebase server. More...
 
static boolean isShowingTermsView ()
 This is the method to check if terms view is being shown. More...
 

Detailed Description

This class provides functionality related to terms of use view.

Member Function Documentation

◆ isShowingTermsView()

static boolean isShowingTermsView ( )
static

This is the method to check if terms view is being shown.

Since
Added 2.35.0

◆ queryTerms()

static void queryTerms ( @NonNull Activity  activity,
@NonNull GamebaseDataCallback< GamebaseQueryTermsResult >  callback 
)
static

Request terms and conditions items list from Gamebase console.

This API can be used when you create custom terms and conditions agreement UI. If you call after logging in, you can also check whether the user agrees to the terms and conditions, except whether to receive notification.

Since
Added 2.20.0
Parameters
activityCurrent activity.
callbackInformation on terms and conditions registered in the console. After logging in, whether you agree to the terms and conditions is returned, except whether to receive notification.

Example Usage:

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.
}
}
});
See also
com.toast.android.gamebase.GamebaseDataCallback.
com.toast.android.gamebase.terms.data.GamebaseQueryTermsResult
com.toast.android.gamebase.terms.data.GamebaseTermsContentDetail

◆ showTermsView() [1/2]

static void showTermsView ( @NonNull Activity  activity,
@Nullable GamebaseDataCallback< GamebaseDataContainer >  callback 
)
static

Show terms and conditions web view.

Since
Added 2.20.0
Parameters
activityCurrent activity.
callbackcalled when the browser closed.

Example Usage:

static PushConfiguration savedPushConfiguration = null;
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 -> {...});
}
}
See also
com.toast.android.gamebase.GamebaseDataCallback.
com.toast.android.gamebase.base.data.GamebaseDataContainer
com.toast.android.gamebase.terms.data.GamebaseShowTermsViewResult.
com.toast.android.gamebase.base.push.PushConfiguration
com.toast.android.gamebase.Gamebase.Push#registerPush(Activity, PushConfiguration, GamebaseCallback)

◆ showTermsView() [2/2]

static void showTermsView ( @NonNull Activity  activity,
@Nullable GamebaseTermsConfiguration  configuration,
@Nullable GamebaseDataCallback< GamebaseDataContainer >  callback 
)
static

Show terms and conditions web view.

Since
Added 2.33.0
Parameters
activityCurrent activity.
configurationThe initial settings of terms view.
callbackcalled when the browser closed.

Example Usage:

static PushConfiguration savedPushConfiguration = null;
final GamebaseTermsConfiguration configuration = GamebaseTermsConfiguration.newBuilder()
.setForceShow(true)
.build();
Gamebase.Terms.showTermsView(activity, configuration, (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 -> {...});
}
}
See also
com.toast.android.gamebase.terms.GamebaseTermsConfiguration.
com.toast.android.gamebase.GamebaseDataCallback.
com.toast.android.gamebase.base.data.GamebaseDataContainer
com.toast.android.gamebase.terms.data.GamebaseShowTermsViewResult.
com.toast.android.gamebase.base.push.PushConfiguration
com.toast.android.gamebase.Gamebase.Push#registerPush(Activity, PushConfiguration, GamebaseCallback)

◆ updateTerms()

static void updateTerms ( @NonNull Activity  activity,
@NonNull GamebaseUpdateTermsConfiguration  configuration,
@Nullable GamebaseCallback  callback 
)
static

Send the agreement to the terms and conditions to the Gamebase server.

This can also be used to change the content of the optional terms and conditions.

Since
Added 2.20.0
Parameters
activityCurrent activity.
configuration
callbackExample Usage:
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);
// 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.
}
}
});
See also
com.toast.android.gamebase.terms.data.GamebaseUpdateTermsConfiguration
com.toast.android.gamebase.terms.data.GamebaseTermsContent
com.toast.android.gamebase.GamebaseCallback.
com.toast.android.gamebase.Gamebase.Terms.showTermsView
static void showTermsView(@NonNull Activity activity, @Nullable GamebaseDataCallback< GamebaseDataContainer > callback)
Show terms and conditions web view.
Definition: Gamebase.java:2918