Question

I am implementing a chat application for iOS. Here is the scenario:

  1. Two QBUUsers engaged in an active exchange of chat messages.
  2. User1 goes offline for some reason (disconnects or app goes to background). Lets assume that the app called logout on the QBChat instance.
  3. User2 sends a ChatMessage to User1 because he thinks User1 is still online.

I should send a Push Notification to User1 instead, but how do I detect that User1 is no longer available to receive a ChatMessage?

I saw that on StackOverflow someone recommended checking the "last_request_at" property on a QBUUser, but that seems heavy-handed since I have to query the server every time I send a ChatMessage. Also that will not tell me when they logged out of the QBChat instance.

My fallback plan is to track user login/logout on our own app server (not rely on QuickBlox server). Any elegant solution here using the QuickBlox SDK?

Was it helpful?

Solution

You have 2 ways what to do:

1) Use contact list http://quickblox.com/developers/SimpleSample-chat_users-ios#Contact_list

With contact list you can track online status of user for your contact list. Contact list is similar to common friends list like in Facebook.

2) send Push Notifications for every message. If user is offline - he will receive it. If user is online - just ignore this push.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top