我有一段代码可以将我的用户保存在我的数据库中,如下所示:
public void createAccount()
{
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://xxx-xxx.firebaseio.com/");
FirebaseApp.DefaultInstance.SetEditorP12FileName("xxx xxx-dd21907c659a.p12");
FirebaseApp.DefaultInstance.SetEditorServiceAccountEmail("xxx@xxx-xxx.iam.gserviceaccount.com");
FirebaseApp.DefaultInstance.SetEditorP12Password("notasecret");
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
FirebaseDatabase.DefaultInstance.GetReference("users").Child(username.GetComponent<InputField>().text).Child("likes").GetValueAsync().ContinueWith(task =>
{
if (task.IsFaulted)
{
email.GetComponent<InputField>().textComponent.color = Color.red;
}
else if (task.IsCompleted)
{
DataSnapshot snapshot = task.Result;
if (snapshot.Value == null)
{
DataBase.userID = username.GetComponent<InputField>().text;
DataBase.email = email.GetComponent<InputField>().text;
DataBase.password = password.GetComponent<InputField>().text;
DataBase.signedIn = true;
reference.Child("users").Child(DataBase.userID).Child("likes").SetValueAsync(DataBase.followers);
reference.Child("users").Child(DataBase.userID).Child("email").SetValueAsync(DataBase.email);
reference.Child("users").Child(DataBase.userID).Child("password").SetValueAsync(DataBase.password);
SceneManager.LoadScene("game");
}
else
{
username.GetComponent<InputField>().textComponent.color = Color.red;
}
}
});
}
当我在统一使用它时它工作正常但是当我编译它并在我的Android设备上运行它时它不会向数据库发送任何信息。它甚至不会将文本颜色变为红色,这表明任务出现故障....希望你能帮助我解决这个问题。
答案 0 :(得分:1)
从项目方向删除空格,包括名称本身。 尝试使项目中所有目录的名称无空间。