multithreading - Firebase Database Tasks do not execute after signing with Firebase Auth in Unity -
so set firebase authentication (with email , password) described in documentation. have account, can sign in , works fine long do. set realtime database. can write , read , works fine long do. except if want use 2 things together. if sign in can not write database. nothing happens. delegate passed argument continuewith
method not execute. can not debug way.
here do:
void awake(){ firebaseapp.defaultinstance.seteditordatabaseurl( "https://****.firebaseio.com/" ); firebasedatabase db = firebasedatabase.getinstance( "https://****.firebaseio.com/" ); auth = firebase.auth.firebaseauth.getauth( firebaseapp.defaultinstance ); dbref = db.rootreference; }
this setup, simple testing purposes only. avoid other issues changed read , write rules true
in firebase database.
i copied log in function docs.
public void login( string email, string password ) { print( "logging in" ); auth.signinwithemailandpasswordasync( email, password ).continuewith( task => { if ( task.iscanceled ) { debug.logerror( "signinwithemailandpasswordasync canceled." ); return; } if ( task.isfaulted ) { debug.logerror( "signinwithemailandpasswordasync encountered error: " + task.exception ); return; } currentuser = task.result; debug.logformat( "user signed in successfully: {0} ({1})", currentuser.displayname, currentuser.userid ); } ); }
if try log in "user signed in successfully..." message.
i have simple test function:
public void test() { dbref.push().setvalueasync( system.datetime.now.tostring() ).continuewith( postprocesssave ); } private void postprocesssave( system.threading.tasks.task task ) { if ( !task.iscompleted ) debug.log( task.exception ); else { debug.log( "boat saved" ); } }
when call test
function executes , can see "boat saved" message. can see new entry in database.
when call login
function (it works), wait couple of seconds , call test
method nothing happens. not single error, not log. nothing crashes , application runs. there no entry in database.
i hope messed set up. can me? thanks.
Comments
Post a Comment