Authentication
Integrate Account Features
Give your players a seamless experience with our account features.
Switch Account

The Switch Account feature allows players to change between different accounts or create a new one. This is particularly useful for games that support multiple profiles or for users who want to start fresh.
How to Implement
To trigger the Switch Account UI, use the following method:
Noctua.Auth.SwitchAccount()
This method will open a pre-built UI that handles the account switching process.
Usage Example
using UnityEngine;
using UnityEngine.UI;
using Noctua;
public class AccountManager : MonoBehaviour
{
[SerializeField]
private Button switchAccountButton;
private void Start()
{
if (switchAccountButton != null)
{
switchAccountButton.onClick.AddListener(SwitchAccountTapped);
}
else
{
Debug.LogError("Switch Account Button not assigned in the inspector");
}
}
private void SwitchAccountTapped()
{
try
{
Noctua.Auth.SwitchAccount();
}
catch (Exception e)
{
if (e is NoctuaException noctuaEx)
{
Debug.Log("NoctuaException: " + noctuaEx.ErrorCode + " : " + noctuaEx.Message);
} else {
Debug.Log("Exception: " + e);
}
}
}
private void OnDestroy()
{
if (switchAccountButton != null)
{
switchAccountButton.onClick.RemoveListener(SwitchAccountTapped);
}
}
}
User Center

The User Center provides a centralized location for players to manage their account settings, view their profile, and access other account-related features.
How to Implement
To open the User Center UI, use the following method:
Noctua.Auth.ShowUserCenter()
This method will display a pre-built UI with various account management options.
Usage Example
using UnityEngine;
using UnityEngine.UI;
using Noctua;
public class UserCenterManager : MonoBehaviour
{
[SerializeField]
private Button userCenterButton;
private void Start()
{
if (userCenterButton != null)
{
userCenterButton.onClick.AddListener(UserCenterTapped);
}
else
{
Debug.LogError("User Center Button not assigned in the inspector");
}
}
private void UserCenterTapped()
{
Noctua.Auth.ShowUserCenter((result, error) =>
{
if (error != null)
{
Debug.LogError($"Failed to open User Center: {error.Message}");
return;
}
Debug.Log("User Center opened successfully");
});
}
private void OnDestroy()
{
if (userCenterButton != null)
{
userCenterButton.onClick.RemoveListener(UserCenterTapped);
}
}
}
Handle Account Changes
When a user modifies their account information or switches accounts, your game needs to respond appropriately. Noctua provides an event that you can subscribe to for handling these changes.
How to Implement
To handle account changes, subscribe to the Noctua.Auth.OnAccountChanged
event.
Noctua.Auth.OnAccountChanged += OnAccountChanged;
Usage Example
private void OnAccountChanged(UserBundle userBundle)
{
Debug.Log($"Account changed: {userBundle.Player.Id}");
}
Handle Account Deletion
When a user chooses to delete their account, your game should handle this event gracefully, cleaning up any local data and potentially logging the user out.
How to Implement
To handle account deletion, subscribe to the Noctua.Auth.OnAccountDeleted
event.
Noctua.Auth.OnAccountDeleted += OnAccountDeleted;
Usage Example
private void OnAccountDeleted(UserBundle userBundle)
{
Debug.Log($"Account deleted: {userBundle.Player.Id}");
}
Remember to always handle these account-related events with care, ensuring that your game state remains consistent and that the user experience is smooth throughout these transitions.