Hello, over the last few days I made a login script that works off of a Firebase database. It essentially does what you would expect, signs new users up and logs them in when they put their credentials in. There is a decent amount of error handling, and testing every case in Unity (on PC) works just fine. All the errors and success messages come up like they should. Mobile though, is different.
For conciseness, I will attach the login method, since it is the strangest in terms of what it does, and itās shorter than the signup method(s).
public void LoginButton() { //onclick listener
Login();
}
private async void Login() {
string email = loginEmail.text.ToLower(); //fields from input text
string password = loginPass.text.ToLower();
if (await CheckIfEmailAndPasswordMatch(email, password)) { //wait for the method to finish
loginError.text = "You were logged in! This would normally trigger the app loading.";
} else {
return; //can only return if the return type is 'void' or 'Task<T>'
}
}
private async Task<bool> CheckIfEmailAndPasswordMatch(string email, string password) {
DataSnapshot snap = await userAccountDB.Child("Users").Child(email.Remove(email.IndexOf("@"))).Child("email").GetValueAsync();
if ((String)snap.Value == email) {
DataSnapshot snap2 = await userAccountDB.Child("Users").Child(email.Remove(email.IndexOf("@"))).Child("password").GetValueAsync();
if ((String)snap2.Value == password) {
return true;
} else {
ErrorReporter("incorrectEmailOrPass");
return false;
}
} else {
ErrorReporter("incorrectEmailOrPass");
return false;
}
}
Again, everything works perfectly on desktop editor runtime. On mobile, putting in an incorrect username or password will tell you theyāre incorrect, but once correct ones are inputted it doesnāt give the login message. Does anyone know why this behavior is occurring? Can Android not handle async/await or Tasks? I am lost, so any help is greatly appreciated! Thank you!