- Home /
Question by
AhmedSabry19 · Aug 27, 2018 at 08:55 AM ·
c#databasegoogle playlogin
Firebase Saves and retrieves data perfectly on editor, but does't work on mobiles
I started using Firebase in my app, I followed the setup steps correctly. I made a registration and login pages, in addition to add fields to the database, however, everything works fine in the editor, but when I build for android, nothing happens.
Here is the code of initializing the Firebase
private void Awake()
{
InitGPServices();
}
private void InitGPServices()
{
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
{
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
Debug.Log("Firebase dependencies: " + dependencyStatus);
InitializeFirebase();
}
else
{
Debug.LogError(System.String.Format("Could not resolve all Firebase dependencies: {0}", dependencyStatus));
}
});
}
protected virtual void InitializeFirebase()
{
FirebaseApp app = FirebaseApp.DefaultInstance;
app.SetEditorDatabaseUrl(databaseUrl);
app.Options.DatabaseUrl = app.Options.DatabaseUrl;
}
Here is the code for login
public void Login()
{
authentication.SignInWithEmailAndPasswordAsync(emailInputL.text, passwordInputL.text).ContinueWith(task =>
{
if (task.IsCanceled)
{
Debug.LogError("SignInWithEmailAndPasswordAsync canceled.");
return;
}
if (task.IsFaulted)
{
Debug.LogError("SignInWithEmailAndPasswordAsync error: " + task.Exception);
if (task.Exception.InnerExceptions.Count > 0)
{
Debug.LogError(task.Exception.InnerExceptions[0].Message);
}
return;
}
FirebaseUser user = task.Result;
if (!user.IsEmailVerified)
{
Debug.LogFormat("Failed to login, email is not verified");
return;
}
Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
SceneManager.LoadScene(1);
});
}
and this is the code of app rules in the console
{
"rules": {
".read": true,
".write": true
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
get_version can only be called from the main thread. 0 Answers
PHP Login not returning anything 1 Answer
mmo/server question.. 2 Answers