How to use the react-native-firebase.database function in react-native-firebase

To help you get started, we’ve selected a few react-native-firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aryaminus / RN-firechat / app / components / Backend.js View on Github external
loadMessages(callback) {
    this.messagesRef = firebase.database().ref("messages");
    this.messagesRef.off();
    const onReceive = data => {
      const message = data.val();
      callback({
        _id: data.key,
        text: message.text,
        createdAt: new Date(message.createdAt),
        user: {
          _id: message.user._id,
          name: message.user.name
        }
      });
    };
    this.messagesRef.limitToLast(20).on("child_added", onReceive);
  }
  // send the message to the Backend
github AOSSIE-Org / CarbonFootprint-Mobile / app / actions / AuthAction.js View on Github external
return new Promise((resolve, reject) => {
            const email = firebase.auth().currentUser.email;
            firebase
                .database()
                .ref('users/' + formatEmail(email))
                .update(user);
            dispatch(receiveAuth(user));
            resolve();
        }).catch(err => {
            console.warn('Error catched');
github mikelambert / dancedeets-monorepo / mobile / js / firestack.js View on Github external
componentWillMount() {
    const dbRef = firebase.database().ref(this.props.path);
    console.log(`Installing handler on path: ${this.props.path}`);
    dbRef.on('value', this.handleValueChange);
    this._setHandler = true;
  }
github celo-org / celo-monorepo / packages / mobile / src / firebase / saga.ts View on Github external
const emitter = (data: DataSnapshot) => {
      if (data.toJSON()) {
        emit(data.toJSON())
      }
    }

    const cancel = () => {
      firebase
        .database()
        .ref(REQUEST_DB)
        .orderByChild(REQUESTEE_ADDRESS)
        .equalTo(address)
        .off(VALUE, emitter)
    }

    firebase
      .database()
      .ref(REQUEST_DB)
      .orderByChild(REQUESTEE_ADDRESS)
      .equalTo(address)
      .on(VALUE, emitter, errorCallback)
    return cancel
  })
}
github celo-org / celo-monorepo / packages / mobile / src / firebase / saga.ts View on Github external
function* updatePaymentRequestStatus({ id, status }: UpdatePaymentRequestStatusAction) {
  try {
    Logger.debug(TAG, 'Updating payment request', id, status)
    yield call(firebase.database().ref(`${REQUEST_DB}/${id}`).update, { status })
    Logger.debug(TAG, 'Payment request status updated', id)
  } catch (error) {
    Logger.error(TAG, `Error while updating payment request ${id} status`, error)
  }
}
github AOSSIE-Org / CarbonFootprint-Mobile / app / actions / firebase / Friends.js View on Github external
return new Promise(function(resolve, reject) {
        firebase
            .database()
            .ref('users/')
            .orderByChild('email')
            .equalTo(value)
            .on('value', function(snapshot) {
                if (snapshot.val()) {
                    snapshot.forEach(function(data) {
                        let user = [
                            {
                                name: data.val().name,
                                picture: data.val().picture,
                                email: data.val().email
                            }
                        ];
                        resolve(user);
                    });
github celo-org / celo-monorepo / packages / mobile / src / firebase / firebase.ts View on Github external
export async function setUserLanguage(address: string, language: string) {
  try {
    Logger.info(TAG, `Setting language selection for user ${address}`)
    const regRef = firebase.database().ref('registrations')
    await regRef.child(address).update({ language })

    Logger.info(TAG, 'User Language synced successfully', language)
  } catch (error) {
    Logger.error(TAG, 'Failed to sync user language selection', error)
    throw error
  }
}
github binbytes / react-native-firebase-chat / src / store / chat.js View on Github external
constructor() {
    this.database = firebase.database()
  }
github mapswipe / mapswipe / src / shared / Database.js View on Github external
getTimestamp() {
        return firebase.database().getServerTime();
    },