Skip to main content
Version: 5.15.0

Initialize

public BackendReturnObject Initialize();
public BackendReturnObject Initialize(BackendCustomSetting settings);
public void InitializeAsync(Backend.BackendCallback callback);
public void InitializeAsync(BackendCustomSetting settings, Backend.BackendCallback callback);

Parameters

ValueTypeDescription
settingsBackendCustomSettingThe parameter value object to be used when initializing the BACKND SDK
callbackAction<BackendReturnObject>Callback method of the asynchronous method to be called upon initialization success/failure

BackendCustomSetting

ValueTypeDescriptionDefault
packageNamestringGame package namestring.Empty
clientAppIDstringUnique game ID that identifies the gamestring.Empty
signatureKeystringKey required to encrypt data when exchanging game data with the serverstring.Empty
functionAuthKeystringKey for authentication when using BACKND Functionstring.Empty
sendLogReportboolValue that determines whether additional logs are stored in the server when a request is sent to the server.true
timeOutSecuintDetermines the time to process as a timeout error when a request is sent to the server and there is no response within a set time (seconds).
default: 100 seconds, min: 30 seconds, max: 100 seconds100
useAsyncPollboolWhether the pooling function will be used to handle callbacks of asynchronous methods in the main thread (the feature will only function when the network type is set to HTTP_CLIENT.)false
waitUntilInitializeFinishboolYou can choose whether to call the country information asynchronously or to invoke it after the initialization function to receive the country information in the same response.false

If the packageName is string.Empty, the SDK will use the value of Application.identifier during 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();
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.sendLogReport = true;
settings.timeOutSec = 100;

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)

// You can specify whether to enable the logic for bringing external thread responses to the main thread.
bool useAsyncPoll = true;

// You can also decide whether to call the country information asynchronously or retrieve it after the initialization response. (if set to false, the country information will be fetched after the initialization response.)
bool autoLocationToAsync = true;
Backend.InitializeAsync(useAsyncPoll, autoLocationToAsync, 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;
settings.autoLocationToAsync = false;

Backend.InitializeAsync(settings, callback => {
if(callback.IsSuccess())
{
// Logic when initialization succeeds
}
else
{
// Logic when initialization fails
}
});
}

Return Cases


Success Case statusCode : 204
message : Success

In addition, Server setting success is printed on the Unity debug console window.


Error Case When the Client App ID or Signature Key is invalid
statusCode : 404
errorCode : NotFoundException
message : game not found, game cannot be found

When the Client App ID or Signature Key is null or string.Empty
statusCode : 400
errorCode : InitializeFail
message : Please Edit the Baceknd Settings