pod 'TUILiveKit'
dependency to your Podfile
file and refer to the Example project if you run into any problems.target 'xxxx' do......pod 'TUILiveKit'end
Podfile
file, first terminal cd
into the xxxx.xcodeproj
directory and then create it with the following command:pod init
cd
to the Podfile
directory, and then run the following command to install the component.pod install
TUILiveKit
cannot be installed, You can delete Podfile.lock and Pods first。Then update the CocoaPods repository list locally by executing the following command.pod repo update
pod update
<key>NSCameraUsageDescription</key><string>TUILiveKit needs access to your camera to capture video.</string><key>NSMicrophoneUsageDescription</key><string>TUILiveKit needs access to your mic to capture audio.</string>
//// AppDelegate.swift//import TUICorefunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {TUILogin.login(1400000001, // Replace it with the SDKAppID obtained in Step 1userID: "denny", // Please replace it with your UserIDuserSig: "xxxxxxxxxxx") { // You can calculate a UserSig in the console and fill it inprint("login success")} fail: { (code, message) inprint("login failed, code: \\(code), error: \\(message ?? "nil")")}return true}
//// AppDelegate.m//#import <TUICore/TUILogin.h>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[TUILogin login:1400000001 // Replace it with the SDKAppID obtained in Step 1userID:@"denny" // Please replace it with your UserIDuserSig:@"xxxxxxxxxxx" // You can calculate a UserSig in the console and fill it insucc:^{NSLog(@"login success");} fail:^(int code, NSString * _Nullable msg) {NSLog(@"login failed, code: %d, error: %@", code, msg);}];return YES;}
SDKSecretKey
to encrypt the information such as SDKAppID
and UserID
. You can generate a temporary UserSig
by clicking the UserSig Generate button in the console.genTestUserSig
function to calculate UserSig
locally, so as to help you complete the current integration process more quickly. However, this scheme exposes your SecretKey
in the application code, which makes it difficult for you to upgrade and protect your SecretKey
subsequently. Therefore, we strongly recommend you run the UserSig
calculation logic on the server and make the application request the UserSig
calculated in real time every time the application uses the TUILiveKit
component from the server.//// MainViewController.swift//import UIKitimport TUILiveKit@objc private func buttonTapped(_ sender: UIButton) {// RoomId can be custom generated,Recommended use LiveIdentityGenerator.shared.generateId(TUILogin.getUserID() ?? "", type: .voice)let roomId = "123666";// Enter the voice chat room preview screenvar roomParams = RoomParams()//The default value is the maximum number of seat supported by the packageroomParams.maxSeatCount = 0roomParams.seatMode = .applyToTakelet voiceRoomController = TUIVoiceRoomViewController(roomId: roomId, behavior: .prepareCreate, roomParams: roomParams)self.navigationController?.pushViewController(voiceRoomController, animated: true)}
//// MainViewController.m//#import <TUILiveKit/TUILiveKit-Swift.h>#import <RTCRoomEngine/RTCEngine.h>- (void)buttonTapped:(UIButton *)sender {// RoomId can be custom generated, Recommended use [LiveIdentityGenerator.shared generateId:[TUILogin getUserID] type: RoomTypeVoice];NSString *roomId = @"123666";// Enter the voice chat room preview screenRoomParams *roomParams = [[RoomParams alloc] initWithMaxSeatCount:0 //The default value is the maximum number of seat supported by the packageseatMode:TUISeatModeApplyToTake];TUIVoiceRoomViewController *voiceRoomController = [[TUIVoiceRoomViewController alloc] initWithRoomId:roomIdbehavior:RoomBehaviorPrepareCreateroomParams:roomParams];[self.navigationController pushViewController:voiceRoomController animated:true];}
Voice chat room preview screen | Voice chat room in-room screen |
| |
//// MainViewController.swift//import UIKitimport TUILiveKit@objc private func buttonTapped(_ sender: UIButton) {// Enter room listlet liveListViewController = TUILiveListViewController()self.navigationController?.pushViewController(viewController, animated: true)}
//// MainViewController.m//#import <TUILiveKit/TUILiveKit-Swift.h>- (void)buttonTapped:(UIButton *)sender {// Enter room listTUILiveListViewController *liveListViewController = [[TUILiveListViewController alloc] init];[self.navigationController pushViewController:liveListViewController animated:true];}
//// MainViewController.swift//import UIKitimport TUILiveKit@objc private func buttonTapped(_ sender: UIButton) {// RoomId is the room ID for creating a voice chat roomlet roomId = "123666";// Enter the voice chat roomlet viewController = TUIVoiceRoomViewController(roomId: roomId, behavior: .join)self.navigationController?.pushViewController(viewController, animated: true)}
//// MainViewController.swift//#import <TUILiveKit/TUILiveKit-Swift.h>- (void)buttonTapped:(UIButton *)sender {// RoomId is the room ID for creating a voice chat roomNSString *roomId = @"123666";// Enter the voice chat roomTUIVoiceRoomViewController *voiceRoomController = [[TUIVoiceRoomViewController alloc] initWithRoomId:roomIdbehavior:RoomBehaviorJoinroomParams:nil];[self.navigationController pushViewController:voiceRoomController animated:true];}
Voice Chat Room | Voice Chat Room |
| |
Was this page helpful?