> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-ios-v5-calls-corrections.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Screen Sharing

> Add screen sharing in CometChat Calls SDK v5 on iOS with presenter controls, permissions, and in-call display behavior.

View screen shares from other participants during a call. The iOS SDK can receive and display screen shares initiated from web clients.

<Note>
  The iOS Calls SDK does not support initiating screen sharing. Screen sharing can only be started from web clients. iOS participants can view shared screens.
</Note>

## How It Works

When a web participant starts screen sharing:

1. The SDK receives the screen share stream
2. The call layout automatically adjusts to display the shared screen prominently
3. iOS participants can view the shared content

## Listen for Screen Share Events

Monitor when participants start or stop screen sharing:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    class CallViewController: UIViewController, ParticipantEventListener {
        
        override func viewDidLoad() {
            super.viewDidLoad()
            CallSession.shared.addParticipantEventListener(self)
        }
        
        deinit {
            CallSession.shared.removeParticipantEventListener(self)
        }
        
        func onParticipantStartedScreenShare(participant: Participant) {
            print("\(participant.name ?? "") started screen sharing")
            // Layout automatically adjusts to show shared screen
        }

        func onParticipantStoppedScreenShare(participant: Participant) {
            print("\(participant.name ?? "") stopped screen sharing")
            // Layout returns to normal view
        }

        // Other callbacks...
        func onParticipantJoined(participant: Participant) {}
        func onParticipantLeft(participant: Participant) {}
        func onParticipantListChanged(participants: [Participant]) {}
        func onParticipantAudioMuted(participant: Participant) {}
        func onParticipantAudioUnmuted(participant: Participant) {}
        func onParticipantVideoPaused(participant: Participant) {}
        func onParticipantVideoResumed(participant: Participant) {}
        func onParticipantStartedRecording(participant: Participant) {}
        func onParticipantStoppedRecording(participant: Participant) {}
        func onParticipantHandRaised(participant: Participant) {}
        func onParticipantHandLowered(participant: Participant) {}
        func onDominantSpeakerChanged(participant: Participant) {}
    }
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    @interface CallViewController () <ParticipantEventListener>
    @end

    @implementation CallViewController

    - (void)viewDidLoad {
        [super viewDidLoad];
        [[CallSession shared] addParticipantEventListener:self];
    }

    - (void)dealloc {
        [[CallSession shared] removeParticipantEventListener:self];
    }

    - (void)onParticipantStartedScreenShareWithParticipant:(Participant *)participant {
        NSLog(@"%@ started screen sharing", participant.name);
        // Layout automatically adjusts to show shared screen
    }

    - (void)onParticipantStoppedScreenShareWithParticipant:(Participant *)participant {
        NSLog(@"%@ stopped screen sharing", participant.name);
        // Layout returns to normal view
    }

    // Other callbacks...

    @end
    ```
  </Tab>
</Tabs>

## Track Who Is Sharing

`Participant` carries **no** screen-share property, and the SDK exposes no getter for one. Track the
current presenter yourself from the start/stop callbacks.

<Warning>
  These callbacks fire only when a share **starts or stops**. A client that joins mid-call cannot
  discover a share that was already in progress before it joined.
</Warning>

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    // uids of participants currently sharing.
    private var presenterUIDs = Set<String>()

    func onParticipantStartedScreenShare(participant: Participant) {
        guard let uid = participant.uid else { return }
        DispatchQueue.main.async {
            self.presenterUIDs.insert(uid)
            print("\(participant.name ?? uid) started sharing their screen")
        }
    }

    func onParticipantStoppedScreenShare(participant: Participant) {
        guard let uid = participant.uid else { return }
        DispatchQueue.main.async {
            self.presenterUIDs.remove(uid)
        }
    }

    // A participant who leaves while sharing never sends a stop event.
    func onParticipantLeft(participant: Participant) {
        guard let uid = participant.uid else { return }
        DispatchQueue.main.async { self.presenterUIDs.remove(uid) }
    }
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    @property (nonatomic, strong) NSMutableSet<NSString *> *presenterUIDs;

    - (void)onParticipantStartedScreenShareWithParticipant:(Participant *)participant {
        NSString *uid = participant.uid;
        if (!uid) { return; }
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.presenterUIDs addObject:uid];
            NSLog(@"%@ started sharing their screen", participant.name ?: uid);
        });
    }

    - (void)onParticipantStoppedScreenShareWithParticipant:(Participant *)participant {
        NSString *uid = participant.uid;
        if (!uid) { return; }
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.presenterUIDs removeObject:uid];
        });
    }
    ```
  </Tab>
</Tabs>
