/// <summary> /// Gets the device identifier and updates the static variables /// </summary> /// <returns><c>true</c>, if device identifier was obtained, <c>false</c> otherwise.</returns> static bool GetDeviceId() { if (PlayFabLoginCalls.CheckForSupportedMobilePlatform()) { #if UNITY_ANDROID //http://answers.unity3d.com/questions/430630/how-can-i-get-android-id-.html AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject objActivity = clsUnity.GetStatic <AndroidJavaObject>("currentActivity"); AndroidJavaObject objResolver = objActivity.Call <AndroidJavaObject>("getContentResolver"); AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure"); android_id = clsSecure.CallStatic <string>("getString", objResolver, "android_id"); #endif #if UNITY_IPHONE ios_id = UnityEngine.iOS.Device.vendorIdentifier; #endif return(true); } else { if (OnPlayFabError != null) { OnPlayFabError("Must be using android or ios platforms to use deveice id.", PlayFabAPIMethods.Generic); } return(false); } }
/// <summary> /// Parses Unity PlayerPrefs for saved login information. See the gitHub readme for more information /// </summary> /// <returns> used for coroutine yielding </returns> IEnumerator ReadLoginDataRecord() { this.status.text = "Finding previous logins..."; if (PlayerPrefs.HasKey("loginMethodUsed")) { this.status.text = "Previous login found... "; string raw = PlayerPrefs.GetString("loginMethodUsed"); PlayFabLoginCalls.LoginPathways method = (PlayFabLoginCalls.LoginPathways)Enum.Parse(typeof(PlayFabLoginCalls.LoginPathways), raw); Debug.Log(method.ToString()); switch (method) { case PlayFabLoginCalls.LoginPathways.pf_username: if (PlayerPrefs.HasKey("accountInfo")) { this.accountInfo = JsonConvert.DeserializeObject <UserAccountInfo>(PlayerPrefs.GetString("accountInfo")); this.createNewAccount = false; PrompForPassword(); this.details.text = string.Format("PlayFab Username: {0} found...", this.accountInfo.Username); this.instructions.text = "Enter password to continue, or change accounts manually by clicking below."; this.loginPathToUse = PlayFabLoginCalls.LoginPathways.pf_username; } break; case PlayFabLoginCalls.LoginPathways.pf_email: if (PlayerPrefs.HasKey("accountInfo")) { this.accountInfo = JsonConvert.DeserializeObject <UserAccountInfo>(PlayerPrefs.GetString("accountInfo")); this.createNewAccount = false; PrompForPassword(); this.details.text = string.Format("Email: {0} found...", this.accountInfo.PrivateInfo.Email); this.instructions.text = "Enter password to continue, or change accounts manually by clicking below."; this.loginPathToUse = PlayFabLoginCalls.LoginPathways.pf_email; } break; case PlayFabLoginCalls.LoginPathways.deviceId: EnableCountdown(); this.createNewAccount = false; this.details.text = "Device Id, click below to manually change accounts"; this.loginPathToUse = PlayFabLoginCalls.LoginPathways.deviceId; break; case PlayFabLoginCalls.LoginPathways.facebook: EnableCountdown(); this.createNewAccount = false; this.details.text = "Facebook, click below to manually change accounts"; this.loginPathToUse = PlayFabLoginCalls.LoginPathways.facebook; break; case PlayFabLoginCalls.LoginPathways.gameCenter: EnableCountdown(); this.createNewAccount = false; this.details.text = "GameCenter, click below to manually change accounts"; this.loginPathToUse = PlayFabLoginCalls.LoginPathways.gameCenter; break; case PlayFabLoginCalls.LoginPathways.googlePlus: EnableCountdown(); this.createNewAccount = false; this.details.text = "Google+, click below to manually change accounts"; this.loginPathToUse = PlayFabLoginCalls.LoginPathways.googlePlus; break; case PlayFabLoginCalls.LoginPathways.steam: EnableCountdown(); this.createNewAccount = false; this.details.text = "Steam, click below to manually change accounts"; this.loginPathToUse = PlayFabLoginCalls.LoginPathways.steam; break; default: AutoNewAccount(); break; } } else { if (PlayFabLoginCalls.CheckForSupportedMobilePlatform()) { AutoNewAccount(); } else { PlayFabLoginCalls.TestDeviceIdHasAccount(); yield return(new WaitForSeconds(.333f)); authController.activeState = AuthenticationController.LoginStates.Manual; } } }