Here\'s my code:
firebase.auth().onAuthStateChanged((user) => {
if (user) {
console.log(\"We are authenticated now!\");
firebase.fires
Sorry I'm late to the party, but I just came across this and thought I'd share my experience. I had the exact same issue, and after months of researching and debugging, it resolved itself when I upgraded to firebase v 5. Here's a link to my SO post and solution. Hope it helps: https://stackoverflow.com/a/51115385/6158840
Please log your UID and confirm it is not null. Then modify the permission rule as -
// Grants a user access to a document matching their Auth user Id
service cloud.firestore {
match /databases/{database}/documents {
// Collection named "users", document named after the userId
match /users/{userId} {
allow read, write: if request.auth.uid == userId;
}
}
}
Seems like a bug - as other high-reputation users experienced it too. I'll update more when we find a fix. If anyone got it working (on react-native through expo) please share.
First check the Stuff on the FIREBSAE Rule Exectuion Simulator,
and secondly your issue sounds like you'r requests are not in Sync, check your rules (if possible) in the Web view , as i tried doing the same and it worked for me
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
I downgraded to Firebase SDK 4.6.2 when I had this problem with latest Firebase JS SDK on Expo.
Also, you have to do this in order for everything to work:
Copy https://gist.githubusercontent.com/mikelehen/444950a35019208f3aaf18d37ab4937c/raw/85ac4cb3108d92163cb8f04fbffffdcc88d4081aab/index.js
over your node_modules/@firebase/webchannel-wrapper/dist/index.js
Without this, you'll get nothing from your collections.
Hope this helps.
I diffed the requests coming from the same code running in the browser vs expo. One difference I noticed was missing Origin header. I patched the xhr and it works for my uses. I'm not sure if this is a bug or expected behavior. I've asked on slack/firestore and discord/react-native but didn't get much input.
const xhrInterceptor = require('react-native/Libraries/Network/XHRInterceptor')
xhrInterceptor.setSendCallback((data, xhr) => {
if (xhr._method === 'POST') {
// WHATWG specifies opaque origin as anything other than a uri tuple. It serializes to the string 'null'.
// https://html.spec.whatwg.org/multipage/origin.html
xhr.setRequestHeader('Origin', 'null')
}
})
xhrInterceptor.enableInterception()