I'm using Firebase version 9.6.11 in a Expo project. The Authentication works perfect, but when I use Firebase Firestore a get the error "Missing or insufficient permissions". I changed the rules of firebase to:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
In a project with React.js it's working, but in React Native with Expo (version 46.0.9) not working. Anyone knows how to solve it?
My config in Expo is:
import AsyncStorage from '@react-native-async-storage/async-storage';
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import { API_KEY, AUTH_DOMAIN, PROJECT_ID, STORAGE_BUCKET, MESSAGING_SENDER_ID, APP_ID } from "@env"
import {
initializeAuth,
getReactNativePersistence
} from 'firebase/auth/react-native';
const firebaseConfig = {
apiKey: API_KEY,
authDomain: AUTH_DOMAIN,
projectId: PROJECT_ID,
storageBucket: STORAGE_BUCKET,
messagingSenderId: MESSAGING_SENDER_ID,
appId: APP_ID
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
// initialize auth
const auth = initializeAuth(app, {
persistence: getReactNativePersistence(AsyncStorage)
});
// initialize firestore
const db = getFirestore(app);
export { auth, db };