Gamebase SDK for Android  1.7.0
Toast Gamebase Platform
Gamebase Class Reference

This class is a wrapper class that is provided to use various features of Gamebase platform. More...

Collaboration diagram for Gamebase:
Collaboration graph

Classes

class  Launching
 This class is provided to check information such as launch information, status, and so on. More...
 
class  Network
 This class provides network status information. More...
 
class  Purchase
 This class provides wrapping of function execution related to payment. More...
 
class  Push
 This class provides wrapping of function execution related to push notification. More...
 
class  Util
 This class provides Android utility functions. More...
 
class  WebView
 This class implements the Webview call function. More...
 

Static Public Member Functions

static void activeApp (final Context applicationContext)
 Notifies the Gamebase SDK that the app has launched. More...
 
static void initialize (final Activity activity, final GamebaseConfiguration configuration, @Nullable final GamebaseDataCallback< LaunchingInfo > callback)
 This function initializes the Gamebase SDK. More...
 
static boolean isInitialized ()
 Check whether the Gamebase is initialized. More...
 
static boolean isSuccess (GamebaseException exception)
 Returns true if the GamebaseException object is null or the error code is zero. More...
 
static boolean isDebugMode ()
 Indicates if we are in debug mode. More...
 
static void setDebugMode (boolean enableDebug)
 Used to enable or disable logging, and other debug features. More...
 
static String getSDKVersion ()
 Returns the current version of the Gamebase SDK for Android as a string. More...
 
static boolean isSandbox ()
 Returns whether this project is sandbox mode or not. More...
 
static void login (@NonNull final Activity activity, final String providerName, @Nullable final GamebaseDataCallback< AuthToken > callback)
 Logs the user in with the external authentication provider. More...
 
static void login (@NonNull final Activity activity, final String providerName, @Nullable Map< String, Object > additionalInfo, @Nullable final GamebaseDataCallback< AuthToken > callback)
 Logs the user in with the external authentication provider. More...
 
static void login (@NonNull final Activity activity, @NonNull final Map< String, Object > credentialInfo, @Nullable final GamebaseDataCallback< AuthToken > callback)
 Logs the user in with the credential of external authentication provider. More...
 
static void loginForLastLoggedInProvider (@NonNull final Activity activity, @Nullable final GamebaseDataCallback< AuthToken > callback)
 Logs the user in with last logged in authentication provider. More...
 
static void addMapping (@NonNull final Activity activity, final String providerName, @Nullable final GamebaseDataCallback< AuthToken > callback)
 Mapping the currently authenticated user identifier of Gamebase with another external authentication. More...
 
static void addMapping (@NonNull final Activity activity, @NonNull final Map< String, Object > credentialInfo, @Nullable final GamebaseDataCallback< AuthToken > callback)
 Mapping the currently authenticated user identifier of Gamebase with the credential of external authentication provider. More...
 
static void addMapping (@NonNull final Activity activity, final String providerName, @Nullable final Map< String, Object > additionalInfo, @Nullable final GamebaseDataCallback< AuthToken > callback)
 Mapping the currently authenticated user identifier of Gamebase with another external authentication. More...
 
static void removeMapping (@NonNull final Activity activity, final String providerName, @Nullable final GamebaseCallback callback)
 Removes external authentication that is mapped to the current user identifier. More...
 
static void logout (@NonNull final Activity activity, @Nullable final GamebaseCallback callback)
 Logs out the user. More...
 
static void withdraw (@NonNull final Activity activity, @Nullable final GamebaseCallback callback)
 Withdraws the user. More...
 
static String getUserID ()
 Gets the user ID that is currently logged in. More...
 
static String getAccessToken ()
 Gets the access token for the current user. More...
 
static String getLastLoggedInProvider ()
 Gets the name of the last logged-in authentication provider. More...
 
static List< String > getAuthMappingList ()
 Gets the list of external authentication providers mapped to the current user identifier. More...
 
