Skip to main content
Version: 5.15.0

Registering Rankings

1. Copy the ranking UUID from BACKND Console

Go to BACKND Console and copy the UUID of the ranking created in BACKND Base > Ranking Management.

2. Write a method for inserting game information

Add content to the RankInsert method in BackendRank.cs written in Pre-arrangements.

At this time, paste the UUID of the ranking copied in No. 1 as the string rankUUID value of the RankInsert method.

Example: "Copied UUID value" -> "4088f640-693e-11ed-ad29-ad8f0c3d4c70"

BackendRank.cs

Before modification

public void RankInsert(int score)
{
// Add content of Step 2. Inserting Rankings
}

After modification

    public void RankInsert(int score)
{
// [Change required] Change the 'copied UUID value' to the UUID value of the ranking created in 'BACKND Console > Ranking Management.'
string rankUUID = "Copied UUID value"; // Example: "4088f640-693e-11ed-ad29-ad8f0c3d4c70"

string tableName = "USER_DATA";
string rowInDate = string.Empty;

// The inDate value of the data used in the game data is required to insert a ranking.
// Therefore, you must load the data and extract its inDate value.
Debug.Log("Attempts data lookup.");
var bro = Backend.GameData.GetMyData(tableName, new Where());

if (bro.IsSuccess() == false)
{
Debug.LogError("An error has occurred while looking up data : " + bro);
return;
}

Debug.Log("Data lookup successful : " + bro);

if (bro.FlattenRows().Count > 0)
{
rowInDate = bro.FlattenRows()[0]["inDate"].ToString();
}
else
{
Debug.Log("The data does not exist. Attempting data insertion.");
var bro2 = Backend.GameData.Insert(tableName);

if (bro2.IsSuccess() == false)
{
Debug.LogError("An error occurred while inserting data : " + bro2);
return;
}

Debug.Log("Data insertion successful : " + bro2);

rowInDate = bro2.GetInDate();
}

Debug.Log("rowInDate of my game information : " + rowInDate); // The extracted rowIndate value is as follows:

Param param = new Param();
param.Add("level", score);

// Edit the data with the extracted rowIndate to the param value and updates the data for the ranking.
Debug.Log("Attempting ranking insertion.");
var rankBro = Backend.URank.User.UpdateUserScore(rankUUID, tableName, rowInDate, param);

if (rankBro.IsSuccess() == false)
{
Debug.LogError("An error has occurred while registering the ranking. : " + rankBro);
return;
}

Debug.Log("Successfully inserted the ranking. : " + rankBro);
}

3. Add method call to BackendManager.cs

BackendManager, which is automatically called when the game is executed, must be used to call this method.
Add it so that the method may be called after BACKND initialization and BACKND login.

BackendManager.cs

Before modification

void Test()
{
BackendLogin.Instance.CustomLogin("user1", "1234"); // Log in to BACKND

// Add a logic to implement ranking functions

Debug.Log("Test complete.");
}

After modification

void Test()
{
BackendLogin.Instance.CustomLogin("user1", "1234"); // BACKND login method

BackendRank.Instance.RankInsert(100); // [Addition] Ranking registration method

Debug.Log("Test complete.");
}

4. Test in Unity

After editing the script, execute Unity debugging and check the console log of Unity.

The method has been successfully called when the log displays 'Successfully inserted the ranking. : statusCode : 204'.
When errors, such as statusCode : 400, 404, 409, occur instead of the above log, you can check which error caused the failure in UpdateUserScore error case.

Error case

An error occurred while looking up rankings. : statusCode : 404
errorCode : NotFoundException
message : rank not found, rank cannot be found

Change the copied UUID value in the first line of the method, string rankUUID = "Copied UUID value"; to the actual UUID of the ranking created in the console.

5. Check in the console

Go to BACKND Console and click the ranking created in BACKND Base > Ranking Management to check the user's place in the ranking.