Skip to content

Commit

Permalink
docs(ios-core): chat and stage v2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
saksham-gt committed Feb 5, 2025
1 parent 595a4f0 commit 45a17e7
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 73 deletions.
11 changes: 7 additions & 4 deletions docs/ios-core/chat/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Introducing chat
title: Introduction
description: >-
Learn the basics of integrating Dyte's chat functionality into your iOS
application – a step towards immersive real-time communication.
Expand Down Expand Up @@ -29,7 +29,8 @@ class DyteTextMessage {
let pluginId: String?
let message: String
let time: String
let channelId: String? = null
let createdAtMillis: Int64
let targetUserIds: [String]? = null
}
```

Expand All @@ -43,7 +44,8 @@ class DyteImageMessage{
let pluginId: String?
let link: String
let time: String
let channelId: String? = null
let createdAtMillis: Int64
let targetUserIds: [String]? = null
}
```

Expand All @@ -59,7 +61,8 @@ class DyteFileMessage{
let time: String
let link: String
let size: Int64
let channelId: String? = null
let createdAtMillis: Int64
let targetUserIds: [String]? = null
}
```

Expand Down
6 changes: 6 additions & 0 deletions docs/ios-core/chat/receiving-chat-messages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ extension MeetingViewModel: DyteChatEventsListener {
func onNewChatMessage(message: DyteChatMessage) {
// when a new chat message is shared in the meeting
}

func onMessageRateLimitReset() {
// when the rate limit for sending messages of self is reset
}
}
```

The `onChatUpdates()` method will be called whenever there is a change in the chat messages. The `messages` parameter is a list of `DyteChatMessage` objects that have been sent in the chat.

The `onNewChatMessage()` method will be called whenever a new chat message is shared in the meeting. The `message` parameter is a `DyteChatMessage` object that has been sent in the chat.

The `onMessageRateLimitReset()` method will be called when the rate limit for sending messages of self is reset and you can send messages again. The default rate limit is 180 messages within 60 seconds.
31 changes: 25 additions & 6 deletions docs/ios-core/chat/sending-a-chat-message.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,36 @@ You can send an image with the help of `meeting.chat.sendImageMessage()` and
sends it to the participants in the meeting.

```swift
var filePath = "file_path_of_image"
var fileName = "file_name"
meeting.chat.sendImageMessage(filePath, fileName)
meeting.chat.meeting.chat.sendImageMessage(imageURL: url) { err in
// Handle error if any
}
```

## Send a file

Sending a file is quite similar to sending an image. The only difference is that when you send an image, a preview will be shown in the meeting chat, which is not the case for sending files. That being said, an image can be sent as a file too using `meeting.chat.sendFileMessage()`.

```swift
var filePath = "file_path_of_image"
var fileName = "file_name"
meeting.chat.sendFileMessage(filePath, fileName)
meeting.chat.meeting.chat.sendFileMessage(fileURL: url) { err in
// Handle error if any
}
```

## Chat Errors

The `sendTextMessage` method returns a `ChatTextError` if the operation fails, `null` if successful. The error can be the following:

- `PermissionDenied`: The user does not have permission to send a message.
- `MessageIsBlank`: The message is empty.
- `CharacterLimitExceeded`: The message exceeds the character limit. Default limit is 2000 characters.
- `RateLimitBreached`: The user has sent too many messages in a short period of time.

Both `sendImageMessage` and `sendFileMessage` methods accept a callback function that will be called with a `ChatFileError` if the operation is not successful, otherwise with `null` if successful.

Possible `ChatFileError`s are:

- `FileFormatNotAllowed`: The file format is not allowed.
- `PermissionDenied`: The user does not have permission to send a file.
- `RateLimitBreached`: The user has breached the rate limit for sending messages.
- `ReadFailed`: The file could not be read.
- `UploadFailed`: The file could not be uploaded.
55 changes: 22 additions & 33 deletions docs/ios-core/stage-management/1-introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions, and kicking participants from the stage. These APIs are accessible

### Stage Status

In meetings where stage management is enabled, a user's stage status can change within the values represented by the `DyteStageStatus`
In meetings where stage management is enabled, a user's stage status can change within the values represented by the `StageStatus`
enum. These status values include:

