Initialize
public BackendReturnObject Initialize();\ public BackendReturnObject Initialize(BackendCustomSetting settings);\ public void InitializeAsync(Backend.BackendCallback callback);\ public void InitializeAsync(BackendCustomSetting settings, Backend.BackendCallback callback);
Parameters
Value | Type | Description |
---|---|---|
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 |
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 |
isSendLogReport | 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 (the feature will only function when the network type is set to HTTP_CLIENT.) | false |
waitUntilInitializeFinish | bool | You 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 packageName is string.Empty, uses the Application.identifier value when initializing SDK.
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 setting value
BackendCustomSetting settings = new BackendCustomSetting();
settings.clientAppID = "Client app ID";
settings.signatureKey = "Signature key";
settings.functionAuthKey = "BACKND Function key";
settings.isSendLogReport = 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)
Backend.InitializeAsync(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 setting value
BackendCustomSetting settings = new BackendCustomSetting();
settings.clientAppID = "Client App ID";
settings.signatureKey = "Signature Key";
settings.functionAuthKey = "BACKND Function Key";
settings.isSendLogReport = true;
settings.timeOutSec = 100;
settings.useAsyncPoll = true;
settings.autoLoadLocationProperties = 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