Should I be using firebase or firebase-admin on raspberry pi? - firebase

When writing Node.JS application for a Raspberry Pi communicating with Firebase, which npm module should be used?
What is the ideal way of doing things when on Raspberry Pi? Is it using firebase-admin or firebase package?

Both the regular Firebase client SDK, and the Firebase Admin SDK for servers can be used on a Raspberry Pi Node.js application. Which one to use depends on how you use the device and app.
The firebase module accesses Firebase as a regular client application, similar to how any other web app, iOS app, or Android app would access it. So with this SDK you'll typically ask the user to sign in with Firebase Authentication, and then use those credentials to access their data in Cloud Firestore.
The firebase-admin module however accesses Firebase as an administrative client. This means that it is authorized through pre-configured credentials, and can then access all data in Firestore and the rest of the Firebase project without any limitations. This SDK is used when you're creating an administrative application, that you then run on your Raspberry Pi.
So: if you're building a regular application that requires no special permissions, use the firebase module. If you're building an admin-type application that requires elevated permissions, use the firebase-admin module.

Related

Can I use the firebase/gcloud emulators to develop on a project locally without enabling billing?

I have a GCP/Firebase project that uses auth, FCM, Cloud Functions, Pub/Sub, and Firestore.
Is there a way I can use the emulators to set up a project that does not require billing to be enabled to do dev/testing?
From what I understand, FCM has no emulation component, so I would have to create an authentic firebase project for that component. Could I use an authentic firebase project for FCM and emulators for the rest?

Does Firebase.initializeApp() require network connection?

I'm building a flutter app, and in order to integrate Firebase to it, I have to run Firebase.initializeApp(), but I'd like to know if it that method won't work if the phone is not online
It does not require a network connection. It is just establishing configuration for Firebase SDKs. Those SDKs will require network.

access google cloud storage with firebase credential

I have a node.js client that uses firebase authentication. Now I want to access Google Cloud Storage, however the firebase SDK for node.js does not include GCS. Using #google-cloud/storage works but only with anonymous access. How do I apply the firebase credential to #google-cloud/storage so that GCS access is in the context of the logged-in user?
Node.js is a server that operates in a privileged environment. The Firebase Admin SDK (aka the Node SDK) talks to other services via a service account.
Firebase Authentication enables client-side authentication. The JavaScript SDK is the client-side SDK.
There is no Node.js client SDK for Firebase that accesses Cloud Storage. Since both the Firebase Admin SDK and the Google Cloud Platform client for Node.js use administrative privileges to access Cloud Storage, it looks like those won't be an option for you either.
The two options I can think of are:
Use the Admin SDK in a Cloud Function, and expose the files from Cloud Storage that way.
Use the REST API for Cloud Storage.
I admit that neither is trivial, so I hope somebody knows a better solution.

Are Cloud Messaging Topics Shared Across Firebase Projects?

I have 2 Firebase projects, one for development and one for production.
If I send a message to a topic in one environment, will it send notifications to devices registered to both projects?
e.g. I have one device with the production app installed and subscribed to the topic broadcast, I also have another device with the development app install and subscribed to the topic broadcast.
If I then send a message to the topic broadcast using the development Firebase project notification composer, will only the device with the development app installed receive it?
It can be due to the reason that you have registered app in both project with same application id.
Try adding suffix in build.gradle file to the development version like .dev
And register the app in the firebase development project with this id i.e. your_app_id.dev
The app id will now help firebase identify you dev and production app

Difference between Firebase Admin SDK and Firebase Admin Web API

I want to take a decision to use Firebase Admin SDK or Firebase Admin REST API.
I need to use it in the communication from Angular/Node.js to Firebase database.
Please let me know if you can share the comparison between this two.
Thanks.
For communicating from an Angular web app with the Firebase Database, use the Firebase Web SDK.
For communicating from a server-side Node.js process with the Firebase Database, use the Firebase Admin SDK.
For communicating with the Firebase Database from a platform for which there is no SDK, use the Firebase REST API.

Resources