Skip to main content
Channel presence tells your app whether any other member of a conversation channel is online. Use it for chat lists, member lists, and compact “active now” indicators.
Channel presence is available on iOS and Android only. The current TypeScript and Flutter SDKs in this checkout do not expose channel presence APIs.

Platform Surface

PlatformRepositoryMain APIs
iOSAmityChannelPresenceRepository()syncChannelPresence(id:viewId:), unsyncChannelPresence(id:viewId:), unsyncAllChannelPresence(), getSyncingChannelPresence()
AndroidAmityChatClient.newChannelPresenceRepository()syncChannelPresence(channelId, viewId), unsyncChannelPresence(channelId, viewId), unsyncAllChannelPresence(), getSyncingChannelPresence()
TypeScriptNot availableNot available
FlutterNot availableNot available
Only conversation channels support channel presence. The SDK sync limit is 20 channel IDs at a time.

Parameters

OperationParameterRequiredDescription
syncChannelPresenceid / channelIdYesConversation channel ID whose members’ presence should be refreshed periodically.
syncChannelPresenceviewIdNoStable view identifier. Defaults to amity-global; use a custom value when the same channel can appear in multiple visible UI locations.
unsyncChannelPresenceid / channelIdYesChannel ID to remove from syncing.
unsyncChannelPresenceviewIdNoMust match the viewId used when syncing if you passed a custom value.
unsyncAllChannelPresenceNoneNoStops syncing all channel presence tracked by the SDK presence engine.
getSyncingChannelPresenceNoneNoReturns iOS AnyPublisher<[AmityChannelPresence], Error> or Android Flowable<List<AmityChannelPresence>>.

Channel Presence Object

FieldiOSAndroidDescription
Channel IDpresence.channelIdpresence.getChannelId()The conversation channel represented by the presence record.
User presencespresence.userPresencespresence.getUserPresences()Presence records for members in the channel.
Any other member onlinepresence.isAnyMemberOnlinepresence.isAnyMemberOnline()true when at least one member other than the current user is online.

Sync Channel Presence

Start syncing when a conversation channel becomes visible, then unsync it when the row or screen is gone.
let repository = AmityChannelPresenceRepository()

let cancellable = repository.getSyncingChannelPresence()
    .sink(receiveCompletion: { completion in
        if case let .failure(error) = completion {
            handleError(error)
        }
    }, receiveValue: { presences in
        for presence in presences {
            let isAnyMemberOnline = presence.isAnyMemberOnline
            showSuccessMessage("\(presence.channelId): \(isAnyMemberOnline)")
        }
    })

repository.syncChannelPresence(id: channelId)

// Call when the row or screen is no longer visible.
repository.unsyncChannelPresence(id: channelId)

_ = cancellable

Unsync All Channel Presence

Use unsyncAllChannelPresence when leaving a channel list, tearing down a view model, or replacing the whole visible channel set.
let repository = AmityChannelPresenceRepository()

repository.syncChannelPresence(id: channelId)

// Later, when the channel list is dismissed.
repository.unsyncAllChannelPresence()

Best Practices

Sync a channel when its conversation row appears. Unsync during row reuse, unmount, or screen dismissal so the app stays under the 20-channel sync limit.
isAnyMemberOnline is designed for compact channel-list indicators. If you need per-user badges, sync those users directly with User Presence.
Other members can only see the current user as online if the app enables presence and starts the current user’s heartbeat.

User Presence

Sync specific users when you need per-user online badges.

Heartbeat Sync

Mark the current user as online with the SDK heartbeat.