Gamebase SDK for Android  2.21.1
Toast 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 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...
 

Detailed Description

This class provides functionality related to terms of use view.

Member Function Documentation

◆ 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()

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:

public void showTermsView(final Activity activity,
final GamebaseDataCallback<GamebaseDataContainer> callback) {
Gamebase.Terms.showTermsView(activity, new GamebaseDataCallback<GamebaseDataContainer>() {
@Override
public void onCallback(GamebaseDataContainer container, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
// Save the PushConfiguration and use it for Gamebase.Push.registerPush()
// after Gamebase.login().
PushConfiguration savedPushConfiguration = PushConfiguration.from(container);
} else {
new Thread(new Runnable() {
@Override
public void run() {
// 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.
Gamebase.Push.registerPush(activity, savedPushConfiguration, new GamebaseCallback() {...});
}
See also
com.toast.android.gamebase.GamebaseDataCallback.
com.toast.android.gamebase.base.data.GamebaseDataContainer
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:2763