I am using firebase phone Authentication . When a user creates a account using phone number and next time he creates account with same phone number Than I want to show a m
I have done this into my project and it is working perfectly, you can use this, you can use your phone number instead of "deviceId".
mFirebaseDatabaseRefrence.orderByChild("deviceId").equalTo(deviceId).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.getValue() != null) {
Log.d(TAG, "Datasnap Shots: " + dataSnapshot.getValue());
/* if alredy exist and check for first time, second time isExist=true*/
if (!isExist) {
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
UserbasicInfo user = userSnapshot.getValue(UserbasicInfo.class);
Toast.makeText(UserInfoActivity.this, "User already exist...!", Toast.LENGTH_SHORT).show();
}
}
isExist = true;
} else {
isExist = false;
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
/*if not exist add data to firebase*/
Runnable runnable = new Runnable() {
@Override
public void run() {
Log.d(TAG, "isExist: " + isExist);
if (!isExist) {
addDataToDB(false);
} else {
addDataToDB(true);
}
}
};
new Handler().postDelayed(runnable, 5000);