Skip to main content
Enable the current group owner to delegate ownership to another member using CometChat’s UIKit for iOS.

Overview

The Transfer Group Ownership feature provides a modal interface where the group owner can:
  • See a list of current group members (excluding themselves).
  • Select exactly one member to become the new owner.
  • Trigger the ownership transfer API call.
  • Automatically exit the group after successful transfer.

Prerequisites

  • A UIKit-based iOS project.
  • CometChat UIKit for iOS v5 installed via CocoaPods or Swift Package Manager.
  • CometChat SDKs (CometChatSDK, CometChatUIKitSwift) integrated.
  • Logged-in user with CometChat.login().
  • UINavigationController or modal presentation flow set up.
  • Group context (GUID) available when invoking the transfer screen.

Components

Integration Steps

1. Present Transfer Ownership Screen

Show the ownership transfer UI modally.
File reference:
GroupDetailsViewController.swift

2. Configure Single Selection Mode

Restrict selection to one member and capture selection.
File reference:
TransferOwnership.swift

3. Load & Filter Member List

Exclude the current owner from the selectable list.
File reference:
TransferOwnership.swift

4. Perform Ownership Transfer

Call the API, emit event, and exit the group.
File reference:
TransferOwnership.swift

5. Manage Loading State

Provide visual feedback during network calls.
File reference:
TransferOwnership.swift

Customization Options

  • Title Text: Replace localization key with custom string.
  • Spinner Style: Adjust spinnerView.style and color using CometChatTheme.
  • Error Handling: Customize error alerts in the onError closure.

Filtering & Edge Cases

  • Empty Member List: Show an informative empty state when no eligible members exist.
  • Network Failures: Disable proceed button until connection restores.
  • Blocked Members: Exclude or disable blocked users from selection.

Error Handling

  • Transfer Failures: Present UIAlertController with retry option.
  • Unexpected States: Ensure removeSpinnerView() always executes in defer.

Feature Matrix

Full Sample App

Explore the transfer ownership feature in context: GitHub → SampleApp

UIKit Source Code

Review the implementation: TransferOwnership.swift