Skip to content

Commit

Permalink
Merge pull request #416 from dyte-io/sg/ios-core-v2
Browse files Browse the repository at this point in the history
docs: started updating ios-core docs for v2
  • Loading branch information
harshs-dyte authored Feb 6, 2025
2 parents ac4a857 + 45a17e7 commit 7b2f619
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 127 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.
4 changes: 2 additions & 2 deletions docs/ios-core/local-user/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Triggered when the user starts / stops the video using `enableVideo` or

```swift
extension MeetingViewModel: DyteSelfEventsListener {
func onVideoUpdate(videoEnabled: Bool) {
func onVideoUpdate(isEnabled: Bool) {
if (videoEnabled) {
// video is enabled, and other participants in room can see local user
} else {
Expand All @@ -41,7 +41,7 @@ Triggered when the user starts / stops the audio using `enableAudio` or
```swift

extension MeetingViewModel: DyteSelfEventsListener {
func onAudioUpdate(audioEnabled: Bool) {
func onAudioUpdate(isEnabled: Bool) {
if (audioEnabled) {
// audio is enabled, and other participants in room can hear local user
} else {
Expand Down
17 changes: 14 additions & 3 deletions docs/ios-core/local-user/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Here is a list of properties that `meeting.localUser` user provides:

- `id`: The ID of the participant pertaining to local user.
- `name`: Contains Name of the local user.
- `clientSpecificId`: Identifier provided by the developer while adding the
- `customParticipantId`: Identifier provided by the developer while adding the
participant.
- `permissions`: The permissions related to various capabilities within a
meeting context for the local user.
Expand Down Expand Up @@ -63,8 +63,19 @@ initialization process. You can setup the audio and video tracks by simply
calling `enableAudio()` and `enableVideo()` like below:

```swift
meeting.localUser.enableAudio()
meeting.localUser.enableVideo()
meeting.localUser.enableAudio{ err in
if let error = err {
print("Error enabling audio: \(error)")
}
}
```

```swift
meeting.localUser.enableVideo{ err in
if let error = err {
print("Error enabling video: \(error)")
}
}
```

## Change the name of the local user
Expand Down
54 changes: 27 additions & 27 deletions docs/ios-core/participants/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ tags:
# All Participant Events

You can subscribe to events for all participants by implementing
`DyteParticipantEventsListener` protocol and then passing that object to
`meeting.addParticipantEventsListener(dyteParticipantEventsListener)` method.
`DyteParticipantsEventListener` protocol and then passing that object to
`meeting.addParticipantsEventListener(dyteParticipantEventsListener)` method.

Here are the supported methods:

Expand All @@ -23,8 +23,8 @@ Here are the supported methods:
Triggers an event when any participant joins the meeting.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onParticipantJoin(participant: DyteMeetingParticipant) {
extension MeetingViewModel: DyteParticipantsEventListener {
func onParticipantJoin(participant: DyteRemoteParticipant) {
// your code here to handle new participant
}
}
Expand All @@ -35,8 +35,8 @@ Triggers an event when any participant joins the meeting.
Triggers an event when any participant leaves the meeting.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onParticipantLeave(participant: DyteMeetingParticipant) {
extension MeetingViewModel: DyteParticipantsEventListener {
func onParticipantLeave(participant: DyteRemoteParticipant) {
// your code here to handle participant left from meeting
}
}
Expand All @@ -47,7 +47,7 @@ Triggers an event when any participant leaves the meeting.
Triggers an event whenever there is any change in participant.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
extension MeetingViewModel: DyteParticipantsEventListener {
func onUpdate(participants: DyteParticipants) {
// your code here to handle participant update
}
Expand All @@ -59,8 +59,8 @@ Triggers an event whenever there is any change in participant.
Trigger an event when any participant starts / stops video.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onVideoUpdate(videoEnabled: Bool, participant: DyteMeetingParticipant) {
extension MeetingViewModel: DyteParticipantsEventListener {
func onVideoUpdate(participant: DyteRemoteParticipant, isEnabled: Bool) {
// your code here to handle participant video toggle update
}
}
Expand All @@ -71,8 +71,8 @@ Trigger an event when any participant starts / stops video.
Trigger an event when any participant starts / stops audio.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onAudioUpdate(audioEnabled: Bool, participant: DyteMeetingParticipant) {
extension MeetingViewModel: DyteParticipantsEventListener {
func onAudioUpdate(participant: DyteRemoteParticipant, isEnabled: Bool) {
// your code here to handle participant audio toggle update
}
}
Expand All @@ -83,17 +83,17 @@ Trigger an event when any participant starts / stops audio.
Triggers an event when there is any change in screenshares in a meeting.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onScreenSharesUpdated() {
extension MeetingViewModel: DyteParticipantsEventListener {
func onScreenShareUpdate(participant: DyteRemoteParticipant, isEnabled: Bool) {
// your code here to handle screenshares from meeting
// you can use `meeting.participants.screenshares` to get latest screenshare participants
}

func onScreenShareStarted(participant: DyteJoinedMeetingParticipant) {
func onScreenShareStarted(participant: DyteRemoteParticipant) {
// participant stared presenting screen in the meeting
}

func onScreenShareEnded(participant: DyteJoinedMeetingParticipant) {
func onScreenShareEnded(participant: DyteRemoteParticipant) {
// participant stopped presenting screen in the meeting
}
}
Expand All @@ -104,8 +104,8 @@ Triggers an event when there is any change in screenshares in a meeting.
Triggers an event when any is change in active speaker in the meeting.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onActiveSpeakerChanged(participant: DyteMeetingParticipant) {
extension MeetingViewModel: DyteParticipantsEventListener {
func onActiveSpeakerChanged(participant: DyteRemoteParticipant?) {
// your code here to handle active speaker
}

Expand All @@ -120,12 +120,12 @@ Triggers an event when any is change in active speaker in the meeting.
Triggers an event when there is any change in pinned participant in the meeting.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onParticipantPinned(participant: DyteMeetingParticipant) {
extension MeetingViewModel: DyteParticipantsEventListener {
func onParticipantPinned(participant: DyteRemoteParticipant) {
// your code here to show pinned participant
}

func onParticipantUnpinned(participant: DyteJoinedMeetingParticipant) {
func onParticipantUnpinned(participant: DyteRemoteParticipant) {
// your code here to remove pinned participant
}
}
Expand All @@ -136,8 +136,8 @@ Triggers an event when there is any change in pinned participant in the meeting.
Triggers an event when any is change in active participants list in the meeting.

```swift
extension MeetingViewModel: DyteParticipantEventsListener {
func onActiveParticipantsChanged(active: [DyteMeetingParticipant]) {
extension MeetingViewModel: DyteParticipantsEventListener {
func onActiveParticipantsChanged(active: [DyteRemoteParticipant]) {
// your code here to refresh active participants
}
}
Expand All @@ -155,7 +155,7 @@ Triggers an event whenever there is any change in participant.

```swift
extension MeetingViewModel: DyteParticipantUpdateListener {
func onUpdate() {
func onUpdate(participant: DyteMeetingParticipant) {
// your code here to handle participant update
}
}
Expand Down Expand Up @@ -191,11 +191,11 @@ Triggers an event when the participant is pinned / unpinned.

```swift
extension MeetingViewModel: DyteParticipantUpdateListener {
func onPinned() {
func onPinned(participant: DyteRemoteParticipant) {
// your code here to show pinned participant
}

func onUnpinned() {
func onUnpinned(participant: DyteRemoteParticipant) {
// your code here to remove pinned participant
}
}
Expand All @@ -207,11 +207,11 @@ Triggers an event when the participant starts / stops screen sharing.

```swift
extension MeetingViewModel: DyteParticipantUpdateListener {
func onScreenShareStarted() {
func onScreenShareStarted(participant: DyteRemoteParticipant) {
// your code here to handle screen share started
}

func onScreenShareEnded() {
func onScreenShareEnded(participant: DyteRemoteParticipant) {
// your code here to handle screen share ended
}
}
Expand Down
5 changes: 3 additions & 2 deletions docs/ios-core/participants/participant-object.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The participant object has the following properties.
- `userId`: The `userId` of the participant.
- `name`: The participant's name.
- `picture`: The participant's picture (if any).
- `clientSpecificId`: An arbitrary ID that can be set to identify the
- `customParticipantId`: An arbitrary ID that can be set to identify the
participant.
- `videoTrack`: The video track of the participant.
- `screenShareTrack`: The video and audio (if any) track of the participant's
Expand All @@ -27,14 +27,15 @@ The participant object has the following properties.
- `audioEnabled`: Set to true if the participant is unmuted.
- `isPinned`: True if current user is pinned in the meeting room.
- `presetName`: Name of the preset associated with the participant.
- `presetInfo` : A typed object representing the preset information for local user.
- `stageStatus`: Status of stage for the participant

## To get video view of a given participant

You can call `participant.getVideoView()` which will return a View which further
can used to add in any view.

Similarly one can use `participant.getScreenShareView()` which will return a
Similarly one can use `participant.getScreenShareVideoView()` which will return a
View which further can used to add in any view.

## Host Controls
Expand Down
5 changes: 2 additions & 3 deletions docs/ios-core/participants/remote-participants.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The data regarding all meeting participants is stored under `meeting.participant

```swift
// get all joined participants
var joined: [DyteJoinedMeetingParticipant] = meeting.participants.joined
var joined: [DyteRemoteParticipant] = meeting.participants.joined

// get all participants
var all: [DyteParticipant] = meeting.participants.all
Expand All @@ -27,14 +27,13 @@ The `meeting.participants` object has the following **lists** of participants
except the local user
- **waitlisted**: A list that contains all the participants waiting to join the
meeting.
- **active**: A list that contains all the participants except the local user whose media is subscribed to i.e
- **active**: A list that contains all the participants including the local user whose media is subscribed to i.e
participants are supposed to be on the screen at the moment except the local user
- **pinned**: A list that contains all the pinned participants of the meeting.
- **screenShares**: A list that contains all the participants who are sharing their screen.

Therefore if you were to make a video / audio grid of participants, you'd use the `active` map, but to display the list of all participants in the meeting you'd use the `joined` map.

Each participant in each of the `joined`, `active`, `pinned` and `screenShares` list are of type `DyteJoinedMeetingParticipant`, `waitlisted` list is of type `DyteWaitlistedParticipant` and `all` list is of type `DyteParticipant`.

<head>
<title>iOS Core Participants</title>
Expand Down
Loading

0 comments on commit 7b2f619

Please sign in to comment.