Skip to content

Client Integration

This page helps you add the TiRTC client SDK to your app and initialize the SDK.

Prerequisites

Before writing client code, prepare:

ItemSource
AppIdYour TiRTC application configuration.

Supported Platforms and Requirements

PlatformRequirement
FlutterFlutter >=3.13.0
Dart >=3.1.0 <4.0.0
Supports Android / iOS / macOS / OpenHarmony / HarmonyOS NEXT
AndroidAndroid 5.0 (API Level 21) or later
arm64-v8a
compileSdk 35
HarmonyOSOpenHarmony / HarmonyOS NEXT native app
DevEco Studio or OpenHarmony SDK 12 or later
Runtime device must support arm64-v8a native libraries
iOSiOS 13.0 or later
arm64

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>'
end

Initialize 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
  }
}

TiRTC