@@ -111,15 +111,12 @@ public void onMethodCall(MethodCall call, Result result) {
111111 case "linkWithFacebookCredential" :
112112 handleLinkWithFacebookCredential (call , result );
113113 break ;
114- case "updateEmail" :
115- handleUpdateEmail (call , result );
116- break ;
117- case "updatePassword" :
118- handleUpdatePassword (call , result );
119- break ;
120114 case "updateProfile" :
121115 handleUpdateProfile (call , result );
122116 break ;
117+ case "updateEmail" :
118+ handleUpdateEmail (call , result );
119+ break ;
123120 case "startListeningAuthState" :
124121 handleStartListeningAuthState (call , result );
125122 break ;
@@ -142,7 +139,6 @@ public void onMethodCall(MethodCall call, Result result) {
142139 }
143140
144141 private void handleSignInWithPhoneNumber (MethodCall call , Result result ) {
145- @ SuppressWarnings ("unchecked" )
146142 Map <String , String > arguments = (Map <String , String >) call .arguments ;
147143 String verificationId = arguments .get ("verificationId" );
148144 String smsCode = arguments .get ("smsCode" );
@@ -428,24 +424,6 @@ public void onComplete(@NonNull Task<GetTokenResult> task) {
428424 });
429425 }
430426
431- private void handleUpdateEmail (MethodCall call , final Result result ) {
432- @ SuppressWarnings ("unchecked" )
433- Map <String , String > arguments = (Map <String , String >) call .arguments ;
434- firebaseAuth
435- .getCurrentUser ()
436- .updateEmail (arguments .get ("email" ))
437- .addOnCompleteListener (new TaskVoidCompleteListener (result ));
438- }
439-
440- private void handleUpdatePassword (MethodCall call , final Result result ) {
441- @ SuppressWarnings ("unchecked" )
442- Map <String , String > arguments = (Map <String , String >) call .arguments ;
443- firebaseAuth
444- .getCurrentUser ()
445- .updatePassword (arguments .get ("password" ))
446- .addOnCompleteListener (new TaskVoidCompleteListener (result ));
447- }
448-
449427 private void handleUpdateProfile (MethodCall call , final Result result ) {
450428 @ SuppressWarnings ("unchecked" )
451429 Map <String , String > arguments = (Map <String , String >) call .arguments ;
@@ -461,7 +439,40 @@ private void handleUpdateProfile(MethodCall call, final Result result) {
461439 firebaseAuth
462440 .getCurrentUser ()
463441 .updateProfile (builder .build ())
464- .addOnCompleteListener (new TaskVoidCompleteListener (result ));
442+ .addOnCompleteListener (
443+ new OnCompleteListener <Void >() {
444+ @ Override
445+ public void onComplete (@ NonNull Task <Void > task ) {
446+ if (!task .isSuccessful ()) {
447+ Exception e = task .getException ();
448+ result .error (ERROR_REASON_EXCEPTION , e .getMessage (), null );
449+ } else {
450+ result .success (null );
451+ }
452+ }
453+ });
454+ }
455+
456+ private void handleUpdateEmail (MethodCall call , final Result result ) {
457+ @ SuppressWarnings ("unchecked" )
458+ Map <String , String > arguments = (Map <String , String >) call .arguments ;
459+ String email = arguments .get ("email" );
460+
461+ firebaseAuth
462+ .getCurrentUser ()
463+ .updateEmail (email )
464+ .addOnCompleteListener (
465+ new OnCompleteListener <Void >() {
466+ @ Override
467+ public void onComplete (@ NonNull Task <Void > task ) {
468+ if (!task .isSuccessful ()) {
469+ Exception e = task .getException ();
470+ result .error (ERROR_REASON_EXCEPTION , e .getMessage (), null );
471+ } else {
472+ result .success (null );
473+ }
474+ }
475+ });
465476 }
466477
467478 private void handleStartListeningAuthState (MethodCall call , final Result result ) {
0 commit comments