Skip to main content
Provide a detailed view for CometChat groups in your iOS app, enabling users to see group info, join/leave, manage members, and respond to real-time group events.

Overview

GroupDetailsViewController displays comprehensive group information and actions:
  • Group Info: Name, icon, description, and member count.
  • Actions: Join/Leave/Delete group.
  • Member Management: View members, add members, view banned members.
  • Real-Time Updates: Reflects joins, leaves, bans, and ownership changes.

Prerequisites

  • A UIKit-based iOS project.
  • CometChat UIKit for iOS v5 installed via CocoaPods or Swift Package Manager.
  • Valid CometChat App ID, Region, and Auth Key.
  • User logged in with CometChat.login().
  • Navigation stack (UINavigationController) configured.

Components

Integration Steps

1. Presenting the Group Details Screen

Push GroupDetailsViewController for a selected group.
File reference:
HomeScreenViewController.swift
Initializes and presents the details UI with the correct group context.

2. Setting Up the UI

Configure scroll view, header, and action views.
File reference:
GroupDetailsViewController.swift
Lays out the UI components and registers for group events.

3. Enabling Group Action Buttons

Wire up view/add/banned members actions.
File reference:
GroupDetailsViewController.swift
Enables user interaction for member management.

4. Handling Leave and Delete Actions

Provide ownership-aware leave/delete flows.
File reference:
GroupDetailsViewController.swift
Manages group exit, with transfer prompt for owners.

5. Listening for Group Events

Update UI on member joins, leaves, bans, and ownership changes.
File reference:
GroupDetailsViewController.swift
Keeps the group details in sync with back-end events.

Customization Options

  • Header Styling: Use CometChatTheme to customize fonts, colors, and borders.
  • Button Labels: Localize or rebrand action texts.
  • Avatar Placeholder: Provide fallback initials or default images.

Filtering & Edge Cases

  • Private/Protected Groups: Prompt for a password before joining.
  • Already a Member: Hide or disable Join button.
  • Empty Group: Show an empty state when no members.
  • Owner Restrictions: Disable Delete for non-owners.

Error Handling

  • Join Failures: Show alert on network or permission errors.
  • Leave/Delete Errors: Display retry prompt on API failure.
  • Event Errors: Log and notify user if group events fail.

Feature Matrix

Full Sample App

Explore the complete Group Details flow: GitHub → SampleApp

UIKit Source Code

Browse the Group Details implementation: GitHub → GroupDetailsViewController.swift