firebase-react-native-sample icon indicating copy to clipboard operation
firebase-react-native-sample copied to clipboard

Android Working?

Open brianegan opened this issue 7 years ago • 4 comments

Hey there! I've tried Firebase 3.2.0 on Android in my own react native project and I seem to be running into trouble!

I've setup my config, initialized the app, and then tried logging in anonymously and with emailAndPassword like so:

firebaseApp.auth().signInAnonymously()
      .then(function onSignInSuccess() {
        console.log("success", arguments)
      })
      .catch(function onSignInError() {
        console.log("Failure", arguments)
      })

The problem: On iOS, the promise succeeds or fails as expected, whereas on Android the Promise does not. Any ideas on why or why 3.2.0 might not work for Android yet works fine on iOS? Is RN for Android supported?

brianegan avatar Aug 10 '16 08:08 brianegan

@brianegan I am facing the same issue as you.

let connectedRef = firebaseRef.database().ref(".info/connected");
connectedRef.on("value", function(snap) {
  if (snap.val() === true) {
    console.log("connected");
  } else {
    console.log("not connected");
  }
});

This always displays not connected on Android. While it works just fine on iOS. @davideast is this a regression in 3.2?

shilpan avatar Aug 12 '16 03:08 shilpan

@brianegan @davideast I figured out the issue. It seems like the firebase is not compatible with the latest 0.31.0 release of react-native. I used 0.30.0 and it seems to work fine.

shilpan avatar Aug 12 '16 04:08 shilpan

If someone is curious, it seems that scoping is the issue here. For reference look at: https://github.com/wkh237/react-native-fetch-blob/issues/93

shilpan avatar Aug 17 '16 04:08 shilpan

@brianegan @shilpan can I suggest using react-native-firebase - it's a small JS bridge to native side - no fetch used as all the work is done by the official native firebase SDK's for android and IOS.

It's much faster and doesn't reduce the JS frame rate. It also includes storage, crash reporting, analytics and offline capabilities compared to the web SDK.

Salakar avatar Apr 06 '17 09:04 Salakar