Add observer. Through this observer, you can receive the several useful notification
such as "user ban", "network status change" and "launching status change"(playable or not).
Since Added 2.0.0.
example
toast.Gamebase.addObserver((event) => {
consttype = event.type;
const data = event.data;
const code = data.code;
if (type === 'network') {
if (code === -1) console.log('network offline');
elseconsole.log('network online');
} elseif (type === 'heartbeat') {
if (code === 6) console.log('user banned');
if (code === 7) console.log('invalid user');
} elseif (type === 'launching') {
if (200 =< code && code < 300) console.log('playable');
elseif (code === 303) console.log('service is on inspecting.');
elseif (code === 304) console.log('Gamebase is on inspecting.');
elseconsole.log('not playable');
}
});
Add server push event. Through this server push event,
you can receive the several useful notification
such as "app kickout".
This event is occured by WebSocket server push event from TOAST Gamebase Console.
Since Added 2.0.0.
example
toast.Gamebase.addServerPushEvent((event) => {
consttype = event.type;
const data = event.data;
if (type === 'appKickout') {
console.log('App Kickout occured.');
} else {
console.log('other server push event occured.');
console.log(event);
}
});
Parameters
serverPushEvent: ServerPushEvent
Returns void
Static getAccessToken
getAccessToken(): string
description
This method returns the Gamebase access token.
Since Added 2.0.0.
Returns string
string
Static getAuthToken
getAuthToken(): AuthToken
description
This method returns the current AuthToken that has several information
such as user id and access token.
Since Added 2.0.0.
Returns AuthToken
AuthToken
Static getBanInfo
getBanInfo(): AuthBanInfo
description
This method returns user's ban information.
If user is banned through TOAST Gamebase console(or other method), it returns useful information.
But user is normal user(not banned), it will return null.
Since Added 2.0.0.
Returns AuthBanInfo
AuthBanInfo
Static getCountryCode
getCountryCode(): string
description
This method returns device country code using browser API, navigator.language.
Since Added 2.0.0.
Returns string
string
Static getDisplayLanguageCode
getDisplayLanguageCode(): string
description
This method returns Gamebase display language code.
Gamebase uses this display language code to Gamebase UI such as
maintenace modal and user banned modal.
Since Added 2.0.0.
Returns string
string
Static getDisplayLanguageTable
getDisplayLanguageTable(): any
description
This method returns Gamebase Display Language Table.
Gamebase uses this display language table to find out which text should be
rendered at Gamebase UI such as maintenace modal and user banned modal.
You can checek the default display language table through the toast.Gamebase.getDisplayLanguageTable() API.
Since Added 2.0.0.
Returns any
any
Static getLanguageCode
getLanguageCode(): string
description
This method returns device language code using browser API, navigator.language.
Since Added 2.0.0.
Returns string
string
Static getLastLoggedInProvider
getLastLoggedInProvider(): string
description
This method returns the last logged in provider.
If Gamebase is not initialized or does not have login history, it will return null.
As Gamebase uses the cookie for saving several information, when cookie is cleared,
it could return the null.
Since Added 2.0.0.
Returns string
string
Static getSDKVersion
getSDKVersion(): string
description
This method returns the Gamebase sdk version.
Since Added 2.0.0.
Returns string
string
Static getUserID
getUserID(): string
description
This method returns the Gamebase userId who is already logged in.
This method returns true if Gamebase is initialized.
Since Added 2.0.0.
Returns boolean
boolean
Static isSandbox
isSandbox(): boolean
description
Gamebase provides the sandbox mode.
This method returns wheater this project is on sandbox or not.
If you want to set the project with sandbox mode, please contact us.
Since Added 2.0.0.
Returns boolean
boolean
Static isSuccess
isSuccess(error: GamebaseError): boolean
description
This method returns the result that Gamebase API success or not.
Set the debug mode.
If debugmode is enabled, Gamebase write logs to console.
As These logs could be sensitive, be careful to set it enabled.
You can hook the whole logs using toast.GamebaseLogger.registerLogger(new CustomLogger());
And you can set it off using toast.GamebaseLogger.enableLog = false;
Set Gamebase Display Language Table.
Gamebase uses this display language table to find out which text should be
rendered at Gamebase UI such as maintenace modal and user banned modal.
What is important is that default display language table is embeded in Gamebase sdk,
and if you set the display language table through this mehtod,
Gamebase internally merged both of the table.
You can checek the default display language table through the toast.Gamebase.getDisplayLanguageTable() API.
Add observer. Through this observer, you can receive the several useful notification such as "user ban", "network status change" and "launching status change"(playable or not).
Since Added 2.0.0.
toast.Gamebase.addObserver((event) => { const type = event.type; const data = event.data; const code = data.code; if (type === 'network') { if (code === -1) console.log('network offline'); else console.log('network online'); } else if (type === 'heartbeat') { if (code === 6) console.log('user banned'); if (code === 7) console.log('invalid user'); } else if (type === 'launching') { if (200 =< code && code < 300) console.log('playable'); else if (code === 303) console.log('service is on inspecting.'); else if (code === 304) console.log('Gamebase is on inspecting.'); else console.log('not playable'); } });