static String getAuthProviderUserID (@NonNull String providerName)
 Gets the user ID from the authentication provider. More...
 
static String getAuthProviderAccessToken (@NonNull String providerName)
 Gets the access token from the authentication provider. More...
 
static AuthProviderProfile getAuthProviderProfile (@NonNull String providerName)
 Gets the profile from the authentication provider. More...
 
static AuthBanInfo getAuthBanInfo ()
 Gets the ban information of the suspended user. More...
 
static String getLanguageCode ()
 Gets the language code set for the current device. More...
 
static String getDeviceLanguageCode ()
 Gets the language code set for the current device. More...
 
static String getDisplayLanguageCode ()
 Gets the display language code set for the current device. More...
 
static void setDisplayLanguageCode (String languageCode)
 
static String getCarrierCode ()
 Gets the carrier code set for the current device. More...
 
static String getCarrierName ()
 Gets the carrier name set for the current device. More...
 
static String getCountryCode ()
 Gets the country code. More...
 
static String getCountryCodeOfUSIM ()
 Gets the country code set in USIM. More...
 
static String getCountryCodeOfDevice ()
 Gets the country code currently set on the device. More...
 
static void onActivityResult (int requestCode, int resultCode, Intent data)
 The method that should be called from the Activity's or Fragment's onActivityResult method. More...
 

Detailed Description

This class is a wrapper class that is provided to use various features of Gamebase platform.

Provides functions such as authentication, launching, pushing, and billing.

Member Function Documentation

◆ activeApp()

static void activeApp ( final Context  applicationContext)
static

Notifies the Gamebase SDK that the app has launched.

It should be called as early as possible.

Since
Added 1.4.0.
Parameters
applicationContextThe application context

Example Usage:

public class GamebaseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Gamebase.activeApp(getApplicationContext());
}
}

◆ addMapping() [1/3]

static void addMapping ( @NonNull final Activity  activity,
final String  providerName,
@Nullable final GamebaseDataCallback< AuthToken callback 
)
static

Mapping the currently authenticated user identifier of Gamebase with another external authentication.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the mapping process.
providerNameThe providerName which is authentication provider.
callbackMapping result callback,
returns the authentication token as a result of mapping.

Example Usage:

Gamebase.addMapping(activity, AuthProvider.GOOGLE, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Add mapping successful");
...
} else {
Log.e(TAG, "Add mapping failed");
...
}
}
});
See also
com.toast.android.gamebase.base.auth.AuthProvider
com.toast.android.gamebase.GamebaseDataCallback

◆ addMapping() [2/3]

static void addMapping ( @NonNull final Activity  activity,
@NonNull final Map< String, Object >  credentialInfo,
@Nullable final GamebaseDataCallback< AuthToken callback 
)
static

Mapping the currently authenticated user identifier of Gamebase with the credential of external authentication provider.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the login process.
credentialInfoThe credentialInfo which is credential of authentication provider.
callbackMapping result callback,
returns the authentication token as a result of mapping.

Example Usage:

Map<String, Object> credential = new HashMap<>();
credential.put(AuthProviderCredentialConstants.PROVIDER_NAME, providerName);
credential.put(AuthProviderCredentialConstants.ACCESS_TOKEN, accessToken);
credential.put(AuthProviderCredentialConstants.ACCESS_TOKEN_SECRET, accessTokenSecret);
Gamebase.addMapping(activity, credential, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Add mapping successful");
...
} else {
Log.e(TAG, "Add mapping failed");
...
}
}
});

◆ addMapping() [3/3]

static void addMapping ( @NonNull final Activity  activity,
final String  providerName,
@Nullable final Map< String, Object >  additionalInfo,
@Nullable final GamebaseDataCallback< AuthToken callback 
)
static

Mapping the currently authenticated user identifier of Gamebase with another external authentication.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the mapping process.
providerNameThe providerName which is authentication provider.
additionalInfoThe additionalInfo which is additional information using for mapping.
callbackCallbacks the results of mappings,
returns the authentication token as a result of mappings.

