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

# Collaboration Extensions

> iOS SDK implementation examples for Collaboration extensions including Collaborative Document and Collaborative Whiteboard

This page contains iOS SDK code examples for Collaboration extensions. For feature documentation, setup instructions, and extension settings, see [Collaboration Extensions](/fundamentals/extensions-collaboration).

## How to Use Extensions with SDK

<Steps>
  <Step title="Enable in Dashboard">
    Login to [CometChat Dashboard](https://app.cometchat.com/login), select your app, then go to **Chat & Messaging → Features** and enable the extension.
  </Step>

  <Step title="Implement SDK methods">
    Use the code examples below to initiate collaboration sessions and extract URLs from messages.
  </Step>

  <Step title="Build your UI">
    Create UI components to display the collaboration interface (e.g., embed the whiteboard/document URL in a WKWebView).
  </Step>
</Steps>

***

## Collaborative Document

Co-edit documents in real-time with other users.

### Initiating the Session

```swift theme={null}
CometChat.callExtension(slug: "document", type: .post, endPoint: "v1/create",
body: ["receiverType":"user/group", "receiver":"uid/guid"], onSuccess: { (response) in
        // Success response
      }) { (error) in
        // Some error occured
      }
```

### Extracting the URL from Received Message

```swift theme={null}
if let metaData = message.metaData, 
   let injected = metaData["@injected"] as? [String: Any], 
   let extensions = injected["extensions"] as? [String: Any], 
   let documentExtension = extensions["document"] as? [String: Any],
   let documentUrl = documentExtension["document_url"] as? String {
    print("Document URL:", documentUrl)
}
```

***

## Collaborative Whiteboard

Draw and brainstorm together on a shared whiteboard.

### Initiating the Session

```swift theme={null}
CometChat.callExtension(slug: "whiteboard", type: .post, endPoint: "v1/create", body: ["receiverType":"user/group", "receiver":"uid/guid"], onSuccess: { (response) in
        // Success response
      }) { (error) in
        // Some error occured
      }
```

### Extracting the URL from Received Message

```swift theme={null}
if let metaData = message.metaData, 
   let injected = metaData["@injected"] as? [String: Any], 
   let extensions = injected["extensions"] as? [String: Any], 
   let whiteboardObject = extensions["whiteboard"] as? [String: Any],
   let boardUrl = whiteboardObject["board_url"] as? String {
    print("Whiteboard URL:", boardUrl)
}
```

### Append Username to the Whiteboard URL

```swift theme={null}
CometChat.getLoggedInUser { user in
    guard let user = user else { return }
    // Replace spaces with underscore
    let username = user.name?.replacingOccurrences(of: " ", with: "_") ?? ""
    // Append the username to the board_url
    let finalUrl = "\(boardUrl)&username=\(username)"
    print("Final Whiteboard URL:", finalUrl)
} onError: { error in
    print("Error getting user:", error?.errorDescription ?? "")
}
```
