User Tools

Site Tools


docs:api:getauthvalue

GetAuthValue

public static string GetAuthValue(string key, Dictionary<string, object> flattenedData)

Summary:

  • A Dictionary exists in the LivelyWebGL SDK, which holds all the values that were found in the supabase user session data, when the user logged in.
  • A list off all this data cann be found in the supabase tools, under the LWT Editor Window

You can also add your own metadata to the user session data!

Example:

//C#
void UpdatePlayerUniquePlays()
{
    // it wont exist the first time we look for it
    string plays = LivelyWebGL.Supabase.Auth.Session.GetAuthValue("user.user_metadata.plays", LivelyWebGL.Supabase.Auth.Session.FlattenedAuthUserdata);
    int playsInt = 0;
    // so since its going to be null the first time, we skip this step
    if (!string.IsNullOrEmpty(plays) && int.TryParse(plays, out int parsed))
        playsInt = parsed;
    // we add to the total amount of unique plays from this user
    playsInt++;

    // we then create a payload to hold the updated changes
    var userData = new Dictionary<string, object>
    {
        { "plays",  playsInt}
    };

    // since the updateMeatadata uses a coroutine to update, we need to reference any active gameobject with a monobehaviour
    LivelyWebGL.Supabase.Auth.Session.UpdateMetadata(
        this, // since this script is a monobehcaviour and the gameobject is active, we can reference this script
        GetSupabasePreset, // we pass the supabasePreset information so that we can authenticate our request
        userData, // and we pass the userData we want to update
        AfterPlaysUpdated, // what happens when successful
        AfterPlaysFailedToUpdate // what happens if it didn't save?
    );
}
docs/api/getauthvalue.txt · Last modified: by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki