I am a beginner to Android and got stuck at a problem stating "Firebase permission denied error". Following is my code snippet:
private void searchUser() {
Log.d(Constants.TAG, "GetUser: userId " + mFirebaseUser.getUid()+" mFirebaseUser.getPhoneNumber() " +mFirebaseUser.getPhoneNumber());
if (!TextUtils.isEmpty(mFirebaseUser.getUid())) {
showSnackBar(getString(R.string.fetching_profile_details), false);
Utils.showProgressDialog(mActivity, false);
final FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference userRef = database.getReference(Constants.FIREBASE_USERS);
Query query = userRef.orderByChild(Constants.FIREBASE_USER_PHONE)
.equalTo(mFirebaseUser.getPhoneNumber())
.limitToFirst(1);
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Utils.hideProgressDialog();
if (dataSnapshot != null && dataSnapshot.exists() && dataSnapshot.getChildrenCount() > 0) {
//Found user with same number
//Log.d(Constants.TAG,"dataSnapshot " +dataSnapshot);
for(DataSnapshot childDataSnapshot : dataSnapshot.getChildren()) {
//Log.d(Constants.TAG, "childDataSnapshot " + childDataSnapshot);
mUser = childDataSnapshot.getValue(com.hypertrack.wintry_consumer.models.User.class);
}
if (mUser != null) {
isNewUser = true;
preFillData();
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Utils.hideProgressDialog();
Log.e(Constants.TAG, "onCancelled", databaseError.toException());
showSnackBar("Firebase Error finding User details: " + databaseError.getMessage());
}
});
} else {
showSnackBar("No firebase user available ");
}
}
Following is my cloud firestore rule:-
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
I am getting the following error:
"Firebase Database Error: Permission denied"
Please help with its solution.