I am using angular firebase in my angular firebase backend panel that I am creating for my mobile apps. However I require to send push notification to devices as admin.
I tried adding firebase-admin however its breaking entire backend with weird errors like . List is quite long
ERROR in ./node_modules/#grpc/grpc-js/build/src/channel.js
Module not found: Error: Can't resolve '../../package' in 'xxxx/backend/node_modules/#grpc/grpc-js/build/src'
What exactly is the issue, why is not compatible with angular and how can I use admin sdk to send push notifications
As far as I know, Firebase admin is not meant to be run in the browser. Are you including it into a NodeJS Web Server or into your Angular Application?
Related
I have to send notification to user from admin and from user to admin by sending the token of user from node js backend to firebase to handle the message
You should integrate your Flutter app and NodeJS backend with Firebase. Please, refer to the docs for detailed instructions and ask a new specific question if you have a more specific doubt.
FlutterFire docs for app integration
Firebase docs for server integration
NPM package
I have an admin site that has a react frontend, using redux actions, with a node.js app as the server which uses firebase-admin to do the work.
I want to use firestore's onsnapshot listener. but im not sure how this works within the HTTP protocol?
I can't use the firebase-admin from my frontend app, and i cant create realtime DB functionality from the backend within HTTP protocol.
The goal: to set snapshot listeners on my collections from rreact frontend without having to go through multiple authentication processes, considering ive got a separate auth system for admins with my express api.
Is there a solution for this?
EDIT:
my client app is currently initialized with firebase web app config data, but because im authenticating admins with my own express server, the firebase web SDK hasnt authenticated with firebase, so i dont have permission for the data i need. im not sure if i need a service account, or a web app config with extra setup or what
My recommendation is to integrate the Firebase JS SDK into your client app using signInWithCustomToken().
It's not too complicated to do. Though I suppose that depends a lot on how your current auth setup works.
The general idea is this:
Send auth request to your auth service.
Process the request like normal.
Evaluate if the user should have access to Firebase.
If they should, use firebase-admin to create a custom token and send it back to the user.
Use the token on the client to authenticate with Firebase.auth
You should make sure to have Firestore rules to allow admin users to access the data you need.
As an alternative that doesn't use the Firebase client SDK, you could have a long-running node process that opens an onSnapshot. Your react app could receive data from it using either Server-Sent Events or through a WebSocket
I have two Ionic applications, and both use the same API served with node. What I need is that when one app sends a post request, the other app gets that post request and uses the information that comes from the request. How can I achieve this? I thought of listening for that particular post request, but I don't know if that's possible, or when the post request reaches the API, trigger some action in the server that sends the information to the other app. Is this possible?
You can use Firebase Cloud Messaging to implement this.
When one ionic application requests a service from your server by using HTTP Requests, the server will trigger the respective action and sends a push notification to your other app by using the Firebase cloud messaging service. Your 2nd app will capture this push notification by subscribing to a URL in Firebase.
For the server-side, You can use fcm-node module or Firebase NodeJS Module to implement this functionality. For the mobile app, you can use providers in ionic to subscribe to firebase cloud messages
A detailed guide on implementing push notifications can be found here
I want to build a Node.js web app using Firebase (authentication, database and storage). But I get confused on which module should I use, firebase or firebase-admin (or both).
The admin SDK runs your code with administrative permissions. This means it bypasses the security rules of your Firebase Database. It also has functionality to manage users and mint custom tokens and can be used to send FCM messages.
If you use the regular (non-admin) Firebase module, you're running as a regular Firebase client and don't have these expanded capabilities.
The Firebase SDK v3 for node JS does not support authenticating with custom generated tokens the same way the web SDK does, the method is simply not there.
How should NodeJS applications running on client machines that wish to have limited visibility over nodes in the realtime database authenticate with this new approach ?
This scenario is supported since release 3.3 of the Firebase JavaScript SDK.
Client Authentication APIs are now available in Node.js. When you call intializeApp(), pass a serviceAccount to use the Authentication for Servers APIs in your app, or pass an apiKey to use the client Authentication APIs
Versions 3.0-3.2.1 of the Firebase SDK for Node.JS require that you have access to a service account/private key for the Firebase project. For that reason they are only targeted for use in a server-side environment.