This page provides the Swift API reference for the Agora Fastboard SDK for iOS.
public class func createFastRoom(withFastRoomConfig config: FastRoomConfiguration)
Creates a FastRoom
instance.
Parameters
config
: Configurations for a FastRoom
instance. See FastRoomConfiguration.Returns
The FastRoom
instance when the method call succeeds.
Configurations for a FastRoom
instance.
public init(appIdentifier: String,
roomUUID: String,
roomToken: String,
region: Region,
userUID: String)
FastRoomConfiguration
contains the following properties:
appIdentifier
: String. The App Identifier of your Interactive Whiteboard project issued by Agora. See Get security credentials for your whiteboard project.roomUUID
: String. The room UUID, that is, the unique identifier of a room. See the value of the uuid
parameter in the response body after a successful call of Create a room (POST).roomToken
: String. The room token for user authentication, which can be obtained through one of the following methods:region
: The data center, which must be the same as the data center you chose when creating the whiteboard room. See Region.userUID
: String. The unique identifier of a user in string format. The maximum length is 1,024 bytes. Ensure that userUID
of each user in the same room is unique.Data centers.
Region
has the following enumerators:
CN
: Hangzhou, China, which provides services to areas not covered by other data centers.US
: Silicon Valley, United States, which provides services to North America and South America.SG
: Singapore, which provides services to Singapore, East Asia, and Southeast Asia.IN
: Mumbai, India, which provides services to India.GB
: London, United Kingdom, which provides services to Europe.The FastRoom
class provides methods to manage the whiteboard room.
public func joinRoom(completionHandler: ((Result<WhiteRoom, FastRoomError>)->Void)? = nil)
Joins the whiteboard room.
Note
Call this method after successfully creating the FastRoom
instance.
Parameters
completionHandler
: The callback that reports the call results. Passing in nil
means not registering the callback.public func disconnectRoom()
Leaves the whiteboard room.
public func insertImg(_ src: URL, imageSize: CGSize)
Inserts an image.
This method inserts and displays a specified online image on the current whiteboard page.
Parameters
src
: String. The URL address of the image. Ensure your app clients can access the URL; otherwise, the image cannot be displayed.imageSizewidth
: CGSize. The size of the image.public func insertMedia(_ src: URL, title: String, completionHandler: ((String)->Void)? = nil)
Inserts and plays audio and video in the whiteboard sub-window.
Parameters
src
: String. The URL address of the audio or video file. Make sure your app clients can access the URL; otherwise, the audio or video file cannot be loaded properly.title
: String. The title of the sub-window.completionHandler
: The callback that reports the call results. Passing in nil
means not registering the callback.public func insertPptx(_ pages: [WhitePptPage],
title: String,
completionHandler: ((String)->Void)? = nil)
Inserts and displays a dynamic document in the whiteboard sub-window.
A dynamic document refers to HTML web pages converted from a PPTX document by using the Agora Interactive Whiteboard file conversion service. The converted files preserve animation effects present in the source document.
After successfully launching a file conversion task and calling the Query file conversion progress (GET) API to get the file conversion result, you can call this method and pass in the obtained file conversion result. After a successful call, the SDK automatically creates a sub-window to insert and display the converted document per page.
Parameters
pages
: The list of converted files. See the convertedFileList
filed in the response body when the call of the Query file conversion progress (GET) API succeeds.title
: The title of the sub-window.completionHandler
: The callback that reports the call results. Passing in nil
means not registering the callback.public func insertStaticDocument(_ pages: [WhitePptPage],
title: String,
completionHandler: ((String)->Void)? = nil)
Inserts and displays a static document in the whiteboard sub-window.
A static document refers to the PNG or JPG/JPEG images converted from a PPT, PPTX, DOC, DOCX, or PDF document by using the Agora Interactive Whiteboard file conversion service.
After successfully launching a file conversion task and calling the Query file conversion progress (GET) API to get the file conversion result, you can call this method and pass in the obtained file conversion result. After a successful call, the SDK automatically creates a sub-window to insert and display the converted document per page.
Parameters
pages
: The list of converted files. See the convertedFileList
filed in the response body when the call of the Query file conversion progress (GET) API succeeds.title
: The title of the sub-window.completionHandler
: The callback that reports the call results. Passing in nil
means not registering the callback.public static var followSystemPencilBehavior
(iPad only) Sets whether the Apple Pencil's behavior follows the system default settings when using the whiteboard:
YES
: Follow the system default settings. In this state, the user can use the system default functions of the Apple Pencil to operate the whiteboard. For example, the user can use their Apple Pencil to draw and sketch, double tap the Apple Pencil to switch between the current tool and eraser, and double tap the Apple Pencil to show the color palette.NO
: Do not follow the system default settings. In this state, the system default functions of the Apple Pencil are disabled for your app.The FastRoomThemeManager
class provides methods to set the theme of the whiteboard user interface.
public func apply(_ theme: FastRoomThemeAsset)
Applies a whiteboard theme.
By default, the Fastboard SDK follows the system theme setting on iOS 13.0 or later, and uses the light theme on versions earlier than iOS 13.0. If the default theme setting does not meet your needs, you can call this method to apply a predefined theme provided by the SDK or a custom theme.
Parameters
theme
: The whiteboard theme.FastRoomDefaultTheme.defaultLightTheme
: The light theme.FastRoomDefaultTheme.defaultDarkTheme
: The dark theme.FastRoomDefaultTheme.defaultAutoTheme
: The automatic theme, that is, following the system theme setting. This option is available only on iOS 13.0 or later.Example
Apply a predefined dark theme:
FastRoomThemeManager.shared.apply(FastRoomDefaultTheme.defaultDarkTheme)
To apply a custom theme:
let white = FastRoomWhiteboardAssets(whiteboardBackgroundColor: .green, containerColor: .yellow)
let control = FastRoomControlBarAssets(backgroundColor: .blue, borderColor: .gray, effectStyle: .init(style: .regular))
let panel = FastRoomPanelItemAssets(normalIconColor: .black, selectedIconColor: .systemRed, highlightBgColor: .cyan, subOpsIndicatorColor: .yellow, pageTextLabelColor: .orange)
let theme = FastRoomThemeAsset(whiteboardAssets: white, controlBarAssets: control, panelItemAssets: panel)
FastRoomThemeManager.shared.apply(theme)
The FastRoomThemeAsset
class provides methods and properties to structure and style a whiteboard user interface theme.
open class FastRoomThemeAsset: NSObject {
@objc
public init(whiteboardAssets: FastRoomWhiteboardAssets,
controlBarAssets: FastRoomControlBarAssets,
panelItemAssets: FastRoomPanelItemAssets) {
self.whiteboardAssets = whiteboardAssets
self.controlBarAssets = controlBarAssets
self.panelItemAssets = panelItemAssets
}
@objc
open var whiteboardAssets: FastRoomWhiteboardAssets
@objc
open var controlBarAssets: FastRoomControlBarAssets
@objc
open var panelItemAssets: FastRoomPanelItemAssets
}
FastRoomThemeAsset
contains the following properties:
whiteboardAssets
: Assets for the whiteboard. See FastRoomWhiteboardAssets.controlBarAssets
: Assets for control bars. See FastRoomControlBarAssets.panelItemAssets
: Assets for buttons. See FastRoomPanelItemAssets.Assets for the Whiteboard.
open class FastRoomWhiteboardAssets: NSObject {
@objc
public init(whiteboardBackgroundColor: UIColor, containerColor: UIColor) {
self.whiteboardBackgroundColor = whiteboardBackgroundColor
self.containerColor = containerColor
}
@objc
open var whiteboardBackgroundColor: UIColor
@objc
open var containerColor: UIColor
}
FastRoomWhiteboardAssets
contains the following properties:
whiteboardBackgroundColor
: The background color of the whiteboard.containerColor
: The color of the HTML container that mounts the whiteboard.Assets for control bars.
open class FastRoomControlBarAssets: NSObject {
@objc
public init(backgroundColor: UIColor, borderColor: UIColor, effectStyle: UIBlurEffect? = nil) {
self.backgroundColor = backgroundColor
self.borderColor = borderColor
self.effectStyle = effectStyle
}
@objc
var backgroundColor: UIColor
@objc
var borderColor: UIColor
@objc
var effectStyle: UIBlurEffect?
}
FastRoomControlBarAssets
contains the following properties:
backgroundColor
: The background color of the control bar.borderColor
: The border color of the control bar.effectStyle
: The blurring effect. See UIBlurEffect for details.Assets for buttons.
open class FastRoomPanelItemAssets: NSObject {
@objc
public init(normalIconColor: UIColor,
selectedIconColor: UIColor,
selectedIconBgColor: UIColor,
highlightColor: UIColor,
highlightBgColor: UIColor,
disableColor: UIColor,
subOpsIndicatorColor: UIColor,
pageTextLabelColor: UIColor) {
self.normalIconColor = normalIconColor
self.selectedIconColor = selectedIconColor
self.selectedIconBgColor = selectedIconBgColor
self.highlightColor = highlightColor
self.highlightBgColor = highlightBgColor
self.disableColor = disableColor
self.subOpsIndicatorColor = subOpsIndicatorColor
self.pageTextLabelColor = pageTextLabelColor
}
@objc
open var normalIconColor: UIColor
@objc
open var selectedIconColor: UIColor
@objc
open var selectedIconBgColor: UIColor
@objc
open var highlightColor: UIColor
@objc
open var highlightBgColor: UIColor
@objc
open var disableColor: UIColor
@objc
open var subOpsIndicatorColor: UIColor
@objc
open var pageTextLabelColor: UIColor
}
FastRoomPanelItemAssets
contains the following properties:
normalIconColor
: The color of the button icon in the normal state, that is, when the button is not selected.selectedIconColor
: The color of the button icon in the selected state.selectedIconBgColor
: The background color of the button in the selected state.highlightColor
: The color of the button icon in the highlighted state, that is, when the button is clicked.highlightBgColor
: The background color of the button in the highlighted state, that is, when the button is clicked.disableColor
: The color of the button in the unclickable state.subOpsIndicatorColor
: The color of the drop-down button.pageTextLabelColor
: The color of the page number.The FastRoomDefaultOperationItem
class provides methods and properties for customizing the operation components on the whiteboard user interface.
public static var defaultColors: [UIColor]
The default color set of the palette.
You can pass a custom [UIColor] object in this property to modify the color set of the palette. The color set of the palette set by using this property applies to tools such as the pencil, text editor, and shape tools.