Podfile
文件中添加 pod 'TUILiveKit'
依赖,如果您遇到任何问题,请参见 Example 工程。target 'xxxx' do......pod 'TUILiveKit'end
Podfile
文件,首先终端cd
到xxxx.xcodeproj
目录,然后通过以下命令创建:pod init
cd
到Podfile
目录下,然后执行以下命令,安装组件。pod install
pod repo update
pod update
<key>NSCameraUsageDescription</key><string>TUILiveKit需要访问你的相机权限,开启后录制的视频才会有画面</string><key>NSMicrophoneUsageDescription</key><string>TUILiveKit需要访问您的麦克风权限,开启后录制的视频才会有声音</string>
//// AppDelegate.swift//import TUICorefunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {TUILogin.login(1400000001, // 请替换为步骤一取到的 SDKAppIDuserID: "denny", // 请替换为您的 UserIDuserSig: "xxxxxxxxxxx") { // 您可以在控制台中计算一个 UserSig 并填在这个位置print("login success")} fail: { (code, message) inprint("login failed, code: \\(code), error: \\(message ?? "nil")")}return true}
//// MainViewController.swift//import UIKitimport TUILiveKit@objc private func buttonTapped(_ sender: UIButton) {//RoomId可以自定义生成, 建议使用 LiveIdentityGenerator.shared.generateId(TUILogin.getUserID() ?? "", .live)String roomId = "123666";// 进入直播预览画面let viewController = TUILiveRoomAnchorViewController(roomId: roomId)self.navigationController?.pushViewController(viewController, animated: true)}
![]() 视频直播预览画面 | ![]() 视频直播中画面 |
//// MainViewController.swift//import UIKitimport TUILiveKit@objc private func buttonTapped(_ sender: UIButton) {// 进入房间列表let liveListViewController = TUILiveListViewController()self.navigationController?.pushViewController(viewController, animated: true)}
![]() 视频直播间 | ![]() 视频直播间 |
本页内容是否解决了您的问题?