I'm using firebase ui in my app for login. everything works fine when i run it in debug mode - no errors at all. I'm running it through my cellphone and it works fine!
My problem starts when i upload my app to play store. When a user try to log in with facebook it tells the user that the hash key does not match to any stored hashes. I checked few times in Facebook Developers and in my Android Studio and its the same hash key.
I also have "Developer error" when i try to log in with Google. I have no idea why...
And also Error login with "Email and password" - the user enter his email and password and nothing happens. Its just stay on the same activity.
I'm not sure what should i do, should i create release SHA-1? or its something else that im missing here.
Here is my login code
public void startSignIn(){
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER)
.setPermissions(Arrays.asList(Scopes.PROFILE,Scopes.EMAIL)).build(),
new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build());
Intent intent = AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers).build();
startActivityForResult(intent,RC_SIGN_IN);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == RC_SIGN_IN){
IdpResponse idpResponse = IdpResponse.fromResultIntent(data);
if(idpResponse != null && resultCode == RESULT_OK){
currentUser = FirebaseAuth.getInstance().getCurrentUser();
//check if the user is exists by userUID. if he is, it jumps to main activity
refToUsers.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.hasChild(currentUser.getUid())){
Intent mainActivity = new Intent(getApplicationContext(), MainActivity.class);
mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(mainActivity);
}else{
//if the user is not exists it will move to register activity
Intent registerActivity = new Intent(getApplicationContext(), RegisterActivity.class);
registerActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(registerActivity);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.d(TAG,databaseError.getMessage());
}
});
}else if (idpResponse.getErrorCode() == ErrorCodes.NO_NETWORK) {
errorToast("No internet connection");
}else if (idpResponse.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
errorToast("Unknown Error");
}
}
Simple code but for some reason not working...