how to build watsapp like chat application in android [closed] - android

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 5 years ago.
Improve this question
Please suggest way to build watsapp like chat application.
In My Android application i have to put Chat Functionality
I already knows following ways.
Chat application by using GCM (Google Cloud Messaging).
Socket Programing
By using our webservice
Is there any other techniques for chatting app?

There are various methods to develop chat application.
1) Using HTTP connection (In this method each and everytime you want to send message, you have to call the webservice and for receive message, you continously need to call the webservice using Timer).
2) Using XMPP Server (XMPP server uses Socket programming, so once a connection will be establish, then it uses that connection each and everytime, you no need to create connection everytime, like HTTP).
3) Using GCM (Using Push Notification you can send and receive messages as well).

Things you need to build a chat app:
Server:
This is required to store all the user information like username, password and gcm registration id (will come to this later).
You can host it anywhere Amazon EC2, Google App Engine, etc
APIs for login, chat message sending, message list, delete message and many others.
Registration for GCM push notification:
Refer the link below:
https://www.digitalocean.com/community/tutorials/how-to-create-a-server-to-send-push-notifications-with-gcm-to-android-devices-using-python
Android:
Register to GCM and send the gcm registration id(as mentioned in point 1) to the server for updating.
Design user interface to send message, sending a message can be done either through REST API or by using socket connection.
You can explore XMPP and MQTT.
Server to Device communication and vice versa:
Now, on receiving message coming from the device, publish the message to the socket connection and as a fallback send push notification to the receiver device. There are 2 ways to do it:
i) Send the message payload along with the push notification
ii) Only send "sync" and on receiving the "sync" notification, receiver's android app can make a call to the server, fetch all the messages and show it to the user. Benefit of this approach is that the messages will never be lost. You will have to maintain the "sync" timing on the android app side.
Above was the normal way to build it if you want to learn but if you want to just get it done fast then you can integrate Applozic Mobile & Web Chat Libraries which will get you started with chat within half an hour. And the beauty is you wouldn't even need to develop or host any server.
Sample code to build chat in available in Github:
Android Chat SDK https://github.com/AppLozic/Applozic-Android-SDK
Web Chat Plugin https://github.com/AppLozic/Applozic-Web-Plugin
iOS Chat SDK https://github.com/AppLozic/Applozic-iOS-SDK
PS: I am the Cofounder #Applozic

Related

One to One Android Chat using Firebase

I need some clarifications.
I'm using Firebase realtime database.
Now I've to implement a realtime chat between two android devices. I need also push notifications.
So, the solution based on realtime database is to drop because if the app isn't running, it will not handle the onChildAdded event.
I read on the documentation that I can achieve my aim, using the upstream message from the device to the server.
Now, it's written also that we need an app server.
I just want to be clarified the need of the app server (XMPP or HTTP), and which is the entire flow of message m1 sent from the device A, and the notification on the device B.
In my opinion the app server should act as a man in the middle, so:
A ---> XMPP SERVER ---> FCM
FCM ---> XMPP SERVER ---> B
Is this the flow?
On the documentation I can't understand if I'm right or not.
If so, how do I send a message from the FCM back to the XMPP Server?
The notification message is sent from FCM to the client o from XMPP Server?
Please someone clarify me.
Other solution thought by me:
Since I find really powerful firebase realtime database, I thought these solution to walk around the problem:
Create an app server the is listening for onChildAdded and when it changes send a notification to client device.
Creating a background service on the client app listening to onChildAdded and create notification when necessary.
Even all, I don't like these solutions.
Just want to understand the standard and correct way to achieve my aim.
Firebaser and author of the article debated in the question comments here
To send messages to a device with Firebase Cloud Messaging, you need to specify your project's FCM Server Key. As its name suggests, this key should only be used in code that runs in a trusted environment: i.e. a server that you control.
To send device-to-device messages (such as in a 1:1 chat application where the receiving user is not necessarily online) you need two steps:
one user send an upstream message
the other user receives the downstream message
Using Firebase Cloud Messaging and your custom app server code, you can handle step 2. But that still leaves step 1: the user needs to send a message that somehow triggers your code on the app server. There are quite a few ways to do this.
For example you could implement an HTTP endpoint on your app server and have the chat application send the messages there too (in addition to sending to the database).
You could also implement an XMPP endpoint and have the chat application send the message there (again in addition to sending it to the database).
My article suggest yet another way, one that doesn't require implementing an endpoint at all. It uses a node.js script that runs on your app server and is essentially just a client to the database. Whenever this script detects a relevant chat message, it calls the FCM API and sends the downstream message.
This pattern of using the Firebase Database as your endpoint and then using server-side scripts is quite common when using Firebase. We documented it in our classic blog post Where does Firebase fit in your app? (as option 2) and in this article in the Google Cloud documentation.

how to send a request from web-server to android? [closed]

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.

