How to check if login with Unity Player Accounts

How do you check if you are logged in with Unity Player Accounts? I know

if (PlayerAccountService.Instance.IsSignedIn == true)
{
     logInWithUnity = true;
}

It works, but only for the first-time login. So, what I’m looking for is when the player restarts the app and logs in. so I change my login menu to the unity buttons unlink and AccountPortal.

I recall that was a bit confusing for me too but can’t remember exactly what it was.

The AccessToken also should be non-null if the player is signed in.

You also have to have run anomymous sign in before IsSignedIn becomes true. Likewise, there’s an async call to get the PlayerInfo property which, before you call that async method, contain partially cached values at the time I tested this.

Best to try logging all the state variables in IAuthenticationService to see what their values are in each situation to understand what you need to use.

thanks for the info. I figured out what works.

IAuthenticationService authenticationService = AuthenticationService.Instance;

string unityId;
unityId = authenticationService.PlayerInfo.GetUnityId();

if (unityId != null)
{
    logInWithUnity = true;
}