How to send push notification using XMPP Server? - node.js

I want to develop a chat application in iphone. I'm using ejabberd xmpp server. Now i'm able to send message to other user.
Now i want to receive the message with push notification.
I heard that we can use xmpp servers to send push notifications.
So Can anyone tell me, I want to know how
Is it possible to send push notification with ejabberd
Is it possible send push notifications from ejabberd xmpp server using node js.
Please give any suggestion to start using notifications for messages in xmpp.

If you want to send push notifications with ejabberd community edition, you need to add an ejabberd module, which sends the offline messages to a specified push notification provider. This provider send the notifications to apple APNS or googles GCM.
You could develop a module by self or maybe you will find some in inet. mod_zeropush (https://github.com/ZeroPush/mod_zeropush) would be one of them, but the zeropush service by self is canceled. Another one would be mod_onesignal (https://github.com/nobreak/mod_onesignal). OneSignal is a free to use Push Notification provider.

XMPP requires a persistent socket connection or a "persistent" BOSH connection during your whole XMPP session. Whenever your iOS app goes in background iOS kills your socket connection, and your Openfire server kills your XMPP session. This means the user goes offline. Which is also the reason why incoming messages for this user go to the offline storage.
A more straight forward approach is to do something in openfire, when openfire can't deliver a message it stores it in offline table, we can do some interception on that part and initiate the push process with the message.

Related

Implementing push notification using Node.js

I was curious to know that can we implement push notification to our client via our Node.js server just like we send emails using nodemailler in Node.js? If yes! Then how? Can anyone please briefly elaborate. Also a point to note that the push notification should be user specific just like our mails are which are distinguished by our mail id.
Thanks in advance.
You can achieve this using Firebase Cloud Messaging. Here's a high level overview:
Each client registers with FCM and sends it's unique token to your node.js server.
The server saves this token and associates it with the user.
When it comes time to send the push notification, you use the FCM node.js library to send a push notification to the token associated with the user you want.
Not sure if it is the best way.
You might open a port on server side and listen to that port from client side. I am talking about socket programming. New notifications will be sent through that open port.

How to send message after user's socket disconnect from the server

I'm using net module of node.js to build a chat server based on TCP. I have figured out how to handle the situation where two users both connect to the server. However, for a chat app, even if the user disconnect from the internet, people can still send message to those disconnected users. I just have no idea of how to achieve this.
You need to save messages in a database so that when they log in again you can retrieve sent messages and send them all at once.
There is no way to communicate to a user who has logged off. You just have to queue up the messages and deliver them when they reconnect.

Receive Push Notification with Node.js webToolkit

I'm developing a desktop application using Node-Webkit.
Now I need to receive push notifications from somewhere.
This is what happens:
1) An android application sends a message to my WebApi server
2) My WebApi server receives that message and forwards it to the Node-Webkit desktop application
The desktop application can't poll the server, so I need a callback that "wakes up"
the desktop application to show the message on the screen.
So I need a service that can send push notifications to an Node-Webkit client.
Is there a way to do it?
Thanks a lot!
You should be able to achieve this by using socket.io
http://socket.io/

push notification like facebook

i want to build a push notifications service like facebook with nodejs and socketio. i have a question:
- how server can know what exactly client to send notification when many client connected to server?
Thanks for help!
Associate sockets with users when they connect, so when you have to notify user "Test" just look at the user.sockets[] list and send him whatever info you want to send.
In other words, Node.js doesn't have to "know" about users, you should take care of that and talk with Node.js in "socket" terms.
You can use socket.io's room feature. You can subscribe each client to its unique room and then emit an event in that room so that user will be the only one to get that.

server send push notification to client browser without using polling

I am developing a web app in which I want that when some changes in database occurs, server sends response to particular client(like push notification). And I want this notification to be sent client's browser. I don't want to use polling.
What can I do?
I think it's possible using SSE, but I am not clear.
I want to know
Is it possible to send response to particular client without client's request(without polling).
How server will detect that particular client?
please help me.
There is Web Notification. And there you can see the browsers that support it.

Resources