Example Usage:

Gamebase.addMapping(activity, AuthProvider.GOOGLE, null, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Add mapping successful");
...
} else {
Log.e(TAG, "Add mapping failed");
...
}
}
});
See also
com.toast.android.gamebase.base.auth.AuthProvider
com.toast.android.gamebase.GamebaseDataCallback

◆ getAccessToken()

static String getAccessToken ( )
static

Gets the access token for the current user.

Since
Added 1.4.0.
Returns
The access token for Gamebase platform.

◆ getAuthBanInfo()

static AuthBanInfo getAuthBanInfo ( )
static

Gets the ban information of the suspended user.

Since
Added 1.4.0.
Returns
The ban information of the suspended user.

◆ getAuthMappingList()

static List<String> getAuthMappingList ( )
static

Gets the list of external authentication providers mapped to the current user identifier.

Since
Added 1.4.0.
Returns
The list of external authentication providers mapped to the current user identifier.
See also
com.toast.android.gamebase.base.auth.AuthProvider

◆ getAuthProviderAccessToken()

static String getAuthProviderAccessToken ( @NonNull String  providerName)
static

Gets the access token from the authentication provider.

Since
Added 1.4.0.
Parameters
providerNameThe providerName which is authentication provider.
Returns
The access token from the authentication provider.

◆ getAuthProviderProfile()

static AuthProviderProfile getAuthProviderProfile ( @NonNull String  providerName)
static

Gets the profile from the authentication provider.

Since
Added 1.4.0.
Parameters
providerNameThe providerName which is authentication provider.
Returns
The profile from the authentication provider.

◆ getAuthProviderUserID()

static String getAuthProviderUserID ( @NonNull String  providerName)
static

Gets the user ID from the authentication provider.

Since
Added 1.4.0.
Parameters
providerNameThe providerName which is authentication provider.
Returns
The user ID from the authentication provider.

◆ getCarrierCode()

static String getCarrierCode ( )
static

Gets the carrier code set for the current device.

Since
Added 1.4.0.
Returns
The carrier code set for the current device.

◆ getCarrierName()

static String getCarrierName ( )
static

Gets the carrier name set for the current device.

Since
Added 1.4.0.
Returns
The carrier name set for the current device.

◆ getCountryCode()

static String getCountryCode ( )
static

Gets the country code.

First, get the country code set in USIM,
and if there is no USIM, get the country code set in the device.

Since
Added 1.4.0.
Returns
The country code.

◆ getCountryCodeOfDevice()

static String getCountryCodeOfDevice ( )
static

Gets the country code currently set on the device.

Since
Added 1.4.0.
Returns
The country code currently set on the device.

◆ getCountryCodeOfUSIM()

static String getCountryCodeOfUSIM ( )
static

Gets the country code set in USIM.

Since
Added 1.4.0.
Returns
The country code that is set in USIM.

◆ getDeviceLanguageCode()

static String getDeviceLanguageCode ( )
static

Gets the language code set for the current device.

Since
Added 1.5.1.
Returns
The device language code that is currently set.

◆ getDisplayLanguageCode()

static String getDisplayLanguageCode ( )
static

Gets the display language code set for the current device.

Since
Added 1.5.1.
Returns
The display language code that is currently set.

◆ getLanguageCode()

static String getLanguageCode ( )
static

Gets the language code set for the current device.

Since
Added 1.4.0.
Deprecated:
As of release 1.5.1, use Gamebase#getDeviceLanguageCode() method instead.
Returns
The language code that is currently set.

◆ getLastLoggedInProvider()

static String getLastLoggedInProvider ( )
static

Gets the name of the last logged-in authentication provider.

Since
Added 1.4.0.
Returns
The name that is last logged-in authentication provider.
See also
com.toast.android.gamebase.base.auth.AuthProvider

