/ SDKs / iOS
SDKs
Chat SDKs iOS v4
Chat SDKs iOS
Chat SDKs
iOS
Version 4

Retrieve the online status of a user

Copy link

You can check if a user in the Sendbird application is currently connected to the Sendbird server. For group channels only, you can check whether each member is currently connected to the server.

var queryParam = ApplicationUserListQueryParams()
queryParam.userIdsFilter = ["Young"]
let query = SendbirdChat.createApplicationUserListQuery(params: queryParam)
query.loadNextPage { users, error in
    guard let young = users?.first, error == nil else {
        return
    }
    
    if young.connectionStatus == .online {
        // Young is online now
        // Acceptable values for User.connectionStatus are NON_AVAILABLE, ONLINE, and OFFLINE
    }
})

Retrieve the online status of channel members

Copy link

In a group channel, you can check the current connection status of each member. To do so, you need to first call the refresh(completionHandler:) method to update the channel with the latest information, then call members to retrieve a list of channel members.

When the members property returns a list of all members, you can call connectionStatus for each member object in the members property to check the corresponding member's current online status. Acceptable values of the connectionStatus property are offline and online.

Connection status values

Copy link
ValueDescription

UserConnectionStatus.offline

The user isn't connected to Sendbird server.

UserConnectionStatus.online

The user isn't connected to Sendbird server.

Note: If your client app needs to keep track of the connection status of users in real time, we recommend that you periodically call the loadNextPage(completionHandler:) method of a ApplicationUserListQuery instance after specifying its userIdsFilter filter, perhaps in intervals of one minute or more.