public void Init(object initData, System.Action <string, bool> callback) { mLoggedIn = SecurePrefs.GetInt("DeviceLoggedIn", 0) > 0; mDeviceAuthId = SecurePrefs.GetString("DeviceAuthId", Device.UniqueIdentifier); callback(null, true); }
public void Authenticate(bool silent, System.Action <string, object> callback) { if (silent) { if (mLoggedIn) { var data = Johny.HashtablePool.Claim(); data["udid"] = mDeviceAuthId; callback(null, data); } else { callback(null, null); } } else { mLoggedIn = true; SecurePrefs.SetInt("DeviceLoggedIn", EB.Time.Now); SecurePrefs.SetString("DeviceAuthId", mDeviceAuthId); var data = Johny.HashtablePool.Claim(); data["udid"] = mDeviceAuthId; callback(null, data); } }
public void OnAsLogin(string token) { EB.Debug.Log("OnAsLogin token = {0} ", token); if (!string.IsNullOrEmpty(token)) { mIsLoggedIn = true; SecurePrefs.SetInt("AsUid", int.Parse(pxAsUserID())); if (mLoginCallBack != null) { Hashtable auth = new Hashtable(); auth["token"] = token; mLoginCallBack(null, auth); mLoginCallBack = null; } } else { if (mLoginCallBack != null) { mLoginCallBack("LoginFailed", null); mLoginCallBack = null; } } }
static public void SaveAccountData(string phone, string password) { UserInfo userInfo = UserInfoList.Find(u => u.phone == phone); if (userInfo == null) { UserInfoList.Add(new UserInfo() { phone = phone, password = password }); } else { userInfo.password = password; } SecurePrefs.SetString("UserID", phone); SecurePrefs.SetString("UserPwd", password); string userInfos = SecurePrefs.GetString("UserInfoData", ""); Debug.Log("store before UserInfoData:" + userInfos); Hashtable userHashtable = EB.JSON.Parse(userInfos) as Hashtable; if (userHashtable != null && userHashtable.ContainsKey(phone)) { userHashtable.Remove(phone); } userHashtable = userHashtable ?? Johny.HashtablePool.Claim(); userHashtable.Add(phone, password); SecurePrefs.SetString("UserInfoData", EB.JSON.Stringify(userHashtable)); Debug.Log("store UserInfoData:" + SecurePrefs.GetString("UserInfoData", "")); }
public void InitSDK(object options, System.Action <string, bool> callback) { #if UNITY_EDITOR mIsInited = false; mIsLoggedIn = false; callback(null, mIsInited); #elif UNITY_IPHONE if (mIsInited) { callback(null, true); } else { new GameObject("as_callback", typeof(SparxAsSDKManager)); //int appId = Dot.Integer("appId", options, 2241); //string appKey = Dot.String("appKey", options, "9d5e83cf5653400b959cd03c422579c6"); int appId = Dot.Integer("appId", options, 2356); string appKey = Dot.String("appKey", options, "2cd489c773204183af5c30c44360501e"); pxAsInit(appId, appKey); mIsInited = true; mIsLoggedIn = SecurePrefs.GetInt("AsUid", 0) > 0; callback(null, mIsInited); } #else mIsInited = false; mIsLoggedIn = false; callback(null, mIsInited); #endif }
private void OnSubmit(string accountId) { #if USE_ACCOUNT_AUTH EB.Debug.Log("OnSubmit: accountId = {0}", accountId); if (string.IsNullOrEmpty(accountId)) { if (mAuthCallback != null) { mAuthCallback("Empty Account Id!", null); mAuthCallback = null; } } else { if (mAuthCallback != null) { mLoggedIn = true; mAccountId = accountId; SecurePrefs.SetString("AccountId", mAccountId); var data = new Hashtable(); data["accountId"] = mAccountId; mAuthCallback(null, data); mAuthCallback = null; } } #endif }
public void Save(string key) { // save fragments as it will be faster //var r = SecurePrefs.SetJSON(key, fragments); //Debug.Log("Save Offline: \n" + r); }
public string GetPlatform() { string lastPlatform = SecurePrefs.GetString("TencentPlatform", null); EB.Debug.Log("GetPlatform: lastPlatform = {0}", lastPlatform); return(lastPlatform); }
public void Load(string key) { var data = SecurePrefs.GetJSON(key); if (data != null && data is Hashtable) { StoreResult((Hashtable)data, true); } }
public void Logout() { if (mLoggedIn) { SecurePrefs.DeleteKey("DeviceLoggedIn"); mLoggedIn = false; mDeviceAuthId = string.Empty; } }
public void Logout() { #if USE_ACCOUNT_AUTH if (mLoggedIn) { mLoggedIn = false; mAccountId = string.Empty; SecurePrefs.DeleteKey("AccountId"); } #endif }
//-------∽-★-∽------∽-★-∽--------∽-★-∽数据操作∽-★-∽--------∽-★-∽------∽-★-∽--------// //-------∽-★-∽------∽-★-∽--------∽-★-∽SETTER∽-★-∽--------∽-★-∽------∽-★-∽--------// /// <summary> /// 设置字符串 /// </summary> /// <param name="key_"></param> /// <param name="value_"></param> public void SetString(string key_, string value_) { if (value_ != null) { key_ = TransKey(key_); SecurePrefs.SetString(key_, value_); } else { DeleteKey(key_); } }
public void Logout() { if (!mIsInited) { return; } if (IsLoggedIn()) { EB.Debug.Log("AsSDKManager.Logout"); mIsLoggedIn = false; SecurePrefs.DeleteKey("AsUid"); pxAsLogout(); } }
public void Init(object initData, System.Action <string, bool> callback) { #if USE_ACCOUNT_AUTH mAccountId = SecurePrefs.GetString("AccountId", mAccountId); if (mLoginUI == null) { mLoginUI = new GameObject("account_auth_ui", typeof(SparxAccountAuthenticator)); mLoginUI.SetActive(false); var comp = mLoginUI.GetComponent <SparxAccountAuthenticator>(); comp.SetInput(mAccountId); comp.OnSubmit += OnSubmit; } callback(null, true); #else callback(null, false); #endif }
public void Init(object initData, System.Action <string, bool> callback) { UserInfoList = new List <UserInfo>(); string userInfos = SecurePrefs.GetString("UserInfoData", ""); EB.Debug.Log("Manhuang:" + userInfos); Hashtable userHashtable = EB.JSON.Parse(userInfos) as Hashtable; if (userHashtable != null && userHashtable.Count > 0) { foreach (DictionaryEntry user in userHashtable) { UserInfoList.Add(new UserInfo() { phone = user.Key.ToString(), password = user.Value.ToString() }); EB.Debug.Log("Manhuang_Login:{" + user.Key.ToString() + "," + user.Value.ToString() + "}"); } } callback(null, true); }
public void Authenticate(bool silent, System.Action <string, object> callback) { if (silent) { if (IsLoggedIn) { callback(null, Johny.HashtablePool.Claim()); return; } else { callback(null, null); return; } } else { System.Action <string, string, string, string> cb = delegate(string phone, string openId, string accessToken, string password) { var data = Johny.HashtablePool.Claim(); Debug.Log("MHAuthenticator callback openId:{0} accessToken:{1}", openId, accessToken); data["openId"] = openId; data["accessToken"] = accessToken; callback(null, data); mLoggedIn = true; UserPhone = phone; SaveAccountData(phone, password); }; string userID = SecurePrefs.GetString("UserID", string.Empty); string userPwd = SecurePrefs.GetString("UserPwd", string.Empty); SparxHub.Instance.Config.LoginConfig.Listener.OnMHLogin(new Hashtable() { { "userID", userID }, { "password", userPwd }, { "callback", cb } }); } }
public void DeletePlatform() { EB.Debug.Log("DeletePlatform"); SecurePrefs.DeleteKey("TencentPlatform"); }
public void DeleteKey(string key_) { key_ = TransKey(key_); SecurePrefs.DeleteKey(key_); }
//-------∽-★-∽------∽-★-∽--------∽-★-∽数据管理∽-★-∽--------∽-★-∽------∽-★-∽--------// public bool HasKey(string key_) { key_ = TransKey(key_); return(SecurePrefs.HasKey(key_)); }
public string GetString(string key_, string defaultValue_ = null) { key_ = TransKey(key_); return(SecurePrefs.GetString(key_, defaultValue_)); }
public int GetInt(string key_, int defaultValue_ = 0) { key_ = TransKey(key_); return(SecurePrefs.GetInt(key_, defaultValue_)); }
//-------∽-★-∽------∽-★-∽--------∽-★-∽GETTER∽-★-∽--------∽-★-∽------∽-★-∽--------// public float GetFloat(string key_, float defaultValue_ = 0) { key_ = TransKey(key_); return(SecurePrefs.GetFloat(key_, defaultValue_)); }
/// <summary> /// 设置浮点型 /// </summary> /// <param name="key_"></param> /// <param name="value_"></param> public void SetFloat(string key_, float value_) { key_ = TransKey(key_); SecurePrefs.SetFloat(key_, value_); }
/// <summary> /// 设置整型 /// </summary> /// <param name="key_"></param> /// <param name="value_"></param> public void SetInt(string key_, int value_) { key_ = TransKey(key_); SecurePrefs.SetInt(key_, value_); }
public void Save(string key) { SecurePrefs.SetJSON(key, ToHashtable()); }
public void Load(string key) { Update(SecurePrefs.GetJSON(key)); }
public void SavePlatform(string platform) { EB.Debug.Log("SavePlatform: platform = {0}", platform); SecurePrefs.SetString("TencentPlatform", platform); }