Methods
Methods
info
To be able to use the methods that will be explained below you have to initialize the SDK and do the authentication before.
Professional List
- You have to instantiate the class MDConsultationMainViewController() and call the method consultationViewController, this method will return you the raw data of the professional list.
public static func consultationViewController(
filter: any MeetingDoctorsFilterType = MeetingDoctorsFilter.default,
showHeader: Bool = true,
divider: (any MeetingDoctorsDividerType)? = nil,
topDividers: [any MeetingDoctorsDividerType]? = []
) throws -> UIViewController
Chat
- The public class Chat() has available the methods to join a room, get the professional detail, fetch messages, send messages, photos, videos and documents, delete messages and leave the room.
Fetch professional detail
- You have to pass the professional hash as a parameter of the function and this method will return the Contact Schema of the professional. Moreover this class will save the professional hash as a class property.
public func fetchProfessionalDetail(from id: String,
_ completion: @escaping (Swift.Result<ContactSchema, Error>) -> Void)
Join room
- You have to pass the professional hash as a parameter of the function and this method will return the room id of the conversation. Moreover this class will save the room id as a class property.
public func joinRoom(with id: String,
_ completion: @escaping (Int) -> Void)
Fetch messages
- You don't need to pass any parameter to the function and this method will return the array of messages that the room has. The type of the array of messages returned will be MessageModel.
public func fetchMessages(
completion: @escaping @Sendable(Swift.Result<([MessageModel], Changeset?), any Error>
) -> Void)
Send message
- You have to pass the professional speciality and the text of the message as a parameter of the function and this method will warn you when the message is sent.
public func sendMessage(professionalSpeciality: String, message text: String, completion: (() -> Void)? = nil)
Send image
- You have to pass the url of the image and the image itself (UIImage) as a parameter of the function and this method will warn you when the image is sent.
public func sendImage(withURL url: URL, image: UIImage, completion: (() -> Void)? = nil)
Send document
- You have to pass the url of the document as a parameter of the function and this method will warn you when the document is sent.
public func sendDocument(withURL url: URL, completion: (() -> Void)? = nil)
Send video
- You have to pass the name of the video and its url as a parameter of the function and this method will warn you when the video is sent.
public func sendVideo(withName name: String, withURL url: URL, completion: (() -> Void)? = nil)
Leave room
- This method has to be used to leave the room and it will send a Notification Center event that is written below.
public func leaveRoom()
- Notification Center event (ChatLeft)
NotificationCenter.default.post(name: Notification.Name.MeetingDoctors.Messenger.ChatLeft, object: nil, userInfo: nil)