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

# Transfer Group Ownership

> Transfer CometChat group ownership to another member with the iOS SDK using GUID and target member UID.

<Accordion title="AI Integration Quick Reference">
  ```swift theme={null}
  // Transfer group ownership
  CometChat.transferGroupOwnership(UID: "NEW_OWNER_UID", GUID: "GUID", onSuccess: { success in }, onError: { error in })
  ```

  **Note:** Only the current group owner can transfer ownership. The owner must transfer ownership before leaving the group.
</Accordion>

Transfer ownership of a group to another member. Only the current owner can do this, and since owners cannot leave their group, you must transfer ownership first if you want to leave. See [Leave Group](/sdk/ios/leave-group).

## Transfer Ownership

Use `transferGroupOwnership()` to transfer ownership to another group member.

| Parameter | Description                                   |
| --------- | --------------------------------------------- |
| `UID`     | The UID of the member to become the new owner |
| `GUID`    | The GUID of the group                         |

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let uid = "cometchat-uid-2"
    let guid = "cometchat-guid-1"

    CometChat.transferGroupOwnership(UID: uid, GUID: guid, onSuccess: { (success) in
        print("Ownership transferred: \(success)")
    }, onError: { (error) in
        print("Error: \(error?.errorDescription)")
    })
    ```
  </Tab>
</Tabs>

On success, the new owner gets admin scope and the previous owner becomes a participant.

## Real-Time Ownership Changed Events

Implement `onOwnershipChanged()` in `CometChatGroupDelegate` to receive real-time notifications when group ownership changes.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    class ViewController: UIViewController, CometChatGroupDelegate {
        
        override func viewDidLoad() {
            super.viewDidLoad()
            CometChat.groupdelegate = self
        }
        
        func onOwnershipChanged(group: Group, newOwner: GroupMember) {
            print("Ownership changed in group: \(group.name ?? "")")
            print("New owner: \(newOwner.name ?? "")")
        }
    }
    ```
  </Tab>
</Tabs>

<Warning>
  Set delegate in `viewDidLoad()`: `CometChat.groupdelegate = self`. Remove delegate when view is dismissed to avoid memory leaks.
</Warning>

## Missed Ownership Changed Events

When fetching previous messages, ownership transfers appear as [`Action`](/sdk/reference/messages#action) messages (a subclass of [`BaseMessage`](/sdk/reference/messages#basemessage)).

| Field       | Value/Type                               | Description                        |
| ----------- | ---------------------------------------- | ---------------------------------- |
| `action`    | `"ownershipChanged"`                     | The action type                    |
| `actionOn`  | [`User`](/sdk/reference/entities#user)   | The new owner                      |
| `actionBy`  | [`User`](/sdk/reference/entities#user)   | The previous owner who transferred |
| `actionFor` | [`Group`](/sdk/reference/entities#group) | The group where change occurred    |

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Leave Group" icon="right-from-bracket" href="/sdk/ios/leave-group">
    Leave a group after transferring ownership
  </Card>

  <Card title="Change Member Scope" icon="user-gear" href="/sdk/ios/group-change-member-scope">
    Promote or demote group members
  </Card>
</CardGroup>
