react-native-firebase
react-native-firebase copied to clipboard
firebase repo is out of date
btw, this breaks the instructions here I think: https://www.freecodecamp.org/news/react-native-firebase-tutorial/
the version of firebase ends up being wrong (8, vs 7). There is a warning when running npm run android, but it's easy to miss. Things all seem fine, except you get errors once you get to the end of step 6 in your tutorial. I finally cloned your repo down and copied your version of firebase. I also ran your project repo, then tried running mine, but I had to close down expo and restart it on my phone to get it to work right. But that seemed to be what fixed it...
May want to update stuff.
oh, forgot I had changed something else trying to get this to work as well (though it either wasn't enough on its own, or was delayed in becoming live)...
At https://console.firebase.google.com/u/2/project/react-native-firebase/firestore/rules I changed permissions to
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
following this stack overflow answer, even though that is bad advice and is only useful for debugging. By default, it says allow read, write: if false;, but the app fails with a permission error when trying to log in with it like that.
When I change it back to its default, it stops working again, so either the version change didn't matter, or it's a separate additional problem; either way, I don't understand the source of this issue and what's going on. The credentials in this repo work, but I can't see what settings are enabled or what is different causing this.
Probably the next thing I'll try will be swapping in my credentials to this cloned repo instead of the one I've put together following the guide, seeing if it's really just some client side code causing the issue, but nothing stands out as different looking.
now changing it back to true is getting me 'user does not exist anymore' (but it is visible in firebase). I recall previously I had dealt with an error that seemed like it wanted me to create firestore space, so I had done that. Now I wonder if it's just looking in the wrong place?
Just, frustrating. Following this guide has not gone smoothly, and the guide mostly is a 'copy and paste' guide without much explanation. I do appreciate what is explained, but... I don't feel like I could just build my own project from scratch after following it, other than to just go follow some verbatim steps, nor do I really know how to expand on this project easily.
Just going to go ahead and keep a little log of my experience here since I'm this far in.
Just noticed that I have a registered user in the cloud firestore... it's the third user I added, and I'm confused about exactly what/when was running at this point because I thought this was when I was using the cloned repo (maybe expo didn't close correct or mixed something up, no idea at this point), but basically the user I added that time is there, while I have three users (two I had added before I cloned your repo down, and the one I added after) visible in the 'authentication' tab.
So, it seems like the user needs to be added as an entity to firestore, but also visible in authentication...? And that wasn't done the first times I tried to register users for some reason...?
Anyways, now trying to login with user 3 does work--again, though, only if I have the unacceptable permissions 'true' I found outside of the guide. Otherwise I get "FirebaseError: Missing or insufficient permissions."
I've now found a rule that seems better, but is still not recommended (and again, this isn't discussed in the guide at all, so... fun times), but seems to at least be correct enough to require authentication:
// Allow read/write access on all documents to any user signed in to the application
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
Supposedly this allows any authenticated user to modify any/all data, though. Perhaps a detailed solution here is out of the scope of this guide, not sure, but certainly at least a basic solution that allows the app to work? Did I miss it somewhere? Ideally, since this is for authorized users to modify something, you'd think we'd get info on completing that process.
I'll be honest, authentication isn't even important to me, I just wanted a basic react native + firebase guide, and this auth flow seems more complex than it's worth. I could do with a basic start that is just 'install = user' or something. But if there's going to be authentication instructions, I'm feeling like it's taking away from the guide more than adding as-is.
I think my impression is that this guide is likely more about firebase with react native, but isn't about teaching the follower anything about react native itself. It's just incidental that one is made from scratch for a clean slate. Which is fine, just needs to be clarified--I'm new to both techs. There was also friction connecting my android phone and seeing it there for the first time on linux (needing to add my user to a group, discovered by following a url in a semi-cryptic error message to docs and digging around...).