Google Cloud Platform: All about Firebase

Google Cloud Function

How to run Firebase Cloud Function locally?

Update firebase-tools and firebase-functions

cd functions
npm install --save firebase-functions@latest

Serve HTTP functions from the command line

firebase serve

react-native-firebase

Analytics

How to enable “Debug Stream” for iOS

  • Signing Set a signing team having developer account
  • Edit Scheme Add argument “-FIRDebugEnabled”

How to track screen and event?

import analytics from '@react-native-firebase/analytics'

export const trackEvent = async (eventName, data) => {
  await analytics().logEvent(eventName, data)
}

export const trackScreenView = async (screenName) => {
  await analytics().setCurrentScreen(screenName, screenName)
}

FireStore

How to get documents of a collection

  const snapshot = await firestore()
    .collection(collections.STATION_LIST)
    .get()

  return snapshot.docs.map(doc => doc.id)  // or doc.data()

Database

How to connect with Firebase database?

It automatically connect to Firebase via “GoogleService-Info.plist” file

How to push data without generating random id key?

When you push it generates a key for you. If you use set or update, it writes the object as you supplied

firebase.database().ref(`/users/${currentUser.uid}`)
.set({ name, description })
.then(() => {
  return firebase.database().ref(`/users/${currentUser.uid}/books`)
  .push({
    title: 'Yeah'
  });
});

Be the first to comment

Leave a Reply

Your email address will not be published.


*