Client Integration
This page helps you add the TiRTC client SDK to your app and initialize the SDK.
Prerequisites
Before writing client code, prepare:
| Item | Source |
|---|---|
AppId | Your TiRTC application configuration. |
Supported Platforms and Requirements
| Platform | Requirement |
|---|---|
| Flutter | Flutter >=3.13.0Dart >=3.1.0 <4.0.0Supports Android / iOS / macOS / OpenHarmony / HarmonyOS NEXT |
| Android | Android 5.0 (API Level 21) or laterarm64-v8acompileSdk 35 |
| HarmonyOS | OpenHarmony / HarmonyOS NEXT native app DevEco Studio or OpenHarmony SDK 12 or laterRuntime device must support arm64-v8a native libraries |
| iOS | iOS 13.0 or laterarm64 |
Add the SDK
Use the <latest-version> from the target platform release notes: Flutter, Android, HarmonyOS, iOS.
text
# pubspec.yaml
dependencies:
flutter:
sdk: flutter
tirtc_av_kit: <latest-version>
# android/build.gradle.kts
# Required only when building the Android target
allprojects {
repositories {
google()
mavenCentral()
maven {
url = uri("http://repo-sdk.tange-ai.com/repository/maven-public/")
isAllowInsecureProtocol = true
credentials {
username = "tange_user"
password = "tange_user"
}
}
}
}kotlin
// settings.gradle.kts
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url = uri("http://repo-sdk.tange-ai.com/repository/maven-public/")
isAllowInsecureProtocol = true
credentials {
username = providers.gradleProperty("TIRTC_PUBLIC_MAVEN_USERNAME").orElse("tange_user").get()
password = providers.gradleProperty("TIRTC_PUBLIC_MAVEN_PASSWORD").orElse("tange_user").get()
}
}
}
}
// app/build.gradle.kts
dependencies {
implementation("com.tange.ai:tirtc-av:<latest-version>")
}json5
// oh-package.json5
{
"dependencies": {
"tirtc-av": "<latest-version>"
}
}ruby
target 'YourApp' do
pod 'TiRTC_AV', '<latest-version>'
endInitialize the SDK
Initialize the SDK with your AppId after your app starts. After initialization succeeds, continue with connection, playback, and messaging.
dart
import 'package:flutter/material.dart';
import 'package:tirtc_av_kit/tirtc_av_kit.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final int code = await TiRtc.initialize(
const TiRtcInitOptions(appId: 'your-app-id'),
);
if (code != 0) {
throw StateError('TiRTC initialize failed: ${TiRtc.formatError(code)}');
}
runApp(const YourApp());
}kotlin
class DemoApp : Application() {
override fun onCreate() {
super.onCreate()
TiRtc.initialize(
applicationContext,
TiRtcInitOptions(appId = "your-app-id"),
)
}
}ts
import type { common } from '@kit.AbilityKit';
import { TiRtc } from 'tirtc-av/Index';
async function initializeTiRtc(context: common.UIAbilityContext): Promise<void> {
const code = await TiRtc.initialize({
context,
appId: 'your-app-id',
});
if (code !== 0) {
throw new Error(`TiRTC initialize failed: ${TiRtc.formatError(code)}`);
}
}swift
import TiRTC_AV
import UIKit
@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
let config = TiRtcInitOptions(appId: "your-app-id")
TiRtc.initialize(config)
return true
}
}