Open When - An Expo + Firebase Firestore Platform


#21

Ok, well, thanks for the quick response.

I think I’ll eject from expo and try RN FB:
https://rnfirebase.io/


#22

Thanks for that. Did you try also authenticating users and having firestore permissions to read/write only to signed in users? It seems like the request sent from my client always has request.auth null even though user is signed in. Here’s my full question with code on SO: https://stackoverflow.com/q/47859246/1806956


#23

This is the issue that is tripping us all up:

https://github.com/firebase/firebase-js-sdk/issues/283#issuecomment-345815579

Various interim solutions are discussed. The specific one I linked to is the first I tried and it worked for me.


#24

Hi, did you find a solution for this problem?

Thanks!


#25

Hi guys,

Those who are testing on android but can’t get firestore to work, I’ve been there too. Here’s the stack overflow question I asked and got a working fix. There’s a deeper insight on the question, if you’re facing the problem.

But now I’m having a different problem, the one that @spettit faced. When I’m trying to enable offline persistence it won’t allow me. I get the following error printed on console:

“Error enabling offline storage. Falling back to storage disabled: FirebaseError: [code=unimplemented]: This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.”

Does anyone know any fix to it?

Thanks in advance


#26

In the end I built my app outside expo using react-native-firebase which implements offline persistence out of the box. I’ve not tried it on android but on iOS react-native-firebase does everything I want it to do.


#27

I’ve used this solution to build my firestore app. However, recently I faced security rules are not working properly on this one. Anyone having same issue?

allow read, write: if request.auth != null;

Always failed getting document with request.auth != null option

releated issue is here.


#28

Great to hear that you had such a positive experience.

I’m keen to migrate my app away from Firebase Realtime DB to Firestore, I had a quick crack at it but it’s mostly a rewrite of my actions and cloud functions :frowning: , and it didn’t seem like Firestore had solid support for React Native at the time.

Do you have an Expo link for iOS?


#29

Thanks… it’s working (Y)

import firebase from "firebase"
require("firebase/firestore");

// Initialize Firebase
var config = {
  apiKey: "XXXX",
  authDomain: "XXX.firebaseapp.com",
  databaseURL: "https://XXXX.firebaseio.com",
  projectId: "XXX",
  storageBucket: "XXX.appspot.com",
  messagingSenderId: "XXXX"
};
firebase.initializeApp(config);

var db = firebase.firestore();

.
.
.
.
  componentDidMount(){
    var db = firebase.firestore();
    var docRef = db.collection("users");
    const output = {};

    docRef.limit(50)
		.get()
		.then(querySnapshot => {
			querySnapshot.docs.map(function (documentSnapshot) {
				return (output[documentSnapshot.id] = documentSnapshot.data());
			});
      this.setState({dataSource: Object.entries(output)}) ;
      console.log("datasource:", this.state.dataSource );
		});
  }

#30

Are you getting a massive object as well? Cant work out if I’m doing something wrong or if thats the actual results


#32

Does it work yet? I am not able to make it work. Please help me out.

It gives the error - TypeError: _firebase2.default.firestore is not a function. (In ‘_firebase2.default.firestore()’, ‘_firebase2.default.firestore’ is undefined)

Thanks


#33

Have you imported firebase/firestore where you are calling firebase.firestore()
Declare

require('firebase/firestore');

or

import '@firebase/firestore';