Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Whatsapp, Viber like application keep tracks of mobile users?

Tags:

android

ios

I mean do they use ping-pong messages to get user connection information? In short, how they know where to send for coming request?

like image 895
Omer Faruk Celebi Avatar asked May 30 '12 07:05

Omer Faruk Celebi


2 Answers

For iOS, these apps use APNS (Apple Push Notification Service).

This is a service provided by Apple that helps applications to alert users when something happens.

In short (and simplified), it works like this

  • When the app is installed, the user is asked if the app should be allowed to send push messages to the phone.

  • If the user accepts, the app registers to the APNS server (hosted by Apple) and registers a "device token". This token is a serial number that helps the Apple Server to keep track of the phone.

  • The app connects to the application server (for example Viber's server) and sends the device token also to this server. The server will connect it to a specific user.

  • When the user receives a call, the viber server contacts the APNS server, which in turn alerts the user.

  • The APNS server keeps track of all apps the user has on his/her phone. It will handle notifications for all of them. The connection between the iPhone and the APNS server is built-in to the iOS platform and it happens automatically on a regular basis.

  • When the APNS server is told by the viber server that something is happening for specific device token, the APNS server will contact that specific phone and send a message to the phone. In this case the user will be told that he/she has an incoming call from viber.

Documentation for APNS can be found here: Local and push notification programming guide

When it comes to Android, there is a equivalent service, C2DM My guess is that these apps are working in a similar way on Android using this service.

If you need a little help getting started with Push, there is a great service called Urban Airship that makes things a lot easier, it support both iOS, Android and other platforms.

EDIT: In the case where the application is already open the connection can either be kept open using a socket connection, or content can be refreshed by polling. It depends on how time critical the application is.

like image 116
jake_hetfield Avatar answered Oct 29 '22 01:10

jake_hetfield


In such applications, users are track based on Android Device Unique ID.

import android.provider.Settings.Secure;

private String android_id = Secure.getString(getContext().getContentResolver(),
                                                    Secure.ANDROID_ID);
like image 40
HTWoks Avatar answered Oct 29 '22 02:10

HTWoks