I want to receive the notifications from a schedule based game and post them into a Discord channel. For example they are something like "Hey join now!" when the game is live, or updates to the games schedule.
Please go through the document for FCM to send notification from your server adn receiving at your client side.
FCM supports all major platforms.
https://firebase.google.com/docs/cloud-messaging/
If you have any further queries, please ask them after implementing, so that community can better help you out.
Related
I need my discord bot written in PYTHON to be able to send a text chat notification about the start of the stream. I tried using webhooks in discord using the IFTTT site, but the alerts come with a huge delay. Can someone throw off some of the code for notification of streams? Thank you in advance
You can use Twitch's Eventsub to recieve a notification when a Stream goes live then modify the payload to match Discord's Webhook format and forward the payload on. Which is essentially what IFTTT does anyway.
Currently EventSub only offers a Webhook Transport. So you need a "Server" that can recieve a HTTP Post from Twitch.
Twitch EventSub is covered here https://dev.twitch.tv/docs/eventsub
Discord Webhooks is covered here https://discord.com/developers/docs/resources/webhook
If you want your Discord Bot to do it itself, then you generally would not use EventSub as you don't want your Bot process to be directly web accesable, so you'd have to poll the Streams Endpoint of the Helix API periodically and test for the Stream changing from offline to online and do whatever is needed. (Or setup a side process to recieve and internal relay the data)
You would use a Twitch App Access/Client Credentials Token, since this is a server to server request.
I'm creating a NodeJS application that should receive notifications from FCM. I've seen in the FCM documentation that you can send, but not receive notifications in the current version.
I've already searched alternatives for FCM, like pushy but seems that they have the same problem, only send notifications, not receive.
Currently I'm poling a REST api every 30 seconds to check for changes but obviously this is not the perfect scenario.
Is there any opensource or commercial solution that can receive notifications from a service, similar to firebase?
I find
https://github.com/MatthieuLemoine/push-receiver for node
and https://github.com/Francesco149/push_receiver for python
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.
I am developing a Web-app with Angular (client-side) and Node (server-side). I'd like to integrate some social features, including a chat. So a user can discover near users and send them a message.
I want to know the best way to implement this. I have an idea, but it seems to me very raw, and I am afraid that it could overload the server.
my idea is to send each minute from the client, a request to the
server about new messages
the server looks for new messages among
all the conversations of that user, checking the last-message's
time for each conversation
the server sends back the conversations
with new messages
if the client receives conversations with new messages, a
notification appears, so the user can open the chat.
once the chat is opened, the request to the server for
new messages is sent each 3 seconds (instead of 1 minute)
Example of conversations of a user, stored in MongoDB
{'conversations':
[
{'to':{'user-id':'101010', 'name':'Michela', 'location':'Alba Adriatica',
'img':'http://graph.facebook.com...jpg'
},
'last-msg':12345, //epoch
'msgs':[
{'from-me':'ciao come stai?', 'date':''},
{'from-you':'bene grazie, tu?', 'date':''},
{'from-me':'eh insomma..mi so rott lu cazz', 'date':''},
{'from-you':'dai poi vai alle Hawaii', 'date':''}
]
},
...
]
}
You realy should learn about websockets and how they can provide 'push and pull' of information.
the approach your suggesting called 'long polling'. And yes, if the time between is not very long, the server will be under heavy load if the number of clients increases.
Using websockets you can let the server communicatie only with the clients that actually need the information.
Do a google search for "node.js chat application tutorial". It is not that difficult.
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.