The user profile module is used to store user specific data related to his identity.
UserProfileData
userId (string): Unique READYgg ID for a user. Authenticated user has the same ID accross applications using READYgg.
email (string): Email of the authenticated user.
displayName (string): Authenticated user share the same display name accross applications using READYgg.
profilePicture (userProfilePicture): Authenticated user share the same profile picture accross applications using READYgg.
bio (string): Authenticated user share the same bio accross applications using READYgg.
currencies (List<Currency>): Contains all the currencies user collected for your application.
UserProfileData class methods
GetRGNCoinBalance();
Return the amount of rgn-coin for this user.
GetCustomCoinBalance(string currencyName);
Return the amount of your custom currency for this user.
Load User Profile
using RGN;
using RGN.Modules.UserProfile;
using UnityEngine;
public class UserProfileExample : MonoBehaviour
{
public async void LoadUserProfileDataAsync()
{
string userId = RGNCore.I.MasterAppUser.UserId;
UserProfileData userProfileData = await UserProfileModule.I.GetFullUserProfileAsync<UserProfileData>();
Debug.Log($"Display name : {userProfileData.displayName} \n" +
$"Bio : {userProfileData.bio} \n" +
$"Email : {userProfileData.email} \n");
}
}
Update UserName/Display Name
using UnityEngine;
using RGN.Modules.UserProfile;
public class UserProfileExamples : MonoBehaviour
{
private async void UpdateDisplayName()
{
string newDisplayName = await UserProfileModule.I.SetDisplayNameAsync("New display name");
Debug.Log($"Display name : {newDisplayName}");
}
}
Update User Bio
using UnityEngine;
using RGN.Modules.UserProfile;
public class UserProfileExamples : MonoBehaviour
{
private async void UpdateUserBio()
{
string newBio = await UserProfileModule.I.SetBioAsync("This is my user description");
Debug.Log($"Bio : {newBio}");
}
}
Retrieve User Currencies
using UnityEngine;
using System.Collections.Generic;
using RGN.Modules.UserProfile;
using RGN.Modules.Currency;
public class UserProfileExamples : MonoBehaviour
{
private async void GetUserCurrencies()
{
List<Currency> currencies = await UserProfileModule.I.GetUserCurrenciesAsync();
foreach (Currency currency in currencies)
{
Debug.Log($"Type : {currency.name} Quantity : {currency.quantity}");
}
}
}
"rgn-coin" Currency
Similar to other in-game currencies but it can only be obtained by making In-App Purchases - it cannot be earned or given as a reward to players. It is consumed to purchase NFT #virtual-items.
For more details about the rgn-coin, please refer to the Currency module.