- `ON_STAGE`: Indicates that the user is currently on the stage and is allowed to publish media.
Expand All @@ -32,12 +32,12 @@ enum. These status values include:
- `REJECTED_TO_JOIN_STAGE`: Indicates that the host has rejected the user's request to join the stage. The user can request again
to join from this status.

The `meeting.stage.status` property provides the current stage status of the local user.
The `meeting.stage.stageStatus` property provides the current stage status of the local user.

### Viewers

You can retrieve a list of off-stage participants (viewers) in a stage-enabled meeting by accessing the `meeting.stage.viewers`
property. This property provides a list of `DyteJoinedMeetingParticipant` objects whose stage status is not `ON_STAGE`.
property. This property provides a list of `DyteRemoteParticipant` objects whose stage status is not `ON_STAGE`.

### Joining the Stage

Expand All @@ -64,60 +64,49 @@ stage-related events in your application:

```swift
extension WebinarViewModel: DyteStageEventListener {
func onPresentRequestReceived() {
// Called when the local user's stage access request is accepted by the host,
// or when the local user, who is a viewer, is invited to the stage by the host.
func onStageAccessRequestAccepted() {
// Called when the local user is accepted to join the stage.
}

func onAddedToStage() {
// Called when the local user successfully joins the stage.
func onStageAccessRequestRejected() {
// Called when the local user's request to join the stage is rejected by the host.
}

func onRemovedFromStage() {
// Called when the local user is removed from the stage.
}

func onPresentRequestAdded(participant: DyteJoinedMeetingParticipant) {
// Called when a participant requests to join the stage. Triggered only if the local user is a host.
}

func onPresentRequestClosed(participant: DyteJoinedMeetingParticipant) {
// Called when a participant with a pending stage access request leaves the meeting.
func onNewStageAccessRequest(participant: DyteRemoteParticipant) {
// Called when a new stage access request is received from a participant.
// Triggered only if the local user is a host.
}

func onPresentRequestRejected(participant: DyteJoinedMeetingParticipant) {
// Called when a participant's stage access request is denied by the host.
// Triggered only if the local user is a host.
}

func onPresentRequestWithdrawn(participant: DyteJoinedMeetingParticipant) {
func onStageAccessRequestsUpdated(participant: DyteJoinedMeetingParticipant) {
// Called when a participant cancels their stage access request.
// Triggered only if the local user is a host.
}

func onParticipantRemovedFromStage(participant: DyteJoinedMeetingParticipant) {
// Called when a participant is removed from the stage by the host.
}

func onStageRequestsUpdated(accessRequests: [DyteJoinedMeetingParticipant]) {
func onStageAccessRequestsUpdated(accessRequests: [DyteRemoteParticipant]) {
// Called when the list of stage access requests is updated.
}

func onParticipantStartedPresenting(participant: DyteJoinedMeetingParticipant) {
// Called when a participant joins the stage.
}

func onParticipantStoppedPresenting(participant: DyteJoinedMeetingParticipant) {
// Called when a participant leaves the stage.
func onStageStatusUpdated(oldStatus: DyteiOSCore.StageStatus, newStatus: DyteiOSCore.StageStatus) {
// Called when the local user's stage status is updated.
}

func onStageStatusUpdated(stageStatus: DyteStageStatus) {
// Called when the local user's stage status is updated.
func onPeerStageStatusUpdated(participant: DyteRemoteParticipant, oldStatus: DyteiOSCore.StageStatus, newStatus: DyteiOSCore.StageStatus) {
// Called when a remote participant's stage status is updated.
}
}
```

All the stage management APIs return a `StageError` if the operation fails. On success, they return `null`. The error type can be one of the following:

- `StageDisabledForMeetingType`: The meeting type does not support stage management.
- `PermissionDenied`: The user does not have the required permissions to perform the operation.
- `ActionInvalidForStageStatus`: The operation is invalid for the current stage status.
- `NoRequestToCancel`: There is no pending request to cancel.

Next, we'll explore the Stage Management APIs for hosts, allowing them to manage stage requests, participants in Dyte meetings.

<head>
Expand Down
42 changes: 14 additions & 28 deletions docs/ios-core/stage-management/2-host-controls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,41 @@ tags:
- stage
---

