After Initializing the READYgg SDK, subscribe to the RGNCore.I.AuthenticationChanged event, to handle authentication and get the user's data.
On SignIn with any Auth Provider, credentials are stored in Keystore(Android) & Keychain(IOS) files.
You can use also the RGNUnityInitilizer component to initialize the READYgg SDK. The RGNCore.I.AuthenticationChangedevent is handled in the RGNUnityInitilizer component. When the user logs out from any provider, he automatically is logged in with Guest provider. It is made to store the user progress and make sure the user can switch to email later and keep the progress.
usingRGN;usingRGN.Modules.GameProgress;usingRGN.Modules.SignIn;usingRGN.Modules.UserProfile;usingUnityEngine;namespaceSomeNamespace{internalsealedclassSomeMonoBehaviour:MonoBehaviour {privatevoidOnEnable() {RGNCore.I.AuthenticationChanged+= OnAuthenticationChangedAsync; }privatevoidOnDisable() {RGNCore.I.AuthenticationChanged-= OnAuthenticationChangedAsync; }privateasyncvoidOnAuthenticationChangedAsync(AuthState authState) {switch (authState.LoginState) {caseEnumLoginState.Error:Debug.LogError("On Auth error: "+authState.LoginState+", error: "+authState.LoginResult);break;caseEnumLoginState.Success:var userProfileData =awaitUserProfileModule.I.GetFullUserProfileAsync<GameUserFullProfileData>(RGNCore.I.MasterAppUser.UserId);Debug.Log("User logged in \n"+"UserId :"+userProfileData.userId+"\n"+"Display Name :"+userProfileData.displayName+"\n"); // TODO: Load other data from herebreak;caseEnumLoginState.NotLoggedIn:Debug.Log("User is not logged in"); // TODO: uncomment if needed: // GuestSignInModule.I.TryToSignInAsync();break;default:Debug.LogError("Unhandled Login State: "+authState.LoginState);break; } } }}
Email Login/Logout
usingRGN.Modules.SignIn;namespaceSomeNamespace{internalsealedclassEmailLoginLogout {publicvoidEmailSignIn() { // This call will open a web form // Handle the result in RGNCore.I.AuthenticationChanged event callbackEmailSignInModule.I.TryToSignIn(); }publicvoidEmailSignOut() {EmailSignInModule.I.SignOut(); } }}