In this post I am going to talk about how to build a chat application like WhatsApp. No one can deny that chatting apps are a great methods for real time communication. There are easy,fast and cheap way to communicate with each other. At the beginning let us analyze Whats App . This application has three core features as the following:
- Chatting: One to one chatting and Group Chatting Calling:
- Audio and Video Calling
- Secured Communication: Encrypted messages and calling
Nice ,how can I build these features from scratch?
OK. let me share my experience with you. It was a great chance for me to work with amazing team to build a chat application like WhatsApp and we did it, so I will share the technologies we used . We build a chat application based on XMPP . XMPP(Extensible messaging and presence protocol) is a great protocol for handling messaging and presence for users.XMPP has core features and additional features called extensions and this is overview about XMPP features :
To exchange the messages between two end points through XMPP server you need to follow the protocol from your client side (Android/IOS).We used Smack Library as our XMPP client and we Used OpenFire Server as our back end server with external MySQL database . You should use the open source code of smack and use it as project in your build.gradle file and also for your open fire you want to build it because you will often modify it according to your business. we modified them to suite our needs.The following are some resources to learn Smack library:Smack Documentaion , ِAndroid chat Demo based on Smack
To be able to make real time video and audio calling or screen sharing also ,you should use WebRTC Technology. WebRTC enables you to make real time communication through two steps:
Signaling: firstly, you should do some signaling between the caller and the callee to exchange your media info and bit rate and more . Also You send offer to the callee then callee sends answer if he wants to answer you .Before that you must be connected to some room on AppRTC Server .You should build your own AppRTC server with your TURN and STUN servers.
Peer-to- Peer communication: here you call your end point using peer to peer technology and there is no server in the middle. The following are some useful resources to learn more about WebRTC:
Now ,we will talk about the hardest part ,in my point of view encryption is the most challenge task for building chat app and this because is not easy task especially if you do not study encryption course before ,so I will talk about the more secure and advanced protocol for encryption until now. Signal protocol is one of the highest encryption protocol nowadays.Signal is build by Whisper Systems company . It is secure and open source ,also it is used by the biggest companies in the world like Google,Facebook and WhatsApp. Unfortunately there is no samples for its implementation on Github so I will share the following only :
Finally ,I hope this article will helps you to build your own chat application. Please share your experience with me through commenting on this post if you have experience with chatting apps