Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does user's whatsapp application detects change in profile picture of its contact?

I was going through whatsapp application and I noticed that, for the first time it fetches thumbnails from the server, keeps them in cache memory, and thereafter it fetches these from the cache memory instead of server. (Like bitmap lazyloading).

Till now I have completed implementing the bitmap lazyloading part.

However I have a question as follows:

When any contact changes its profile picture how does the user's whatsapp application detects that particular change and how does it update that particular thumbnail only, cause the application is supposed to fetch the thumbnails from cache memory.

I am clueless about this. Any help is appreciated.

EDIT:

Does it use push notification to notify the client applications to update the corresponding profile thumbnail?

like image 618
Ritesh Gune Avatar asked Aug 20 '13 08:08

Ritesh Gune


People also ask

How do you know if someone checked your profile picture on WhatsApp?

Sadly, you can't see who has viewed your WhatsApp profile. WhatsApp has no feature that lets you see who viewed your profile. However, you can control who sees your WhatsApp profile. You can control who views your “last seen“, “profile photo”, “about info” & “WhatsApp status”.

Can a deleted contact see my profile picture on WhatsApp?

Then, follow Option 1 and select "My Contacts" so that only your contacts can see your profile photo on WhatsApp. Because you've deleted the contact from your phone, they won't be able to see your picture.

Why would someone's profile picture disappear on WhatsApp?

If you can't see someone else's last seen, profile photo, about, status, or read receipts, it might be due to one of the following: There's a temporary network issue. You or the user changed your privacy settings for last seen or profile photo. You and the user both need to resync your contacts.


2 Answers

Source: WhatsApp is build upon C2DM and XMMP for message delivery. MQTT is another protocol which is used to minimise the battery usage.

When any contact changes its profile picture how does the user's whatsapp application detects that particular change and how does it update that particular thumbnail only, cause the application is supposed to fetch the thumbnails from cache memory

Answering your question: So WhatsApp may be using XMMP push or a GCM push notification(C2DM is deprecated ;] ) to inform all the client that some event has occurred and all it's client needs to take care of the same. In your case event is to update your profile pic in devices of your friends in WhatsApp contacts

In your case, you can use GCM to update clients regarding such events. I don't have much idea about XMPP but You can also have a look at Smack API(An Open Source XMPP (Jabber) client library for instant messaging and presence) and this interesting post

I hope I answered your question. Good Luck :)

Edit:

GCM is a service from Google that uses a persistent XMPP connection to communicate with Android devices. You can use any of the following techniques of GCM to achieve this.

  • Send "send-to-sync" messages
  • Send messages with payload
like image 180
Vishal Vyas Avatar answered Sep 21 '22 01:09

Vishal Vyas


An easy way to handle this situation will be to keep an modified datetime in the table where you store the path of the image and thumbnail. You have to keep the url of the image along with the modified date as the parameter.

Eg:

http://yourdomain.com/images/user_id.png?q=modifieddatetime

Whenever the app will try to open this link, it will first check whether it is available in cache or not. If not the new image will be fetched from the server.

I have not tried this on Android, but it should work. I usually do this in my web applications.

like image 43
Sunil Mishra Avatar answered Sep 21 '22 01:09

Sunil Mishra