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
Related
I am running a cloud scheduler with firebase functions and would like to send the specific user a notification when something in the cloud using node js has completed, I researched about cloud messaging but it send it to everyone, I don't want that, how can I achieve what I'm looking for
You can send notifications to a specific app instance by targeting the FCM device registration tokens.
https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-specific-devices
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 need to use firebase cloud messaging application in web application development. I am able to send the push notification to a single client from the server. But I dont know how to subscribe tokens, i.e, sending push notifications to multiple clients from a single server. Is there any example code available for sending messages/notifications to multiple clients?
I am using Serverless framework to create lambda functions with node.js backend that uses fcm-push package.
Desired flow :
Call api from mobile app -> api uses fcm-push package to send the payload/message/registration tokens to Firebase Cloud Messsaging -> sends push notification to Android and iOS devices
This works perfectly when I run the api locally using "serverless invoke local..."
However, when I do "serverless deploy" and hit the api endpoint from mobile app OR a rest client like Postman, the api call times out, i changed the timeout to 45 seconds and still times out. To troubleshoot, I removed all fcm related code from the api to see if api returns a response while hitting from mobile app/Postman. It does. So it seems like AWS is preventing the api to make a call to fcm, and the call lasts until it times out.
I am not sure what I can do to get around this as I am fairly new to using AWS, so any input would be helpful
If you are using API Gateway as API endpoint which is connected to a lambda function, then you need to specify the body template in the API gateway itself. Make sure you are able to get the values at your Lambda function that you have been sending via the REST API call to your API gateway.
Please find the link to this answer I wrote earlier to achieve the same.
You should check for any break point in your function.
I built my bot using Node.js. It is working fine on web chat and Skype.
Now I want to use direct line to communicate my web app with my bot. I am confused on how I can maintain the URL in my node.js app.
I am trying something like that:
https://directline.botframework.com/api/conversations/abc123/how%20are%20you/BotConnector/NsNT2RG8oNA.cwA.Emk.8yB_FdFCy18b4iTcxBscDRxQVAB
Here you will find a DirectLine Node.js sample that implements a client to talk with a Node.js bot.
Remember that you also need to enable DirectLine in the Bot Developer portal in order to get the DirectLine credentials.