Implementing Login
1. Write the login script
Add content to the CustomSignIn method in BackndLogin.cs written in Pre-arrangements.
BackndLogin.cs Before editing
public void CustomSignIn(string id, string pw) {
// Logic for Step 3. Implementing Login
}
After editing
public void CustomSignIn(string id, string pw) {
Debug.Log("Requesting login.");
var bro = Backnd.Player.CustomSignIn(id, pw);
if(bro.IsSuccess()) {
Debug.Log("Login successful. : " + bro);
} else {
Debug.LogError("Login failed. : " + bro);
}
}
2. Add method call to BackndManager.cs
BackndManager, 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.
BackndManager.cs
Before editing(after Step 2. Implementing Sign-up)
async void Test() {
await Task.Run(() => {
BackndLogin.Instance.CustomSignUp("user1", "1234"); // [Addition] BACKND sign-up
Debug.Log("Test complete.");
});
}
After editing
async void Test() {
await Task.Run(() => {
BackndLogin.Instance.CustomSignIn("user1", "1234"); // [Addition] BACKND login
Debug.Log("Test complete.");
});
}
3. 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 'Login successful. : statusCode: 200'.
When errors, such as statusCode : 400, 404, and 409, occur instead of the above log, you can check which error caused the failure in CustomSignIn error case.
4. Check in the console
In BACKND Base > User Management
of BACKND Console, the registration date is the date the user signed up, and the last login date updates the user's most recent login date.
Therefore, the two dates are the same at the point of sign-up, but the last login date keeps changing because the sign-up and login dates become different.