Host Preview Before Going Live | Host Live Streaming | Audience Viewing | Host and Audience Co-hosting |
![]() | ![]() | ![]() | ![]() |
flutter pub add tencent_live_uikit atomic_x_core
Resolving dependencies...Downloading packages.........+ tencent_live_uikit x.x.x......Changed xx dependencies!xx packages have newer versions incompatible with dependency constraints.Try `flutter pub outdated` for more information.
android/app/build.gradle file:android {......defaultConfig {......// Enable Multidex supportmultiDexEnabled true}buildTypes {release {......// Enable proguard rulesminifyEnabled trueproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}
android/app/proguard-rules.pro file. If the file does not exist, create a new one:-keep class com.tencent.** { *; }
android/app/src/main/AndroidManifest.xml. The component itself only declares network and foreground service permissions; camera, microphone, and other permissions must be declared by your app:<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /><uses-permission android:name="android.permission.BLUETOOTH" /><uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
plugins {id "dev.flutter.flutter-plugin-loader" version "1.0.0"id "com.android.application" version "8.2.1" apply falseid "org.jetbrains.kotlin.android" version "2.1.10" apply false}
platform :ios, '15.0'post_install do |installer|installer.pods_project.targets.each do |target|flutter_additional_ios_build_settings(target)target.build_configurations.each do |config|config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)','PERMISSION_CAMERA=1','PERMISSION_MICROPHONE=1',]endendend
ios/Runner/Info.plist (audience should still hear the live stream when the app is in the background):<key>NSCameraUsageDescription</key><string>TUILiveKit requires access to your camera. Enabling this allows video for co-hosting.</string><key>NSMicrophoneUsageDescription</key><string>TUILiveKit requires access to your microphone. Enabling this allows audio for co-hosting.</string><key>UIBackgroundModes</key><array><string>audio</string></array>
LoginStore.shared.login to authenticate. This step is required before you can use any TUILiveKit features. Make sure all parameters are set correctly.login after completing your own user authentication and login logic. This prevents business logic conflicts or data inconsistencies, and ensures TUILiveKit integrates smoothly with your user management and permission system.import 'package:atomic_x_core/atomicxcore.dart';import 'package:flutter/material.dart';Future<void> login() async {// 1. Call the login API. userSig should be issued by your backendfinal CompletionHandler result = await LoginStore.shared.login(sdkAppID: 1400000001, // Replace with your SDKAppID from the service consoleuserID: 'denny', // Replace with your UserIDuserSig: 'xxxxxxxxxxx', // Replace with the UserSig generated by your backend);// 2. Check login resultif (result.isSuccess) {debugPrint('login success');} else {debugPrint('login failed: ${result.errorCode} ${result.errorMessage}');}}
Parameter | Type | Description |
SDKAppID | Int | |
UserID | String | The unique ID for the current user. Must contain only English letters, numbers, hyphens, and underscores. |
UserSig | String | Authentication credential for TRTC. Please note: Development Environment: You can use the local GenerateTestUserSig.genTestSig function to generate a UserSig or generate a temporary UserSig via the UserSig Generation Tool.Production Environment: To prevent key leakage, you must use a server-side method to generate UserSig. For details, see Generating UserSig on the Server. |
LoginStore offers login status callbacks to help you handle exceptions, including "Kicked Offline" and "Signature Expired":import 'dart:async';import 'package:atomic_x_core/atomicxcore.dart';import 'package:flutter/foundation.dart';class LoginService {StreamSubscription<LoginEvent>? subscription;void subscribeLoginStatus() {subscription = LoginStore.shared.loginEventStream.listen((LoginEvent event) {switch (event) {case LoginEvent.kickedOffline:case LoginEvent.loginExpired:debugPrint('login state changed: $event');}});}void dispose() {subscription?.cancel();}}
Feature | Description | Integration Guide |
Host Streaming | The complete workflow for a host to start a stream, including pre-stream setup and various in-stream interactions. | |
Audience Viewing | Audience can watch live streaming after entering the anchor's live streaming room, with features like audience mic connection, live room information, online audience, and bullet screen display. | |
Live Stream List | Display the live stream list interface and features, including the live stream list and room information display. |
LoginStore.shared.login is sufficient. We recommend aligning LoginStore.shared.login and LoginStore.shared.logout with your own authentication logic.Non-Global Symbols to preserve the necessary global symbol information. Otherwise, runtime exceptions may prevent you from entering the room.Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan