Answer the question
In order to leave comments, you need to log in
How to create a chat on android using firebase?
I came up with the idea to try to create a chat for android that works according to the following algorithm:
1. The application sends a message to my server.
2. The server saves the message and instructs firebase to notify the recipient of a new message.
3. firebase send notification.
4. The recipient's application, having received a notification, sends a request to the server and receives the message itself.
I'm going to write the server part in php.
Here such questions arise, which firebase components should be used? How to designate a specific recipient for sending a notification? To what extent does such an algorithm have the right to life? And what are the pitfalls?
I would appreciate any help. Thank you!
Answer the question
In order to leave comments, you need to log in
and why directly realtime database not to zayuzat?
send notifications only if the person is not in the chat, you can not bother to write the backend logic in node.js and deploy it to the firebase function
There are almost none on the server, the only thing you need is fcmtoken. That is, the application must send fcmtoken at the first start, save it on the server. Then, when a message arrives, you need to determine the recipient's fcm token and send a request to the Google server via curl on my Post. If the chat is general, then there are built-in solutions for sending by groups, in my opinion, just an additional parameter needs to be added. In the application, the processing is standard, the standard Google class parses the code. There are zero pitfalls, the only thing is that there are two parameters for sending a push, the first one displays messages in notifications, and the second one does nothing, but simply passes it to the broadcast receiver of the application. And this, in android there are no restrictions on the size of the message, that is, it can not be stored on the server at all, but as it is sent, it still won’t be faked,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question