Hello
I am unsure what happened - no change to my code and i started having issues with creating accounts - my existing user is working fine.
there are 3 subsequent errors i get after hitting the register button which calls the AddAccountAndPassword();
'unknownerror'
'silent authentication by device failed'
and i get an object null refernece error at like 294 which is :::
Username = !string.IsNullOrEmpty(Username) ? Username : result.PlayFabId, //Because it is required & Unique and not supplied by User.
private void AddAccountAndPassword() { //Any time we attempt to register a player, first silently authenticate the player. //This will retain the players True Origination (Android, iOS, Desktop) SilentlyAuthenticate((result) => { if(result == null) { //something went wrong with Silent Authentication, Check the debug console. OnPlayFabError.Invoke(new PlayFabError() { Error = PlayFabErrorCode.UnknownError, ErrorMessage = "Silent Authentication by Device failed" }); } //Note: If silent auth is success, which is should always be and the following //below code fails because of some error returned by the server ( like invalid email or bad password ) //this is okay, because the next attempt will still use the same silent account that was already created. //Now add our username & password. PlayFabClientAPI.AddUsernamePassword(new AddUsernamePasswordRequest() { Username = !string.IsNullOrEmpty(Username) ? Username : result.PlayFabId, //Because it is required & Unique and not supplied by User. Email = Email, Password = Password, }, (addResult) => { if (OnLoginSuccess != null) { //Store identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; //If they opted to be remembered on next login. if (RememberMe) { //Generate a new Guid RememberMeId = Guid.NewGuid().ToString(); //Fire and forget, but link the custom ID to this PlayFab Account. PlayFabClientAPI.LinkCustomID(new LinkCustomIDRequest() { CustomId = RememberMeId, ForceLink = ForceLink }, null, null); } //Override the auth type to ensure next login is using this auth type. AuthType = Authtypes.EmailAndPassword; //Report login result back to subscriber. OnLoginSuccess.Invoke(result); } }, (error) => { if (OnPlayFabError != null) { //Report error result back to subscriber OnPlayFabError.Invoke(error); } }); }); }
private void SilentlyAuthenticate(System.Action<LoginResult> callback = null) { #if UNITY_ANDROID && !UNITY_EDITOR //Get the device id from native android AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject>("currentActivity"); AndroidJavaObject contentResolver = currentActivity.Call<AndroidJavaObject>("getContentResolver"); AndroidJavaClass secure = new AndroidJavaClass("android.provider.Settings$Secure"); string deviceId = secure.CallStatic<string>("getString", contentResolver, "android_id"); //Login with the android device ID PlayFabClientAPI.LoginWithAndroidDeviceID(new LoginWithAndroidDeviceIDRequest() { TitleId = PlayFabSettings.TitleId, AndroidDevice = SystemInfo.deviceModel, OS = SystemInfo.operatingSystem, AndroidDeviceId = deviceId, CreateAccount = true, InfoRequestParameters = InfoRequestParams }, (result) => { //Store Identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; //check if we want to get this callback directly or send to event subscribers. if (callback == null && OnLoginSuccess != null) { //report login result back to the subscriber OnLoginSuccess.Invoke(result); }else if (callback != null) { //report login result back to the caller callback.Invoke(result); } }, (error) => { //report errro back to the subscriber if(callback == null && OnPlayFabError != null){ OnPlayFabError.Invoke(error); }else{ //make sure the loop completes, callback with null callback.Invoke(null); //Output what went wrong to the console. Debug.LogError(error.GenerateErrorReport()); } }); #elif UNITY_IPHONE || UNITY_IOS && !UNITY_EDITOR PlayFabClientAPI.LoginWithIOSDeviceID(new LoginWithIOSDeviceIDRequest() { TitleId = PlayFabSettings.TitleId, DeviceModel = SystemInfo.deviceModel, OS = SystemInfo.operatingSystem, DeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true, InfoRequestParameters = InfoRequestParams }, (result) => { //Store Identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; //check if we want to get this callback directly or send to event subscribers. if (callback == null && OnLoginSuccess != null) { //report login result back to the subscriber OnLoginSuccess.Invoke(result); }else if (callback != null) { //report login result back to the caller callback.Invoke(result); } }, (error) => { //report errro back to the subscriber if(callback == null && OnPlayFabError != null){ OnPlayFabError.Invoke(error); }else{ //make sure the loop completes, callback with null callback.Invoke(null); //Output what went wrong to the console. Debug.LogError(error.GenerateErrorReport()); } }); #else PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest() { TitleId = PlayFabSettings.TitleId, CustomId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true, InfoRequestParameters = InfoRequestParams }, (result) => { //Store Identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; //check if we want to get this callback directly or send to event subscribers. if (callback == null && OnLoginSuccess != null) { //report login result back to the subscriber OnLoginSuccess.Invoke(result); } else if (callback != null) { //report login result back to the caller callback.Invoke(result); } }, (error) => { //report errro back to the subscriber if (callback == null && OnPlayFabError != null) { OnPlayFabError.Invoke(error); } else { //make sure the loop completes, callback with null callback.Invoke(null); //Output what went wrong to the console. Debug.LogError(error.GenerateErrorReport()); } }); #endif }
debug
PlayFab.Internal.PlayFabUnityHttp:OnError(String, CallRequestContainer) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:268) PlayFab.Internal.<Post>c__Iterator1:MoveNext() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:153) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
I am not getting a result from this call
PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest() { TitleId = PlayFabSettings.TitleId, CustomId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true, InfoRequestParameters = InfoRequestParams }, (result) => {
any clue what i can try? - when i login (not register a user) the api calls work no problem login . call character data rtitle data etc and so on