Manage profiles

Players can use profiles to sign in to multiple accounts on a single device. Profiles add a level of isolation to the values saved to the PlayerPrefs. Profiles are not automatically persisted; it’s up to developers to determine how to manage them.

Switch profiles

Players must be signed out to switch the current profile. Use AuthenticationService.Instance.SwitchProfile(profileName). The profile name only supports alphanumeric values, `-`, `_` and has a maximum length of 30 characters.

If a player is not signed out, SwitchProfile throws an AuthenticationException with the error code AuthenticationErrorCodes.ClientInvalidUserState.

If an invalid name is used, SwitchProfile throws an AuthenticationException with the error code AuthenticationErrorCodes.ClientInvalidProfile

Current profile

To view the current profile, use AuthenticationService.Instance.Profile.

Default profile

If no profile is provided in the initialization options, the value default is used.

Set the profile at initialization

Optionally, you can set the profile when initializing UnityServices. The AuthenticationService uses the value default if no profile is provided.

async Task InitializeUnityServices()
{
    var options = new InitializationOptions();
    options.SetProfile(“test_profile”);
    await UnityServices.InitializeAsync(options);
}