Flutter push notifications using Socket IO and NodeJS Backend, is it Possible? - node.js

I'm planning to develop a native app for an already-built web app and nodeJS server that uses socket IO for real-time updates, my concern is if I can generate push notifications using socket io even when the user is away from the app?

If you want something simple, i will advice you to use firebase.
But if you still want to use socket.io, you can do it. The app listen for event emitting and when receive the event, trigger a local notification.
Check this link to learn more about background process.

Related

How do you send push notifications to a Rust app?

I'm building a desktop app with Tauri and I need to send pure-data push notifications to them from an AWS Lambda function. I was previously using FCM and listening from my Electron app with the push-receiver Node library that painstakingly reverse engineered the GCM message protocol. But I don't see anything similar for Rust. And from what I can tell WNS is only for apps in the Microsoft Store, and I'm not planning on requiring my users go through that.
Has this been tackled yet? So far the only route forward I can see is trying to port push-receiver to Rust.

React app listning for backend notifications

I'm developing a react app and I need to trigger notifications in it for database changes , My back end is node and I'm not sure how to achieve this task. Should I listen always from front end for back-end notifications?I need to do It like how they do it in Facebook, When I develop my flutter apps I used Firebase streams to achieve this and don't know how to do this in react and node with PostgreSQL database.
You can use web sockets or socket.io library.
https://socket.io/
Old browsers don't support web sockets, in that case you need to check repeatedly from the front-end whether there is any notification from the back-end, lets say when database changes. This is called polling.
But, socket.io supports this polling automatically if browser don't support web sockets.
Socket.io is used by many applications . Your purpose seems to be solved using this library. It is event based. Once there is any database change in backend, and if you set up a socket.io event emitter, your front end will receive it via socket.io on the client and your react app can finally notify the user.
From their website,
Socket.IO enables real-time, bidirectional and event-based communication.
It works on every platform, browser or device, focusing equally on reliability and speed.

Send Notification to dashbord app When New order is created in Database using Nodejs

Commerce web app. i want to send notification to be showed in dashboard when new order is created.how can i achieve this using MEAN stack (mongodb express angular and node). can i do this using socket.io. what is procedure to be followed.
You are correct in looking towards socket.io. Socket.io will allow you to do this very easily.
Frankly, you should be able to read the tutorial linked below and know what you need to do, as notifications are probably the easiest thing you could do with socket.io.
http://socket.io/get-started/chat/
Basically what you'd want to do is have your clients listen for an event from socket. You'll emit the event from socket when a new order is created.

Angular2 + Laravel with Real time & WebSockets

I built an app and i'm planning to make a real time battle with Angular 2 and laravel. For example, you hit the "attack" button, and your opponent see his life going down in real time.
My app built with:
frontend: Angular 2
Backend: PHP Laravel 5.2
Now I'm searching and learning for my real time battle component,
and I saw different guides and tutorials for it:
https://www.codetutorial.io/laravel-5-and-socket-io-tutorial/
http://4dev.tech/2016/02/creating-a-live-auction-app-with-angular-2-node-js-and-socket-io/
The first tutorial is about how to use Laravel 5 and socket io.
The second one is how to use Angular 2 with NODS JS and socket io.
When I say real time, I mean that both users see the same thing that is happening on the screen)
My Backend and Frontend are totally divided and I have no setup with NodeJS anywhere in my app.
Both users need to see actions happening during a battle in my app, and It need to go through my laravel API and shown via my Angular 2 battle component
My question is -
What's the best approach to real time app (seem websockets) using Angular2 and Laravel 5.2 to get the desired result of what I'm trying to achieve?
Laravel in this context is just templating and serving the client files, and acting as an interface inbetween the client and the socket.io server. It doesn't actually act as the socket.io server, and I don't believe it can.
So yes, you would still need something (node) to host the socket.io server to interact with the client, through PHP or otherwise. Personally, I'd skip Laravel/PHP altogether and just use node with koa/express/whatever to template your client (html/js/css/etc) files. Feels like an unnecessary abstraction to me.
The code below from socket.blade.php already has a connection to the actual socket.io server, so I don't see why the additional overhead of an HTTP POST through PHP/Laravel is a good idea. Security, perhaps, but you can handle that with the actual socket.io server as well.
var socket = io.connect('http://localhost:8890');
socket.on('message', function (data) {
$( "#messages" ).append( "<p>"+data+"</p>" );
});
For the real-time character of your use-case, websockets are definitely the way to go. The players that should get the updates should be in the same 'room', so you can broadcast changes more easily. For the other functionality you can either use websockets or regular API calls to your backend directly from your client-side app code with some kind of communication between your api and the socket server, e.g. through Redis.
TLDR:
All data through sockets, node server does api calls and broadcasts changes to active players
Use API from app directly, use pub/sub queue foo for communication between laravel and node to broadcast changes to active players
Option 1:
Angular frontend app
Set up websocket connection
Add triggers for game foo which will send data over the socket connection and is handled by your nodeserver
Only talks to sockets
Node server
Serves frontend app
Handles socket connections, divide players per game
Handles socket calls and calls laravel api to do mutations on your data
Process action and broadcast changes to players in game X
Laravel REST API
Auth x
Default CRUD foo
Option 2:
Angular frontend app
Talks to api directly
Uses sockets to listen for updates
Node server
Serves frontend app
Handle websocket data
Listen on queue for published data from API
Broadcast changes to players in game x over socket
Laravel REST API
Auth
Crud
Mutation x triggers publish in Redis or other queue, which the node server can/should listen on
I'm sure there are more ways you can set this up, you just have to decide where you want what. Maybe introducing Redis is something you do not want, in that case your node app will have more to do. If you do want to use something like Redis, you'll need to do API calls from either your frontend app or choose to do it through the node app anyway, combining the 2 options.
If you are planning to use websockets then there seems to be less use of laravel as only one socket is pretty capable of handling all the data that will be exchanged between the frontend and the backend, so if you don't mind changing your engine you can try Meteor, https://www.meteor.com/

What module / service should I use to push message from Node.js server to Mobile App written in Unity?

Here is my set up:
Node.js server with RedisCloud, and client mobile app written in Unity C#.
I'm trying to push message from Node.js server to UnityC#.
At first, I try to get Unity access RedisDB directly but that is too dangerous having Client connecting to DB, and open the port.
So, what module works well between Node.js & Unity for message pub/sub? or 3rd party services that takes data from Redis, and push to Client?
I think socket.io will work but it seems just too much work for Client to write code handling that.
Is there something like Firebase or Photon, but instead using Firebase DB, point to my own RedisDB?
Thanks.
If your mobile client is for iOS then you should use "Apple Push Notifications", if Android, you should use "Google Cloud Messaging".
You can easily find modules for these tasks on npm, for example: https://www.npmjs.com/package/gcm
Use a Cloud service like Pusher or Realtime (the company I work for). Simply subscribe a channel on your mobile app using the Realtime Unity SDK and publish the messages from your server using the Node.js SDK. You don't need to worry about the dirty backend details (security, scalability,...)
More at http://framework.realtime.co/messaging

Resources