Skip to main content

Pin a channel

Pin a channel to keep it at the top of the channel list. The pin state is synced to the Nexconn server and synchronized across devices.

Pin a channel

Call pinWithParams:completion: on a channel instance:

swift
import NexconnChatSDK
guard let channel = DirectChannel(channelId: "targetUserId") else { return }
let params = PinParams(updateOperationTime: false)
channel.pin(params: params) { error in
if error == nil {
print("Channel pinned.")
}
}

Unpin a channel

swift
import NexconnChatSDK
guard let channel = DirectChannel(channelId: "targetUserId") else { return }
channel.unpin { error in
if error == nil {
print("Channel unpinned.")
}
}

Listen for pin status changes across devices

Register an NCChannelHandler to receive pin status changes in real time when they are modified on another device:

swift
import NexconnChatSDK
final class MyChannelHandler: NSObject, ChannelHandler {
func onChannelPinnedSync(_ event: ChannelPinnedSyncEvent) {
print("Channel \(event.channelIdentifier.channelId) pinned: \(event.isPinned)")
}
}

let handler = MyChannelHandler()
NCEngine.addChannelHandler(identifier: "MY_CHANNEL_HANDLER", handler: handler)

See Sync Channel Status Across Devices for full details.