In a stage management-enabled meeting, a user with the `selfPermissions.host.canAcceptStageRequests` permission as `true` is
In a stage management-enabled meeting, a user with the `permissions.host.canAcceptStageRequests` permission as `true` is
considered a host. The `meeting.stage` object in Dyte's iOS Core SDK provides stage management APIs that allow hosts to
manage stage access requests, invite participants to the stage, and remove participants from the stage.

### List of Stage Access Requests

You can retrieve the list of pending stage access requests by accessing the `meeting.stage.accessRequests` property. This property
provides a list of `DyteJoinedMeetingParticipant` objects who have requested stage access.
provides a list of `DyteRemoteParticipant` objects who have requested stage access.

**Note**: If the local user is not a host, this property returns an empty list.

### Grant Access

To accept stage access requests or allow a participant directly to the stage, you can use the `grantAccess()` method.
Alternatively, the `grantAccessAll()` method can be used to grant stage access to all participants with pending stage access requests.

```swift
// Grants stage access to a participant
// id: peer id of the stage access requesting participant
meeting.stage.grantAccess(id)
// userId: peer id of the stage access requesting participant
meeting.stage.grantAccess(userIds: [userId])

// Grants stage access to all participants with pending stage access requests
meeting.stage.grantAccessAll()
meeting.stage.grantAccess(userIds: mobileClient.stage.accessRequests.map { return $0.userId })
```

### Deny Access

To reject stage access requests, you can use the `denyAccess()` method. Similarly, the `denyAccessAll()` method can be used to
deny all pending stage access requests.
To reject stage access requests, you can use the `denyAccess()` method.

```swift
// Denies stage access request of a participant
// id: peer id of the stage access requesting participant
meeting.stage.denyAccess(id)
// userId: peer id of the stage access requesting participant
meeting.stage.denyAccess(userIds: [userId])

// Denies all pending stage access requests
meeting.stage.denyAccessAll()
meeting.stage.denyAccess(userIds: mobileClient.stage.accessRequests.map { return $0.userId })
```

### Kick Users
Expand All @@ -53,7 +51,7 @@ You can remove a participant from the stage by using the `kick()` method.
```swift
// Kicks a participant from stage
// id: peer id of the ON_STAGE participant to kick
meeting.stage.kick(id)
meeting.stage.kick(userIds: [id])
```

### Listening to Stage Access Requests
Expand All @@ -63,24 +61,12 @@ following callbacks to `DyteStageEventListener`:

```swift
extension WebinarViewModel: DyteStageEventListener {
func onPresentRequestAdded(participant: DyteStageParticipant) {
// Called when a user is requesting to join the stage
func onNewStageAccessRequest(participant: DyteRemoteParticipant) {
// Called when a new stage access request is received from a participant.
}

func onPresentRequestClosed(participant: DyteStageParticipant) {
// Called when a user who was trying to join the stage leaves the call
}

func onPresentRequestRejected(participant: DyteStageParticipant) {
// Called when a join stage request is denied by the host
}

func onPresentRequestWithdrawn(participant: DyteStageParticipant) {
// Called when a user who was trying to join the stage withdraws their request to join
}

func onStageRequestsUpdated(accessRequests: [DyteJoinedMeetingParticipant]) {
// Called when the access requests list is updated
func onStageAccessRequestsUpdated(accessRequests: [DyteRemoteParticipant]) {
// Called when the list of stage access requests is updated.
}
}
```
Expand Down
8 changes: 6 additions & 2 deletions docs/ios-core/stage-management/3-viewer-participants.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ meeting.stage.requestAccess()
```

When a host accepts the user's stage access request or allows the user directly to the stage, the SDK triggers the
`onPresentRequestReceived` callback in `DyteStageEventListener`. You can listen to this event:
`onStageAccessRequestAccepted` callback and if the host rejects the request, the SDK triggers the `onStageAccessRequestRejected` callback. You can listen to these events by adding a `DyteStageEventListener`:

```swift
extension WebinarViewModel: DyteStageEventListener {
func onPresentRequestReceived() {
func onStageAccessRequestAccepted() {
// Host accepted the join stage request or invited user directly to stage
}

func onStageAccessRequestRejected() {
// Host rejected the join stage request
}
}
```

Expand Down

0 comments on commit 45a17e7

Please sign in to comment.