◆ getSDKVersion()

static String getSDKVersion ( )
static

Returns the current version of the Gamebase SDK for Android as a string.

Since
Added 1.4.0.
Returns
The current version of the Gamebase SDK

◆ getUserID()

static String getUserID ( )
static

Gets the user ID that is currently logged in.

Since
Added 1.4.0.
Returns
The user id that is currently logged in.

◆ initialize()

static void initialize ( final Activity  activity,
final GamebaseConfiguration  configuration,
@Nullable final GamebaseDataCallback< LaunchingInfo callback 
)
static

This function initializes the Gamebase SDK.

If this function is not called, the Gamebase SDK function will not work.

Since
Added 1.4.0.
Parameters
activityThe activity which is initializing modules
configurationThe configurations required to run the Gamebase SDK
callbackInitialization result callback,
returns the launching information as a result of initialization

Example Usage:

public class SampleActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
Gamebase.setDebugMode(true);
GamebaseConfiguration configuration = new GamebaseConfiguration.Builder()
.setAppId("diIofWef")
.setAppVersion("1.0.0")
.setZoneType(ZoneType.REAL)
.build();
Gamebase.initialize(activity, configuration, new GamebaseDataCallback<LaunchingInfo>() {
@Override
public void onCallback(LaunchingInfo data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
// Success
...
} else {
// Failed
...
}
}
});
}
...
}
See also
com.toast.android.gamebase.GamebaseConfiguration
com.toast.android.gamebase.launching.data.LaunchingInfo
com.toast.android.gamebase.GamebaseDataCallback

◆ isDebugMode()

static boolean isDebugMode ( )
static

Indicates if we are in debug mode.

Since
Added 1.4.0.
Returns
True if enabled debug, false if not.

◆ isInitialized()

static boolean isInitialized ( )
static

Check whether the Gamebase is initialized.

Since
Added 1.4.0.
Returns
True if initialized, false otherwise.

◆ isSandbox()

static boolean isSandbox ( )
static

Returns whether this project is sandbox mode or not.

Since
Added 1.4.0.
Returns
Boolean value whether this project is sandbox mode.

◆ isSuccess()

static boolean isSuccess ( GamebaseException  exception)
static

Returns true if the GamebaseException object is null or the error code is zero.

Since
Added 1.4.0.
Parameters
exceptionThe exception that occurred
Returns
True if success, false if not
Here is the call graph for this function:

◆ login() [1/3]

static void login ( @NonNull final Activity  activity,
final String  providerName,
@Nullable final GamebaseDataCallback< AuthToken callback 
)
static

Logs the user in with the external authentication provider.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the login process.
providerNameThe provider name witch is authentication provider.
callbackLogin result callback,
returns the authentication token as a result of login.

Example Usage:

Gamebase.login(activity, AuthProvider.GOOGLE, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Login successful");
...
} else {
Log.e(TAG, "Login failed");
...
}
}
});
See also
com.toast.android.gamebase.base.auth.AuthProvider
com.toast.android.gamebase.auth.data.AuthToken
com.toast.android.gamebase.GamebaseDataCallback

◆ login() [2/3]

static void login ( @NonNull final Activity  activity,
final String  providerName,
@Nullable Map< String, Object >  additionalInfo,
@Nullable final GamebaseDataCallback< AuthToken callback 
)
static

Logs the user in with the external authentication provider.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the login process.
providerNameThe providerName which is authentication provider.
additionalInfoThe additionalInfo which is additional information using for login.
callbackLogin result callback,
returns the authentication token as a result of login.

Example Usage:

Gamebase.login(activity, AuthProvider.GOOGLE, additionalInfo, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Login successful");
...
} else {
Log.e(TAG, "Login failed");
...
}
}
});
See also
com.toast.android.gamebase.base.auth.AuthProvider
com.toast.android.gamebase.auth.data.AuthToken
com.toast.android.gamebase.GamebaseDataCallback

