invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

'key' property is missing from database reference - Crash with GeoFire #2818

Closed crocodile closed 4 years ago

crocodile commented 5 years ago

Issue

I am trying to use 'react-native-firebase' with the 'geofire' library as follows:

import database, {firebase} from '@react-native-firebase/database';

let ref = database().ref('somepath')
let geoFire = new GeoFire(ref);
var geoQuery = geoFire.query({
        center: [51.296704, -0.8553124],
        radius: 5,
      });
...

... also tried by referencing firebase directly:

let ref = firebase.database().ref('somepath')
...

Expected: No error

Actual:

This does not happen if I use the 'firebase' package directly (i.e. not using 'react-native-firebase'), but that's not an easy option for me as I am already using this library for authentication and other functions.

package.json :

  "dependencies": {
    "@react-native-firebase/app": "^6.0.3",
    "@react-native-firebase/auth": "^6.0.3",
    "@react-native-firebase/database": "^6.0.3",
    "@react-native-firebase/firestore": "^6.0.3",
    "@react-native-firebase/messaging": "^6.0.3",
    "react": "^16.9.0",
    "firebase": "^7.2.3",
    "react-native": "0.61.2",
    "@types/firebase": "^3.2.1",
    "geofire": "^5.0.1",
    ...

Project Files

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`


Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Ehesp commented 5 years ago

Can't say I've ever used GeoFire, but the key is/should be there: https://github.com/invertase/react-native-firebase/blob/4709781fb0f5b7a06e1b48d37ebb4363736bf79b/packages/app/lib/common/ReferenceBase.js#L40

My guess would be it's not being handled the same, maybe internally passing the class along and losing the context/serialising etc?

stale[bot] commented 4 years ago

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

ziyaddin commented 4 years ago

@crocodile have you found solution for this issue?

danielcolgan commented 4 years ago

@ziyaddin @crocodile looking for an answer as well

ziyaddin commented 4 years ago

@danielcolgan I came up with temporary solution:

import { GeoFire, GeoFireTypes } from 'geofire';
import firebase from '@react-native-firebase/app';

const firebaseDb = firebase.database();
const tempRef: any = firebaseDb.ref();
tempRef.key = null;
const firebaseRef: GeoFireTypes.firebase.Reference = tempRef;
const geofire = new GeoFire(this.firebaseRef);

Basically, firebaseRef = tempRef + 'key' property.

crocodile commented 4 years ago

@danielcolgan @ziyaddin I no longer have this issue after upgrading to 6.4.0.

ziyaddin commented 4 years ago

@crocodile thanks for informing.