Real time chat between website and app - google-cloud-messaging

We have social networking website which has a messenger module ( Chat with friends ) which is implemented in JQUERY, PHP and HTML with mysql. Now we are creating Mobile app of this Messenger module. So we decided to go to Ionic framework.
Now my problem is As we did R&D, We need to use GCM or FCM for smooth running of messenger with background service for real time chat and for push notification.
So my query is, If we use GCM or FCM, And one user has app and another user on website,
Then how they can communicate via GCM or FCM?
Another approach is we don't use GCM or FCM, Create REST API on server for Messenger app and call that API in background for messenger.
So which one is good approach?
If we use REST API then can you please share any example of this type, We are not able to find on google.
Please share your thoughts, We are struggling from last 7 days on this.

You will need to use websockets
on the client side socket.IO is a godd library ) , you need to connect to a socket server ( in php Rachet is a good one ) once the connection is open , you will basically have an exposed client side method ( function ) that the server can directly trigger.
eg: you have a chat window : two people connect
1) person A sends a message to the server
2) The server receives this new messages, the triggers a broadcast to the socket server
3) The broadcast calls newMessage( messageText ) on the client ( Person B )
4) All the connected clients then display the new message
you can also have private channels ( for chat rooms )
This is a VERY high level description of my understanding of web sockets ( you should go and do some more research on websockets, but this is a starting point )

Related

Push API / Web Push: what is the behaviour if client is offline?

I just finished the Google codelabs about Push notifications and I have some questions that I couldn't find any answer yet.
Using only web-push library on the server (so no Firebase or anything), do we need to create a database in order to store the endpoint and the userId ?
What happens if the client is offline when the server sends a Push notification ? Does the client will get it as soon as he's online ? Is the notification lost ?
-> if the notification is lost would it be a good solution to create a database table containing each notification and the status (delivered, not delivered) for example ?
I even searched in the on the Push API documentation and on the web-push npm page but there aren't any informations about those points.

Buildfire: PHP API To send notifications

I am using php api to send push notifications to users using docs provided here
https://sdk.buildfire.com/AWSGatewayPublicAPI/#/push_notifications/post_push_notifications_schedule
Is there a way I can send notification to all devices which has app installed but not logged in?
Thanks,
Chandresh
You don't have access to send a push notification to all devices, the group_id is required.
but you can create a service in your plugin and subscribe the users to your plugin group, this way you can send a PN to all subscribed users.

GraphQL subscriptions or RabbitMQ Message Queuing

I'm building a chat & notifications server based on NestJS & I'm worried about the best method to build the server to handle a minimum of 10K users/month. Please I need help. ( It's a react-native app client ).
I intend to use FCM & APNS to push notifications to users but about chat, no idea what to do.

How to access chat history in Twilio chat

I am following this tutorial https://www.twilio.com/docs/chat to integrate simple chat into my ASP.NET Core application. I don't understand where are messages from chat stored. Are they stored on Twilio server or I should manually store messages on my backend?
I have found two repositories with relevant code:
https://github.com/TwilioDevEd/sdk-starter-csharp - when I start chat with this project, clients are able to chat, but new client is not able to see old messages
https://github.com/TwilioDevEd/twiliochat-csharp - this code can start, but it is not possible to send messages with error code
WebSocket connection to 'wss://tsock.twilio.com/v2/wsconnect?token=eyJj...' failed: Error during WebSocket handshake: Unexpected response code: 503
Chat history is maintained unless you delete it. You can view chat history by joining an existing Twilio Programmable Chat channel which was used before.
You can also view the Chat history using the respective API's.
Read multiple Message resources

agent chat history problen in smack api

i wrote a java program to connect with google talk using smack api
connection and sending receiving messages are working fine
then how can i get the chat history using smack api
there is one method AgentchatHistory in smack but how can i use it
I believe AgentChatHistory is to support Openfire's feature call fastpath. Don't think Google supports that. If you want chat history, you will have to implement it.