◆ login() [3/3]

static void login ( @NonNull final Activity  activity,
@NonNull final Map< String, Object >  credentialInfo,
@Nullable final GamebaseDataCallback< AuthToken callback 
)
static

Logs the user in with the credential of external authentication provider.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the login process.
credentialInfoThe credentialInfo which is credential of authentication provider.
callbackLogin result callback,
returns the authentication token as a result of login.

Example Usage:

Map<String, Object> credential = new HashMap<>();
credential.put(AuthProviderCredentialConstants.PROVIDER_NAME, providerName);
credential.put(AuthProviderCredentialConstants.ACCESS_TOKEN, accessToken);
credential.put(AuthProviderCredentialConstants.ACCESS_TOKEN_SECRET, accessTokenSecret);
Gamebase.login(activity, credential, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Login successful");
...
} else {
Log.e(TAG, "Login failed");
...
}
}
});

◆ loginForLastLoggedInProvider()

static void loginForLastLoggedInProvider ( @NonNull final Activity  activity,
@Nullable final GamebaseDataCallback< AuthToken callback 
)
static

Logs the user in with last logged in authentication provider.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the mapping process.
callbackLogin result callback,
returns the authentication token as a result of login.

Example Usage:

Gamebase.loginForLastLoggedInProvider(new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Login successful");
...
} else {
Log.e(TAG, "Login failed");
...
}
}
});
See also
com.toast.android.gamebase.auth.data.AuthToken
com.toast.android.gamebase.GamebaseDataCallback

◆ logout()

static void logout ( @NonNull final Activity  activity,
@Nullable final GamebaseCallback  callback 
)
static

Logs out the user.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the mapping process.
callbackCallbacks the result of logout.
See also
com.toast.android.gamebase.GamebaseCallback

◆ onActivityResult()

static void onActivityResult ( int  requestCode,
int  resultCode,
Intent  data 
)
static

The method that should be called from the Activity's or Fragment's onActivityResult method.

Since
Added 1.4.0.
Parameters
requestCodeThe request code that's received by the Activity or Fragment.
resultCodeThe result code that's received by the Activity or Fragment.
dataThe result data that's received by the Activity or Fragment.

Example Usage:

public class MainActivity extends AppCompatActivity {
...
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Gamebase.onActivityResult(requestCode, resultCode, data);
}
...
}

◆ removeMapping()

static void removeMapping ( @NonNull final Activity  activity,
final String  providerName,
@Nullable final GamebaseCallback  callback 
)
static

Removes external authentication that is mapped to the current user identifier.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the mapping process.
providerNameThe providerName which is authentication provider.
callbackCallbacks the result of removing the mapping.

Example Usage:

Gamebase.removeMapping(AuthProvider.GOOGLE, new GamebaseCallback() {
@Override
public void onCallback(GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
Log.d(TAG, "Remove mapping successful");
} else {
Log.d(TAG, "Remove mapping failed");
}
}
});
See also
com.toast.android.gamebase.base.auth.AuthProvider
com.toast.android.gamebase.GamebaseCallback

◆ setDebugMode()

static void setDebugMode ( boolean  enableDebug)
static

Used to enable or disable logging, and other debug features.

If true, Outputs a log when the log priority is VERBOSE or higher.
If false, Outputs a log when the log priority is WARN or higher.

Since
Added 1.4.0.
Parameters
enableDebugDebug features (like logging) are enabled if true, disabled if false.

◆ setDisplayLanguageCode()

static void setDisplayLanguageCode ( String  languageCode)
static

◆ withdraw()

static void withdraw ( @NonNull final Activity  activity,
@Nullable final GamebaseCallback  callback 
)
static

Withdraws the user.

Since
Added 1.4.0.
Parameters
activityThe activity which is starting the mapping process.
callbackCallbacks the result of withdraw.
See also
com.toast.android.gamebase.GamebaseCallback