Initialize
public BackendReturnObject Initialize(bool useAsyncPoll);
public BackendReturnObject Initialize(BackendCustomSetting settings);
public void InitializeAsync(bool useAsyncPoll, Action<BackendReturnObject> callback);
public void InitializeAsync(BackendCustomSetting settings, Action<BackendReturnObject> callback);
Parameters
Value | Type | Description | |
---|---|---|---|
useAsyncPoll | bool | Whether the pooling function will be used to handle callbacks of asynchronous methods in the main thread | |
settings | BackendCustomSetting | The parameter value object to be used when initializing the BACKND SDK | |
callback | Action<BackendReturnObject> | Callback method of the asynchronous method to be called upon initialization success/failure |
useAsyncPoll
If the useAsyncPoll parameter is declared as true, you must utilize an update method or coroutine from a specific Unity object and call the Backend.AsyncPoll method to properly call the asynchronous method's callback..
For more information, refer to the Callback Method Pooling documentation.
BackendCustomSetting
Value | Type | Description | Default |
---|---|---|---|
packageName | string | Game package name | string.Empty |
clientAppID | string | Unique game ID that identifies the game | string.Empty |
signatureKey | string | Key required to encrypt data when exchanging game data with the server | string.Empty |
functionAuthKey | string | Key for authentication when using BACKND Function | string.Empty |
isAllPlatform | bool | Value that determines whether an OS other than Android or iOS devices is allowed If the value is 'false,' an error is returned when a user attempts to connect to the server from an OS other than Android or iOS. | true |
sendLogReport | bool | Value that determines whether additional logs are stored in the server when a request is sent to the server. | true |
timeOutSec | uint | Determines the time the system will wait for the server when the response does not arrive within the set time(seconds). default: 100 seconds, min: 30 seconds, max: 100 seconds | 100 |
useAsyncPoll | bool | Whether the pooling function will be used to handle callbacks of asynchronous methods in the main thread | false |
If packageName is string.Empty, Application.identifier value is used for the SDK initialization.
Description
To use BACKND SDK, you must undergo SDK initialization.
The initialization process only needs to be done once while the game is running.
If BackendCustomSetting is passed as a parameter value of the initialization method, all values of The Backend Settings set in the Unity Inspector window are ignored,
and the initialization of SDK is attempted with the values defined in BackendCustomSettings.
Values defined in The Backend Settings cannot be used interchangeably with values defined in BackendCustomSetting.
Example
Synchronous
using BackEnd;
void Start()
{
// First way(synchronous)
var bro = Backend.Initialize(true);
if(bro.IsSuccess())
{
// Logic when initialization succeeds
}
else
{
// Logic when initialization fails
}
}
Synchronous(SDK settings value declared directly)
using BackEnd;
void Start()
{
// Second way(synchronous)
// SDK settings value
BackendCustomSetting settings = new BackendCustomSetting();
settings.clientAppID = "Client app ID";
settings.signatureKey = "Signature key";
settings.functionAuthKey = "BACKND Function key";
settings.isAllPlatform = true;
settings.sendLogReport = true;
settings.timeOutSec = 100;
settings.useAsyncPoll = true;
var bro = Backend.Initialize(settings);
if(bro.IsSuccess())
{
// Logic when initialization succeeds
}
else
{
// Logic when initialization fails
}
}
Asynchronous
using BackEnd;
void Start()
{
// Third way(asynchronous)
Backend.InitializeAsync(true, callback => {
if(callback.IsSuccess())
{
// Logic when initialization succeeds
}
else
{
// Logic when initialization fails
}
});
}
Asynchronous(SDK settings value declared directly)
using BackEnd;
void Start()
{
// Fourth way(asynchronous)
// SDK settings value
BackendCustomSetting settings = new BackendCustomSetting();
settings.clientAppID = "Client app ID";
settings.signatureKey = "Signature key";
settings.functionAuthKey = "BACKND Function key";
settings.isAllPlatform = true;
settings.sendLogReport = true;
settings.timeOutSec = 100;
settings.useAsyncPoll = true;
Backend.InitializeAsync(settings, callback => {
if(callback.IsSuccess())
{
// Logic when initialization succeeds
}
else
{
// Logic when initialization fails
}
});
}
Return casess
Success cases
Server setting success
statusCode : 204
In addition, is printed on the Unity debug console window.
Error cases
When the Client App ID or Signature Key is null or string.Empty
statusCode : 400
errorCode : InitializeFail
When the Client App ID or Signature Key is invalid
statusCode : 404
errorCode : NotFoundException