Server push notification implementation [closed]

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
Group,
I am planning to implement my own Server push notification server to Android/IOS apps. So My application server (which may be implemented through NodeJs) will contact that Notification Server to push messages to devices. So i surfed through internet and found the below existing solutions.
Google cloud messaging
Apple push notification service
Firefox os push notifications
Microsoft push notification service
Q1)
On their respective sites; they were informing only about how to use their notification Server. However i need info on how they implemented their server push.
Please tell me; are they following any of this below?
Polling
Long polling
Streaming
Server Sent Events
TLS, SSL or TCP socket connections with Client
XMPP
Q2)
Below two methods are claiming that though my app is not running; they can still be able to sent notification to APP? How is that possible?
Apple push notification service
Firefox os push notifications
Q3)
In Firefox os push notifications; they have informed that they were avoiding keep-Alive to save battery life. My question is without keep-alive how to determine the connection is still alive or not ?
Q4)
Is this all these (GCM/APNS/FireFox OS) implementation is only Server side pushing, and won't accept requests from Client. Am i correct?
So still my server has to handle millions of device requests other than push messages, right?
If i use websocket between my own notification server and client devices, do i need to maintain one more websocket connection between my application server and clients to receive requests from devices ?
There are good articles available over internet, you can go through you will get answers. However I am trying to answer your question:
Answers are mostly true for android and google servers.
Ans1)
They have their listeners which has to be used by you by using their library classes in your code. You need not to bother about pushing. You have to send the message to server server will push the message to the device. They use OAuth.
Regarding Protocols, there are two methods using CCS and XMPP. CCS just uses XMPP as an authenticated transport layer, so you can use most XMPP libraries to manage the connection. To send notifications to device you can write code in android app to send as well as your server code. the message sending will be done only by your code. Rest will be taken care by Google Server in GCM case.
You can check detail at this link
http://developer.android.com/google/gcm/server.html
Also, for security issues
google cloud messaging security
https://groups.google.com/forum/#!topic/android-gcm/M-EevBitbhQ
Ans 2)
Yes in case your app is not running then also devices vcan recieve notification because you have to write code for broadcast listeners. In background it will be listening to server and whenever any message packet will be there it will recieve the message as notification. Android has service you need to not to bother about it. You have only to use those resources using the library class that makes your work easier and let them write if your app is not running then also it recieve notification. Obviously, there would be some listener whick make the app to recieve.Check "Recieve the message" section in this link
http://developer.android.com/google/gcm/client.html
Ans 3)-
Firefox OS Push Notifications are designed for one thing – waking up apps. They do not deal with data. Check this link
https://hacks.mozilla.org/2013/07/dont-miss-out-on-the-real-time-fun-use-firefox-os-push-notifications/
Ans 4)-
No it will acccept request from users also.
I am not sure for others, but for GCM it will do.
Please check "Send a message"
http://developer.android.com/google/gcm/client.html
Hope this helped you with your question.
Apple push notification is controlled by iOS not your app. Thus this is available even if the app is not running. To send a notification you open an ssl connection to the apple server and send the push notification payload. There is no polling or anything since iOS will handling everything.
If you intend to write your own server you can not user push notification and will drain the battery since you will be needing to pull message from your own server. Apple APNS is controlled by iOS, it connects to Apples server once is a while and collect all push notifications for all apps on the device.
Technical details aside, there are various third party solutions such Amazon SNS. Per million notifications should be about $0.50. Comparing this tiny cost than implementing your own servers/services (time, costs, reliability), I feel you should spend the time on other aspects of your project.

Google cloud messaging with CCS [closed]

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.

Implementing one to one and group chat in android [duplicate]

This question already has answers here:
How to make a chat application in android? [closed]
(6 answers)
Closed 9 years ago.
I am developing an Android app in which I have to implement chat messaging. I would like one to one chat or a group chat.
But I have no idea how to start. Please help me with this stuff. Any help will be appreciated.
A simple chat mechanism will have 2 basic functionalities
Send the message to server (with info about the recipient)
Receive the message from server (designated for my user name)
First step is simple, we can create a web service which will accept the message with additional information about recipient(s). We can create it using any server side language.
Step 2, that is fetching the message from server can be done using 2 techniques, Pull the message (using polling) from server, or Push the message from server to android phone
Polling: In this, the android device will keep accessing server after a few seconds to check if there is a message available for user. This again can be implemented using a simple async task at the client side which will keep calling a web service after say 2-3 seconds. This is fine to use if we are planning to enable chatting only when user is accessing the app (no notifications like gmail or facebook), so that we can kill the polling service when not in use (otherwise it will eat up resources).
Push notifications: a better option is to use push notifications. Android provide Google cloud messaging or GCM (http://developer.android.com/google/gcm/index.html) which will help achieve push from server easily. Otherwise you can try a third party API like urbanairship or pushwoosh depending on your requirement. Push notifications will help the user to receive messages even when he is not using the app.
So in nutshell, a webservice to receive the messages and a push notification mechanism should be sufficient to implement a chat service in android.
Little bit about UrbanAirship
I used UA in one of my projects for push notifications as I needed to support both iOS and Android. If you just want to support Android GCM might also be a good option.
Coming back to UA, check this for sample code and usage: https://docs.urbanairship.com/display/DOCS/Home
The way it works is simple, when someone installs the app and is connected to internet, app registers itself to the UA service. A unique code is specified for each installed app (this is the time when you can capture the user name and unique code and store somewhere in your DB). Next UA provides an API using which you can push a message to designated recipient(s), using the unique codes which are available with UA. These messages can be received by android app and used as per the requirement. Even if the app is not running we can show a notification just like when we receive an email or a message
You can use an existing platform like Scringo. It gives you a one-on-one chat as well as group chat (both the client and the server) as well as the push notification service.

Categories

Resources