Open When - An Expo + Firebase Firestore Platform

Ok, well, thanks for the quick response.

I think I’ll eject from expo and try RN FB:

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: firebase - In react native app (through Expo) using firestore permissions - request.auth is always null - Stack Overflow

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.

Hi, did you find a solution for this problem?

Thanks!

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

1 Like

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.

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.

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?

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 );
		});
  }
1 Like

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

2 Likes

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

1 Like

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

require('firebase/firestore');

or

import '@firebase/firestore';

I’m having the same issue as well

TypeError: _firebase2.default.firestore is not a function. (In ‘_firebase2.default.firestore()’, ‘_firebase2.default.firestore’ is undefined)
even when using

require('firebase/firestore');

or

import '@firebase/firestore';

Thanks for the help

2 Likes

Hey did you get the solution for that even I am getting the same error.

Error: firebase.firestore is not a function. (In ‘firebase.firestore()’, ‘firebase.firestore’ is undefined)

P.S.: I have imported;
import * as firebase from ‘firebase’;
import ‘firebase/firestore’;

It works fine when I use firebase.database(), but I need to use firestore… all my data is in firestore could you help?

Hello,
I solved it by using

import * as firebase from 'firebase/app';
import 'firebase/firestore';

I think how you import depends on your firebase version.

So what is the version of both the imports

5.8.1

Did you find a solution for this?

Is firestore working with expo and if yes with which firebase version? Because it’s not working with 7.14

It doesn’t work in 7.9.0 firebase version. I have tried all the solutions given above but still get firestore is not a function error.