-
Notifications
You must be signed in to change notification settings - Fork 442
Description
Please fill in the following fields:
Unity editor version: 2019.4.6.f
Firebase Unity SDK version: 6.15.2
Source you installed the SDK (.unitypackage or Unity Package Manager): .unitypackage
Firebase plugins in use (Auth, Database, etc.): Realtime Database
Additional SDKs you are using (Facebook, AdMob, etc.): None
Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac
Platform you are targeting (iOS, Android, and/or desktop): Android
Scripting Runtime (Mono, and/or IL2CPP): IL2CPP
Please describe the issue here:
(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)
I am succesfully retrieveing data from the database. However, when I try to set an int value in the PlayerPrefs, the script 'stops' and silently fails without returning any errors.
This is the code I am using, I am calling this method with a button:
public void RetrieveCodes()
{
_codeFromUser = _codeInputField.text;
FirebaseDatabase.DefaultInstance.GetReference("SH_TT").GetValueAsync().ContinueWith(retrieveTask => {
if (retrieveTask.IsFaulted)
{
Debug.Log("No snapshot");
// Handle the error...
}
else if (retrieveTask.IsCompleted)
{
DataSnapshot snapshot = retrieveTask.Result;
foreach (DataSnapshot ds in snapshot.Children)
{
Debug.Log(ds.ChildrenCount);
_currentOrder = new Order(ds.Key, ds.Child("Date").Value.ToString(),ds.Child("Email").Value.ToString(), ds.Child("OrderID").Value.ToString(), ds.Child("Redeemed").Value.ToString());
_ordersList.Add(_currentOrder);
Debug.Log($"_Coderedeemed:= {ds.Key}");
Debug.Log($"_Coderedeemed:= {_currentOrder.OrderID}");
}
//RETRIEVEAL FINISHED
//DO STUFF
foreach(Order o in _ordersList)
{
if (o.OrderID == _codeFromUser)
{
if (o.Redeemed == "N")
{
Debug.Log($"Event Date: {o.Date}");
reference.Child("SH_TT").Child(o.OrderKey).Child("Redeemed").SetValueAsync("Y");
Debug.Log("FOUND TICKET"); //THIS IS THE LAST EXECUTED INSTRUCTION, NOTHING AFTER THIS HAPPENS
PlayerPrefs.SetInt("HasRedeemedShow", 1);
PlayerPrefs.Save();
Debug.Log("SAVED PLAYER");
}
else
{
Debug.Log("Ticket Has Already Been redeemed!!!");
}
}
}
}
});
}
The last line which is executed is Debug.Log("FOUND TICKET");
, nothing is executed after that. However, if I remove the lines PlayerPrefs.SetInt("HasRedeemedShow", 1);
and PlayerPrefs.Save();
then the line Debug.Log("SAVED PLAYER");
is executed.
No errors appear in the Console. I don't understand what is going on! Any help would be appreciated!
Please answer the following, if applicable:
Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
N/A
What's the issue repro rate? (eg 100%, 1/5 etc)
100%