你可以通过阅读密钥说明了解更多 Token 相关。
本文操作步骤和示例图以 Xcode 13.1 为例。
iOS 9.0 或以上版本的设备。
使用 Objective-C 作为开发语言。
请确保您的项目已设置有效的开发者签名。
已获取 Whiteboard SDK。
打开 Xcode, 点击 File > New > Project。
选择 iOS > App , 点击 Next。

输入项目名称、团队名称、选择开发语言,点击 Next。

选择项目存储位置,点击 Create。
签名设置:进入 TARGETS > Project Name > Signing & Capabilities。勾选 Automatically manage signing, 并在弹出菜单中选择 Enable Automatic。

根据场景需要,为你的项目创建互动白板的用户界面。
为实现基本的白板功能,我们建议在项目中添加如下视图或元素:
选择模式按钮
调节图形(直线、圆、矩形、箭头)格式的面板按钮
橡皮擦按钮
清空白板按钮
下课按钮
退出房间按钮
platform :ios, '9.0'
source 'https://github.com/volcengine/volcengine-specs.git'
target '你的项目名字' do
pod 'VolcEngineWhiteboard', '1.3.0'
end
spec.dependency 'VolcEngineWhiteboard', '1.3.0'
在调用了白板 SDK API 的文件中引入头文件。
//引入 头文件
#import "WhiteBoard/ByteWhiteBoardRoomManager.h"
#import "WhiteBoard/ByteWhiteBoardRoom.h"
#import "WhiteBoard/ByteWhiteBoard.h"
objectivec
@property (nonatomic, strong) ByteWhiteBoardRoomManager * boardRoomManager;
@property (nonatomic, strong) ByteWhiteBoardRoom * boardRoom;
@property (nonatomic, strong) ByteWhiteBoard * board;
objectivecByteWhiteBoardRoomManager 中的方法绑定设备信息和环境。+ (void)setDeviceID:(NSString*)deviceID; // 指定设备 ID,方便定位和排查问题
+ (void)setACacheLocatidon:(NSString*)paith; // 设置 SDK 数据缓存路径
+ (void)setELogLocationv:(ByteWhiNSSteBoardEinvg*)envpath; // 设置 SDK 本地日志缓存路径
objectivec+ (instancetype)sharedEngineWithAppId:(NSString *)appId delegate:(id<ByteWhiteBoardRoomManagerDelegate>)delegate;
objectivec参考 开通服务 获取 AppID。
4. 调用 createWhiteBoardRoom:userID:token:delegate: 创建白板房间。
- (ByteWhiteBoardRoom *)createWhiteBoardRoom:(NSString *)roomID userID:(NSString*)userID token:(NSString*)token delegate:(id<ByteWhiteBoardRoomDelegate>)delegate;
objectivecroomID 不能与 RTC 房间 roomID 相同。以免影响白板房间和 RTC 房间内回调提醒相互影响。建议为白板房间名加上 whiteboard_ 前缀。userID 不能与 RTC userID 相同。id<ByteWhiteBoardRoomDelegate>)delegate 为白板 ViewController,继承了 ByteWhiteBoardRoomDelegate 协议。使用刚创建的 ByteWhiteBoardRoom 进入房间。
- (void)joinRoom;
objectivec白板服务在当前用户加入白板房间后开始计费,直到该用户调用 leaveRoom 退出房间后停止计费。建议在即将使用白板前创建白板实例。并结束使用后及时销毁白板实例。
加入房间后,SDK 将通过 ByteWhiteBoardRoomDelegate 的 onGetAllBoardInfo 回调所有白板的信息、当前活跃的白板 ID、当前房间是否活跃,请及时保存需要的信息。
如果房间内白板数量为 0,需要通过 ByteWhiteBoardRoom 的createWhiteBoard 方法创建第一个白板。
- (void)byteWhiteBoardRoom:(ByteWhiteBoardRoom *)boardRoom onGetAllBoardInfo:(NSArray<ByteWhiteBoardInfo *> * )boardArray currentBoard:(NSInteger) activeBoardId roomActive:(BOOL)isRoomActive {
self.isRoomActive = isRoomActive;
if (boardArray.count == 0) {
[self.boardRoom createWhiteBoard:888 pageInfo:[NSArray array] backgroundInfo:[[ByteWhiteBoardBackgroundInfo alloc]init] boardNmae:@"default"];
}
}
objectivec成功进入房间后,SDK 将通过 byteWhiteBoardRoom:onWhiteBoardCreated:elapsed: 回调通知白板创建完毕。
- (void)byteWhiteBoardRoom:(ByteWhiteBoardRoom *)boardRoom onWhiteBoardCreated:(ByteWhiteBoard *)board elapsed:(NSInteger)elapsed;
objectivec在这个回调中,调用 bindToWindow 将白板绑定到一个视图上。
绑定后,白板会填满绑定的 UI 控件。根据业务的需求指定 UI 控件尺寸和比例。注意,各端的 UI 比例必须保持一致,否则将导致各端显示效果有差异。例如,老师端和学生端白板都是固定 4:3 比例。
{
self.board = board;//很重要,给你刚刚创建的WhiteBoard属性初始化
[self.board updateByteWhiteBoardDelegate:self];
[self.board bindToWindow:self.view];//调用本接口后才能进行图形有关设置。只能被调用一次,重复绑定将使多个 View 叠加。
//设置笔迹格式
[self.board setPenSize:70];// 所有 size 的单位都是 View 宽度的万分之一
[self.board setPenColor:[UIColor redColor]];
[self.board setEditType:ByteWhiteBoardShapeTypePen];
[self.board setEditMode:ByteWhiteBoardEditModeEditAll];//当前白板允许所有用户编辑。ByteWhiteBoardEditModeReadOnly 是只读
}
objectivec至此,我们实现了互动白板的基础功能。
在结束白板使用时,释放资源的步骤如下。
ByteWhiteBoardRoom 的 leaveRoom 离开房间,结束通话过程,释放所有通话相关的资源。byteWhiteBoardRoom:onLeaveRoomResult:reason: 回调通知。- (void)leaveRoom;
objectivecdestroyWhiteBoard 销毁白板对象。- (int)destroyWhiteBoard:(ByteWhiteBoard *)board;
objectivecByteWhiteBoardRoomManager 的 destory 释放资源。[ByteWhiteBoardRoomManager destroy];
objectivec默认路径为:
日志目录:AppData/Library/Caches/Logs
回放文件目录:AppData/Library/Caches
你可以调用 setLogLocation: 和 setCacheLocation: 自定义日志和缓存文件路径。
bitcode_strip ****/byteaudio.framework/byteaudio: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip exited with 1
解决方法:
关闭 bitcode:自定义环境设置 STRIP_BITCODE_FROM_COPIED_FILES = NO
'***/WhiteBoardDemo/Lib/WhiteBoard.framework/WhiteBoard' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '***/WhiteBoardDemo/Lib/WhiteBoard.framework/WhiteBoard' for architecture arm64
解决方法:
设置 target 的 Enable BitCode 字段为 NO。