Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
From my research MQTT brokers only save the most recent message but facebook uses MQTT in its messenger app. So are they using a custom broker to retain the messages?
https://www.facebook.com/notes/facebook-engineering/building-facebook-messenger/10150259350998920
My question is it possible for mqtt brokers to retain all messages sent so that I can create my own chat messaging mobile application? I know that paid services like HiveMQ offer this functionality but I am looking for a free alternative.
MQTT is a protocol for sending and receiving messages between a client and server. What either does with the messages beyond the basic requirements of the protocol will be implementation dependant.
You could use a application subscribed to a topic to store all messages in a database - it does not have to be a function of the broker component.
The usual MQTT broker works in a passive manner. It gets the message from publishers and forwards it to any available subscriber.
I think Facebook uses another process that receives the messages and then sends it to the clients again. The clients then can send another MQTT message when it receives the message.
However, MQTT has some QoS mechanism. It's possible to use it if there's a persistent connection to the client. Facebook may be making use of that too.
In case you need message persistence out of the box, it's not possible with MQTT though. You can use a technology such as Apache Kafka.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am completely new to the whole concept of push notifications. I have written a back-end server and I will send push notifications from it to the Android app, which is also written by me. But my question is:
Do I really need, or why would I need a Push notification service?
Thanks!
If you want to use FCM to send push notifications, at some point in time, someone has to make a request to Google's FCM service, because Google is the only one, who can send a message to a device via FCM. Same applies for APNS, at some point in time, someone has to make a request to Apple's APNS service
Depending on your requirements, you can do this yourself in your own code or you can use some 3rd party provider. Using a 3rd party provider MAY have benefits. For instance they may take care of token management, or provide a single request for sending to Android and iOS devices, and so on and so forth. But in the end of the day, also a 3rd party provider sends out requests to Google or Apple in your behalf.
You can use firebase cloud messaging service or using socket programming for this .
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am a beginner in android application development,therefore i dont know the cons of firebase cloud messaging.So,can i use fcm for chat application which can handle multiple users at a time
FCM can be a valid part of a chat application, but it will only be one piece of the puzzle. You also need a server component for a complete solution.
Two advantages of FCM over other approaches for messaging:
No need to create an additional connection for the most part (battery, data, & performance advantage) if you use XMPP as your protocol for upstream and downstream messaging. An XMPP FCM client will reuse the device's single persistent connection to FCM servers.
Ability to have (high-priority) messages trigger a notification even in Doze mode to ensure instant user notification.
There are alternative technologies available that you might consider, but for a beginner in Android development FCM may be one of the better approaches if you know your way around a server.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am working on a chatting app. In which one user sends message to another user. So there are two users(user1 and user2). when user1 sends a message to user2. On back-end I am sending the message to my web-server using post method, then user2 is always sending get request to server and receives the message in response. In this way my job is done but my question is that if there is any way to send a request from web-server to phone? and user2 can directly receive the message without sending request to the server all the time. Please help!
As #Linesh said above, could be one possible solution but rather unconventional using GCM for chatting purpose; instead you can make use of standard web sockets, which could be easily implemented in node.js, or PHP,Python, whatever server side programming you are supposed to be using. also based on websockets , have look at socket.io or you can make use of some third party chatting API's like quickblox, or pub-nub or even AWS as well.
Yes there is a way. You can use GCM to send the msg to phone.
The working would be like.
register both the devices with gcm and store the registration id to your server with the unique user id
when user1 sends some msg to server. then get the registration id of user2 and send the msg to gcm server.
user 2 will get the msg when he connects himself to some network.
this links will might help you
http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-1/
http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-2/
One big downside to using 100% GCM is that it can tie you to Android unless you take extra steps in your design to ensure that you can use other services too - with an improper implementation you could only do chat between Android phones but not, for example, Android to iOS, Windows Phone to Android, or Android to desktop client. This ends up being a significant downside since, based on statistics I saw recently, Android has an approximately 66% market share. While this sounds like a lot, this limitation would mean that you couldn't chat with 1/3 of people. iOS, Windows, and Amazon phones/tablets all use different push notification services. (One possible solution to this is to use AWS SNS Push, which will act as a "matchmaker" for different push notification services; this would improve the platform independence to some degree).
SignalR is another option. There are actually quite a few examples of chat apps out there that use it - it seems to be the canonical example actually.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have got a client-server android app and i want to integrate a small
messaging tool where users can send messages to other users. It does not
need to be like a real time chat, it would be enough to act asynchronous
like email messaging for example.
I just need to know whats the 'best practice' for such a messaging service
for storing the messages. Is it smart to save all the messages and message
history in the database or should they be stored as files on the harddrive
on server side?
Is it enough to save them at the server and load them into the app everytime
the users opens the messaging activity or would it be better to synchronize
the messages? Or shouldnt i store the messages on the server at all and keep the
history on the device itself?
The answer is 'depends'. Do you expect a lot of messages? If so, synchronizing is probably better than downloading all the messages.
Do you want users to see messages on another device if they switch devices? If so, you have to store the messages on the server.
Also, do you want users to be notified of a message when they're not using the app? Or when another user sends them the message, and not when they start the app? That would require using push notifications.
So - depends.
The best practise would be mainly to use GCM for notifying devices about new messages, which requires a server anyway. Once you have a server, it's better to have database to be sure you won't lose any messages.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to GCM and have a few questions regarding an app implementation. The app should be capable of upstream messaging. So -
Do I have to create a server (lets say in Google App engine) which will communicate with GCM. And then GCM will send the message to the app. Or I can do it just with CCS connection and my device can send message to app on another device without a server?
Is there a code example of writing server side code which I can use in App Engine? I badly need some tutorial/code implementation on CCS to understand the logic. I dont think android developer site is enough to understand things clearly.
Help appreciated!!
Hi Actually I am using http://parse.com to create server and push notification in android.
First of all you should always go to the source and read, as Google provides samples and everything.
About 1 and 2 then it depends if your going to use a third party provider or do everything yourself.
If your making everything yourself then YES you need a server and YES Google provides some code but I've never used it so I can't tell you how much work you have to put in it.
If you just want GCM capabilities but it doesn't have to be Googles, then there is plenty of alternatives out there: Parse.com and Urban Airship to name at least two.
Following link will help to code GCM but it is unidirectional(from third party server to cloud only)
http://avilyne.com/?p=267
Google GCM CSS provides upstream messaging that is from application(http://developer.android.com/google/gcm/client.html), you can send a message. This message will reach the Google server and they will send you the same message to your server, which you have to implement(https://developer.android.com/google/gcm/ccs.html).Do what you want with it.
If you have to send a message from your server to the client(application), you can send it via your css server or by making a http call to the google gcm http server. They will send the message to the client. You have to handle the received message and can show as a notification or use internally.