UpdateLocalUserMetadataJson (Unity)
public static void UpdateLocalUserMetadataJson(string key, JObject jValue, Action<string> onSuccess = null, Action<string> onFailure = null)
- Description
Updates the local user’s metadata via key-value lookup where key is a JObject
. If the key does not exist, a new key-value pair is created.
Â
For more information on user metadata, see INSERTPAGE for details.
- Sample
using CavrnusSdk.API;
using UnityEngine;
public class ExampleScript: MonoBehaviour
{
public void RandomizeLocalUserColor()
{
CavrnusFunctionLibrary.AwaitAuthentication(auth => {
// Create a random color and structure it as JSON
var randomColor = Random.ColorHSV();
var jsonValue = new JObject
{
{ "r", randomColor.r },
{ "g", randomColor.g },
{ "b", randomColor.b },
{ "a", randomColor.a }
};
// Update the metadata with the JSON object
CavrnusFunctionLibrary.UpdateLocalUserMetadataJson("userColor", jsonValue, print, print);
});
}
}