I have two way method for signing-in, one is normal Google sign-in and other is Anonymous Sign-in. In my google sign-in there is no problem and everything works fine even the user's credentials are also coming great including name, email and firebase id. Now the problem is that when I link my anonymous account to the google id using firebase, it is also working fine but at the time of getting credentials all I'm getting is null when getDisplayName() is called.
NOTE: I'm getting the firebase id and email correctly but the name is coming null.
This is my log output here :
11-15 12:58:26.712 21983-21983/in.pinelane.myhovi E/userName: null
11-15 12:58:26.712 21983-21983/in.pinelane.myhovi E/userEmail: xyz@gmail.com
Since my code is working fine but still no luck, code goes like this :
private void linkGuestWithCredential(AuthCredential credentials) {
firebaseAuth.getCurrentUser().linkWithCredential(credentials)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if( task.isSuccessful()){
mProgress.dismiss();
Log.d(TAG, "linkWithCredential:success");
FirebaseUser permanentUser = task.getResult().getUser();
callAnonymousUpdateApi(permanentUser);
Intent signIntent = new Intent(LoginActivity.this, MainActivity.class);
signIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(signIntent);
Toast.makeText(LoginActivity.this, "Welcome to MyHovi!", Toast.LENGTH_LONG)
.show();
finish();
overridePendingTransition(R.anim.right_enter, R.anim.left_exit);
}else{
mProgress.dismiss();
Log.e(TAG, "linkWithCredential:failure", task.getException());
Toast.makeText(getApplicationContext(), "Sign-in failed", Toast.LENGTH_SHORT)
.show();
}
}
});
In the callAnonymousUpdateApi(permanentUSer) I'm actually getting the credentials :
private void callAnonymousUpdateApi(FirebaseUser permanentUser) {
final String name = permanentUser.getDisplayName();
final String email = permanentUser.getEmail();
final String firebaseId = permanentUser.getUid();
RequestParams params = new RequestParams();
params.add("user_id", userId);
params.add("name", name);
params.add("email", email);
params.add("firebase_id", firebaseId);
params.add("user_complete", "true");
}
What I have tried so far is :
Changing
FirebseUser permanentUSer = task.getResult().getUser();
toFirebseUser permanentUSer = FirebaseAuth.getInstance().getCurrentUser();
Tried the same thing in different way that is in the callAnonymousUpdateApi(FirebaseUser permanentUser) what I've done is trying the to get the name as
final String name = FirebaseAuth.getInstance().getCurrentUser().getDisplayName();
but still no luck, any help would be highly appreciated. Thanks