agorawhiteboardlibrary_ios.podspec


## AgoraWhiteboardLibrary-iOS


AgoraWhiteboardLibrary-iOS is a powerful real-time whiteboard SDK provided by Agora.io. It enables developers to integrate collaborative whiteboard capabilities into their iOS applications effortlessly.


### Installation


You can install AgoraWhiteboardLibrary-iOS by using CocoaPods. To add this SDK to your project, include the following line in your `Podfile`:


“`ruby
pod ‘AgoraWhiteboardLibrary-iOS’
“`


Then, run the following command in the terminal:


“`bash
pod install
“`


### Usage


#### Importing


To use AgoraWhiteboardLibrary-iOS in your project, import the following module:


“`swift
import AgoraWhiteboardLibrary
“`


#### Initialization


To use the Agora Whiteboard SDK, initialize the `WhiteboardKit` class. Ensure that you have obtained an Agora App ID and a token, which are required for initializing the SDK.


“`swift
let appId = “YOUR_APP_ID”
let token = “YOUR_TOKEN”
let whiteboardKit = WhiteboardKit()
whiteboardKit.initialize(appId: appId, token: token)
“`


#### Joining a Whiteboard


Use the `joinWhiteboard` method to join a specific whiteboard room.


“`swift
whiteboardKit.joinWhiteboard(roomUUID: “YOUR_ROOM_UUID”) { success, errorCode in
if success {
// Whiteboard joined successfully
} else {
// Failed to join whiteboard, handle the error
print(“Failed to join whiteboard: \(errorCode)”)
}
}
“`


#### Leaving a Whiteboard


When you no longer need to use a whiteboard, leave the room using the `leaveWhiteboard` method.


“`swift
whiteboardKit.leaveWhiteboard { success, errorCode in
if success {
// Whiteboard left successfully
} else {
// Failed to leave whiteboard, handle the error
print(“Failed to leave whiteboard: \(errorCode)”)
}
}
“`


#### Whiteboard Delegate


To receive whiteboard events and data, conform to the `WhiteboardDelegate` protocol and implement the required methods. The delegate methods will be called when various events occur during the whiteboard session.


“`swift
class MyWhiteboardDelegate: WhiteboardDelegate {
func onJoinRoomSucess() {
// Whiteboard room joined successfully
}

func onLeaveRoom() {
// Whiteboard room left successfully
}

// Implement other required whiteboard delegate methods…

}

// Set the delegate
whiteboardKit.whiteboardDelegate = MyWhiteboardDelegate()
“`


### API Reference


#### Class


##### WhiteboardKit


`WhiteboardKit` is the main class of AgoraWhiteboardLibrary-iOS. It provides methods for initializing and managing whiteboard sessions.


##### WhiteboardDelegate


`WhiteboardDelegate` is a protocol that defines methods to handle whiteboard events. Implement this protocol to receive whiteboard-related callbacks.


#### Methods


##### initialize(appId:token:)


Initialize the Agora Whiteboard SDK with your App ID and token.


“`swift
func initialize(appId: String, token: String)
“`


– `appId`: The App ID obtained from the Agora Developer Console.
– `token`: The token generated to authenticate the user’s access permissions.


##### joinWhiteboard(roomUUID:completion:)


Join a specific whiteboard room.


“`swift
func joinWhiteboard(roomUUID: String, completion: @escaping (Bool, Int) -> Void)
“`


– `roomUUID`: The UUID (Universally Unique Identifier) of the whiteboard room to join.
– `completion`: A completion closure that is called when the operation is completed. It returns a boolean indicating success or failure, and an error code if the operation fails.


##### leaveWhiteboard(completion:)


Leave the current whiteboard room.


“`swift
func leaveWhiteboard(completion: @escaping (Bool, Int) -> Void)
“`


– `completion`: A completion closure that is called when the operation is completed. It returns a boolean indicating success or failure, and an error code if the operation fails.