Search code examples
androidauthenticationquickbloxquickblox-android

What is the difference between QBUsers.signIn and QBChatService.login?


I would like to understand what is the difference between the two actions. It's said in chat guide that in order to use the chat service, I have to create a session and then call login() - http://quickblox.com/developers/Android_XMPP_Chat_Sample#Login_to_Chat

and in the QBUsers guide - create a session and call QBUsers.signIn - http://quickblox.com/developers/SimpleSample-users-android#Sign_In_.26_Social_authorization

I'm not sure what do I have to do in order to be able to use the chat and to be able to retrieve users' profile data and so own (I want to display profiles of contacts to the user). So, if anyone could clarify the difference between those functions, I'd be very grateful! Thanks in advance!


Solution

  • Quickblox makes use of 2 different sessions, 1.User Session, 2.Chat session. In order to retrieve user profile pictures, dialogs list and every thing you will need user session and in order to receive and send chat seamlessly you will need chat session.

    But there is a catch. You cant establish chat session without user session. :) So you have to establish a user session first and then establish chat session after that.

    So when user quits the app or when application terminates, you have to close the chat session (no need to close user session I mean you have to log out from chat not from user session) and once user brings the app to foreground check both user session and chat session whichever has expired and re-establish the same.

    If you are wondering why to establish user session when I never logged out ,friend user session gets expiered automatically after 3 hours or so as per docs. So check if user session exists, if yes check chat session establish whichever is needed.

    Additional info: Chat session is short lived compared to user session. In fact, you can fetch the chats as well for a dialog, if you have user session, but you cant send chat to that dialog without chat session. Thats what I meant when I said "in order to receive and send chat seamlessly you will need chat session".

    Hope it helps. Any doubt am here to help you :)