/// <summary> /// Method for on login complete event /// </summary> /// <param name="_msg"></param> private void OnLoginSuccess(CallbackLoginMessage _msg) { if (_msg.IsSuccess) { EasyProfileManager.Instance.GetUserData(_callback => { EasyProfileManager.Instance.PROFILE_CONTROLLER.CURRENT_USER_DATA = _callback.UserData; EasyProfileManager.Instance.VIEW_CONTROLLER.HideLogin(); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); if (EasyProfileManager.Instance.PROFILE_SETTING.AllowToLoadScene) { SceneManager.LoadScene(EasyProfileManager.Instance.PROFILE_SETTING.ProfileSceneName); } }); } else { if (_msg.MessageCode == ProfileMessageCode.None) { PopupMessage msg = new PopupMessage(); msg.Title = "Error"; msg.Message = _msg.ErrorMessage; EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMessage(msg); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); } else { EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMSG(ProfileMessageCode.EmailConfirm, EasyProfileManager.Instance.VIEW_CONTROLLER.ShowLogin); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); } } }
/// <summary> /// Show popup view window /// </summary> /// <param name="_msg">PopugMessage object</param> public void ShowPopupMessage(PopupMessage _msg) { if (PopupViewObject == null) { PopupViewObject = Instantiate(EasyProfileManager.Instance.PROFILE_SETTING.PopupWindowPrefab, transform); } PopupViewObject.SetActive(true); PopupViewObject.GetComponent <PopupController>().ShowMessage(_msg); }
/// <summary> /// Callback for login complete /// </summary> /// <param name="_msg"></param> public void OnLoginSuccess(CallbackLoginMessage _msg) { if (_msg.IsSuccess) { if (!string.IsNullOrEmpty(EmailInput.text) && !string.IsNullOrEmpty(PasswordInput.text) && EasyProfileManager.Instance.PROFILE_SETTING.AutoSaveUserCredentials) { EasyProfileManager.Instance.SaveUserCredentials(_msg.Gredentials.UserLogin, _msg.Gredentials.UserPassword); } EasyProfileManager.Instance.GetUserData(_callback => { EasyProfileManager.Instance.PROFILE_CONTROLLER.CURRENT_USER_DATA = _callback.UserData; EasyProfileManager.Instance.VIEW_CONTROLLER.HideLogin(); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); if (EasyProfileManager.Instance.PROFILE_SETTING.AllowToLoadScene) { SceneManager.LoadScene(EasyProfileManager.Instance.PROFILE_SETTING.ProfileSceneName); } }); } else { if (_msg.MessageCode == ProfileMessageCode.None) { PopupMessage msg = new PopupMessage(); msg.Title = "Error"; msg.Message = _msg.ErrorMessage; EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMessage(msg); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); } else { EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMSG(ProfileMessageCode.EmailConfirm, EasyProfileManager.Instance.VIEW_CONTROLLER.ShowLogin); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); } } }
/// <summary> /// Callback for set user data complete /// </summary> /// <param name="_msg"></param> public void OnSetUserDataComplete(CallbackSetUserDataMessage _msg) { if (_msg.IsSuccess) { if (EasyProfileManager.Instance.PROFILE_SETTING.UseEmailConfirm) { EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMSG(ProfileMessageCode.RegistrationSuccessWithConfirm, CloseWindow); EasyProfileManager.Instance.SendMailVerification(); } else { EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMSG(ProfileMessageCode.RegistrationSuccess, CloseWindow); } EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); } else { PopupMessage msg = new PopupMessage(); msg.Title = "Error"; msg.Message = _msg.ErrorMessage; EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMessage(msg); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); } }
/// <summary> /// Callback for registration complete /// </summary> /// <param name="_msg"></param> public void OnRegistrationComplete(CallbackRegistrationMessage _msg) { if (_msg.IsComplete) { string _login = EmailInput.text.Trim(); string _password = PasswordInput.text.Trim(); User _user = new User(); _user.UserID = _msg.UserID; _user.DataRegistration = EasyProfileManager.Instance.GetSystemDate(); _user.FirstName = FirstNameInput.text; _user.LastName = LastNameInput.text; _user.NickName = NickNameInput.text; _user.FullName = FirstNameInput.text + " " + LastNameInput.text; EasyProfileManager.Instance.SetUserData(_user, OnSetUserDataComplete); } else { PopupMessage msg = new PopupMessage(); msg.Title = "Error"; msg.Message = _msg.ErrorMessage; EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMessage(msg); EasyProfileManager.Instance.VIEW_CONTROLLER.HideLoading(); } }
/// <summary> /// Show popup message by specific code /// </summary> /// <param name="_code">Pupup message code</param> /// <param name="_callback">Add on close pupp method</param> public void ShowPopupMSG(ProfileMessageCode _code, Action _callback = null) { PopupMessage msg = new PopupMessage(); msg.Callback = _callback; switch (_code) { case ProfileMessageCode.EmptyEmail: msg.Title = "Error"; msg.Message = "Email is empty"; break; case ProfileMessageCode.EmptyFirstName: msg.Title = "Error"; msg.Message = "First Name is empty"; break; case ProfileMessageCode.EmptyLastName: msg.Title = "Error"; msg.Message = "Last Name is empty"; break; case ProfileMessageCode.EmptyNickName: msg.Title = "Error"; msg.Message = "Nick Name is empty"; break; case ProfileMessageCode.EmptyPassword: msg.Title = "Error"; msg.Message = "Password is empty"; break; case ProfileMessageCode.PasswordNotMatch: msg.Title = "Error"; msg.Message = "Passwords do not match"; break; case ProfileMessageCode.EmailNotValid: msg.Title = "Error"; msg.Message = "Email is not valid"; break; case ProfileMessageCode.SmallPassword: msg.Title = "Error"; msg.Message = "Password is too small. Min value is " + EasyProfileManager.Instance.PROFILE_SETTING.MinAllowPasswordCharacters.ToString(); break; case ProfileMessageCode.RegistrationSuccess: msg.Title = "Success"; msg.Message = "Registration Success!"; break; case ProfileMessageCode.RegistrationSuccessWithConfirm: msg.Title = "Success"; msg.Message = "Registration Success! Please confirm your email address"; break; case ProfileMessageCode.EmailConfirm: msg.Title = "Error"; msg.Message = "Please confirm your email address"; break; case ProfileMessageCode.FailedUploadImage: msg.Title = "Error"; msg.Message = "Failed Upload Image"; break; case ProfileMessageCode.RestorePassword: msg.Title = "Success"; msg.Message = "Сheck your mail to continue"; break; default: Debug.Log("NOTHING"); break; } ShowPopupMessage(msg); }
private void TestsCalls() { // get system data string currentDate = EasyProfileManager.Instance.GetSystemDate(); // save user login data EasyProfileManager.Instance.SaveUserCredentials("*****@*****.**", "password123"); // check if has user login data bool hasSavedCredendtials = EasyProfileManager.Instance.HasSavedCredentials(); // clear user login data EasyProfileManager.Instance.ClearUserCredentials(); // get saved user login data UserCredentials _userCred = EasyProfileManager.Instance.GetSavedCredentials(); Debug.Log("Login" + _userCred.UserLogin); Debug.Log("Password" + _userCred.UserPassword); // init firebase EasyProfileManager.Instance.InitFirebase(OnFirebaseInited); // check is firebase is inited bool IsFirebaseInited = EasyProfileManager.Instance.IsFirebaseInited(); // register new user EasyProfileManager.Instance.RegisterNewUser("*****@*****.**", "password123", OnRegistrationComplete); // register new user with custom token id User _newUser = new User(); _newUser.DataRegistration = EasyProfileManager.Instance.GetSystemDate(); _newUser.FirstName = "First Name"; _newUser.FullName = "Full Name"; _newUser.LastName = "Last Name"; _newUser.NickName = "NickName"; _newUser.Phone = "+38093333333"; EasyProfileManager.Instance.RegisterNewUserWithCustomTokenID("your custom token id", _newUser, OnRegistrationComplete); // register new user with custom auth system User _newUser3 = new User(); _newUser3.DataRegistration = EasyProfileManager.Instance.GetSystemDate(); _newUser3.FirstName = "First Name"; _newUser3.FullName = "Full Name"; _newUser3.LastName = "Last Name"; _newUser3.NickName = "NickName"; _newUser3.Phone = "+38093333333"; EasyProfileManager.Instance.RegisterNewUserWithCustomAuthSystem("your user id", _newUser3, OnRegistrationComplete); // register new user with Credential object UserCredentials _userCredential = new UserCredentials(); _userCredential.UserLogin = "******"; _userCredential.UserPassword = "******"; EasyProfileManager.Instance.RegisterNewUser(_userCredential, OnRegistrationComplete); // login user EasyProfileManager.Instance.LogIn("*****@*****.**", "password123", OnUserLogined); // login user with Credential object UserCredentials _userCredential2 = new UserCredentials(); _userCredential2.UserLogin = "******"; _userCredential2.UserPassword = "******"; EasyProfileManager.Instance.LogIn(_userCredential2, OnUserLogined); // login user with custom token id EasyProfileManager.Instance.LogInWithCustomTokenID("your custom token id", OnUserLogined); // login user with custom auth system EasyProfileManager.Instance.LogInWithCustomAuthSystem("your user id", OnUserLogined); // upload image avatar Texture2D TestTexture = null; RequestUploadImage _imageUploadRequset = new RequestUploadImage(); _imageUploadRequset.OwnerId = EasyProfileManager.Instance.PROFILE_CONTROLLER.USER_ID; _imageUploadRequset.Texture = TestTexture; EasyProfileManager.Instance.UploadAvatar(_imageUploadRequset, OnUploadAvatarImageComplete); // get image avatar RequestGetProfileImage _imageGetRequest = new RequestGetProfileImage(); _imageGetRequest.Id = EasyProfileManager.Instance.PROFILE_CONTROLLER.USER_ID; _imageGetRequest.Size = ImageSize.Size_512; EasyProfileManager.Instance.GetProfileImage(_imageGetRequest, OnGetProfileImageComplete); // get user data EasyProfileManager.Instance.GetUserData(OnGetUserDataComplete); // get user data by user id EasyProfileManager.Instance.GetUserDataByID(EasyProfileManager.Instance.PROFILE_CONTROLLER.USER_ID, OnGetUserDataComplete); // send verification mail EasyProfileManager.Instance.SendMailVerification(OnVerificationEmailSended); // send reset password EasyProfileManager.Instance.SendResetPasswordEmail("*****@*****.**", OnResetPasswordToEmailSended); // set user data User _newUser2 = new User(); _newUser2.UserID = "userID"; // get it from registration complete message or login complete message _newUser2.DataRegistration = EasyProfileManager.Instance.GetSystemDate(); _newUser2.FirstName = "First Name"; _newUser2.FullName = "Full Name"; _newUser2.LastName = "Last Name"; _newUser2.NickName = "NickName"; _newUser2.Phone = "+38093333333"; EasyProfileManager.Instance.SetUserData(_newUser2, OnSetUserDataComplete); // get/set user full name EasyProfileManager.Instance.GetUserFullName(OnGetUserFullName); EasyProfileManager.Instance.GetUserFullNameByID("userID", OnGetUserFullName); EasyProfileManager.Instance.SetUserFullName("new value", OnSetUserValueComplete); // get/set user last name EasyProfileManager.Instance.GetUserLastName(OnGetUserLastName); EasyProfileManager.Instance.GetUserLastNameByID("userID", OnGetUserLastName); EasyProfileManager.Instance.SetUserLastName("new value", OnSetUserValueComplete); // get/set user first name EasyProfileManager.Instance.GetUserFirstName(OnGetUserFirstName); EasyProfileManager.Instance.GetUserFirstNameByID("userID", OnGetUserFirstName); EasyProfileManager.Instance.SetUserFirstName("new value", OnSetUserValueComplete); // get/set user nick name EasyProfileManager.Instance.GetUserNickName(OnGetUserNickName); EasyProfileManager.Instance.GetUserNickNameByID("userID", OnGetUserNickName); EasyProfileManager.Instance.SetUserNickName("new value", OnSetUserValueComplete); // get/set user phone number EasyProfileManager.Instance.GetUserPhone(OnGetUserPhone); EasyProfileManager.Instance.GetUserPhoneByID("userID", OnGetUserPhone); EasyProfileManager.Instance.SetUserPhone("new value", OnSetUserValueComplete); // get user registration date EasyProfileManager.Instance.GetUserRegistrationDate(OnGetRegistrationDate); EasyProfileManager.Instance.GetUserRegistrationDateByID("userID", OnGetRegistrationDate); // get all users EasyProfileManager.Instance.GetAllUsers(OnGetAllUsers); // log out EasyProfileManager.Instance.LogOut(OnLogOut); // search user EasyProfileManager.Instance.SearchUsers("Jack", OnSearchUserComplete); // set user custom data EasyProfileManager.Instance.SetCustomValue("Gold", 150, OnSetCustomValueComplete); // set user custom data by user id EasyProfileManager.Instance.SetCustomValueByUserID("UserID", "Gold", 150, OnSetCustomValueComplete); // get user custom data EasyProfileManager.Instance.GetCustomValue("Gold", OnGetCustomValueComplete); // get user custom data by user id EasyProfileManager.Instance.GetCustomValueByUserID("UserID", "Gold", OnGetCustomValueComplete); // update activity EasyProfileManager.Instance.UpdateUserActivity(OnUpdateActivityComplete); // get user activity EasyProfileManager.Instance.GetUserLastActivity("UserID", OnActivityGetted); // get server timestamp EasyProfileManager.Instance.GetServerTimestamp(OnServerTimeStampGetted); if (EasyProfileManager.Instance.PROFILE_CONTROLLER.IsLogined()) { // get last saved user data User _user = EasyProfileManager.Instance.PROFILE_CONTROLLER.CURRENT_USER_DATA; Debug.Log(_user.NickName); // get last cached user avatar if (EasyProfileManager.Instance.PROFILE_CONTROLLER.PROFILE_IMAGE_LOADED) { Texture2D _avatarTexture = EasyProfileManager.Instance.PROFILE_CONTROLLER.CACHED_AVATAR; } // get firebase user object FirebaseUser fUSer = EasyProfileManager.Instance.PROFILE_CONTROLLER.FIREBASE_USER; Debug.Log(fUSer.UserId); string UserID = EasyProfileManager.Instance.PROFILE_CONTROLLER.USER_ID; } // show login windows EasyProfileManager.Instance.VIEW_CONTROLLER.ShowLogin(); // show loading windows EasyProfileManager.Instance.VIEW_CONTROLLER.ShowLoading(); // show popup windows PopupMessage _popupMSG = new PopupMessage(); _popupMSG.Callback = OnPopupMessageClosed; _popupMSG.Title = "Some Title"; _popupMSG.Message = "Some Message"; EasyProfileManager.Instance.VIEW_CONTROLLER.ShowPopupMessage(_popupMSG); // show registration windows EasyProfileManager.Instance.VIEW_CONTROLLER.ShowRegistration(); // show restore password windows EasyProfileManager.Instance.VIEW_CONTROLLER.ShowRestorePassword(); // show user profile windows EasyProfileManager.Instance.VIEW_CONTROLLER.ShowUserProfileView(); }
/// <summary> /// Display popup message /// </summary> /// <param name="_msg">PopupMessage object</param> public void ShowMessage(PopupMessage _msg) { TitleLabel.text = _msg.Title; MessageLabel.text = _msg.Message; Callback = _msg.Callback; }