User’s Online Presence

Correct me if i’m wrong but the only way to know if a user is online or offline is by using this code as mentioned in the doc

ArrayList<String> userIds = new ArrayList<>();

ApplicationUserListQuery listQuery = SendBird.createApplicationUserListQuery();
listQuery.setUserIdsFilter(userIds); UserListQuery.UserListQueryResultHandler() {
    public void onResult(List<User> list, SendBirdException e) {
        if (e != null) { 
            // Handle error.

        // list.get(0) = 'Jeff' 
        if (list.get(0).getConnectionStatus() == User.ConnectionStatus.ONLINE) {
            // 'Jeff' is currently online.
            // User.ConnectionStatus consists of NON_AVAILABLE, ONLINE, and OFFLINE.

and if i need a more realtime approach then i need to follow this as mentioned in the doc

it says that i need to have a mechanism wherein i’d be calling the next() function periodically, perhaps in intervals of one minute or more.

My question is how can i achieve the realtime-ness if i’ll be hitting every 1 minute or so, a user can switch back and forth from the app multiple times in a span of a minute and i won’t be notified of those events.

Hi @iamarjun. Could you please further explain what you are trying to do using this feature? If we knew that I believe we can deliver more helpful answers. Thank you.

@Cjeon I want to know the other party’s online presence in real-time

@iamarjun sorry if it sounds repeating, but my question was that, what are you trying to do using an online presence? Are you building a friend list with online status or are you making a game that some real-time online-ness is critical? Our answer could depend on your final goal so I wanted to clarify this.

@Cjeon It’s a simple chat app that shows a green indicator if the user is online and a grey indicator if the user is offline

Thanks for your reply @iamarjun . In that case, it would be pseudo-real-time, but how about checking the user’s online presence every 15 seconds or so? It would be a little delayed but most of the time it would work as expected - if it’s not enough I can talk to the team for new feature consideration as we currently do not support it.