インテグレーション
This article will guide you through the process of integrating the TUICallKit component quickly. By following this documentation, you can complete the access work in just 10 minutes and ultimately obtain an application with a complete user interface as well as audio and video calling features.
Video Call | Group call |
| |
Environment Preparations
Flutter 3.0 or higher version.
Step 1. Activate the service
Before using the audio and video services provided by Tencent Cloud, you need to go to the console to activate the audio and video services for your application, and obtain
SDKAppID, SDKSecretKey
. They will be used in Step 5. For specific steps, please refer to activate the Service.Step 2. Import the component
flutter pub
add
tencent_calls_uikit
Step 3. Configure the project
1. If you need to compile and run on the Android platform, since the SDK uses Java's reflection feature internally, certain classes in the SDK must be added to the non-aliasing list.
First, configure and enable obfuscation rules in the
android/app/build.gradle
file of the project:android {......buildTypes {release {......minifyEnabled trueproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}
Create a
proguard-rules.pro
file in the android/app
directory of the project, and add the following code in the proguard-rules.pro
file:-keep class com.tencent.** { *; }
2. Configure to enable Multidex support in the
android/app/build.gradle
file of your project.android {......defaultConfig {...... multiDexEnabled true }}
Since TUICallKit uses iOS's audio and video features, you need to grant permissions for the use of the microphone and camera.
Authorization Operation Method: In your iOS project's
Info.plist
, under the first-level <dict>
directory, add the following two items. They correspond to the system's prompt messages when asking for microphone and camera permissions.<key>NSCameraUsageDescription</key><string>CallingApp needs to access your camera to capture video.</string><key>NSMicrophoneUsageDescription</key><string>CallingApp needs to access your microphone to capture audio.</string>
Step 4: Set up navigatorObservers
1. In the Flutter application framework, add TUICallKit.navigatorObserver to navigatorObservers. For example, using the MaterialApp framework, the code is as follows:
import 'package:tencent_calls_uikit/tencent_calls_uikit.dart';......class XXX extends StatelessWidget { const XXX({super.key});@override Widget build(BuildContext context) { return MaterialApp( navigatorObservers: [TUICallKit.navigatorObserver], ...... ); } }
Step 5: Log in to the TUICallKit Component
import 'package:tencent_calls_uikit/tencent_calls_uikit.dart';import 'package:tencent_calls_uikit/debug/generate_test_user_sig.dart';......final String userID = 'xxxxx'; // Please replace with your UserId final int sdkAppID = 0; // Please replace with the SDKAppID you got from the console in step 1 final String secretKey = 'xxxx'; // Please replace with the SecretKey you got from the console in step 1void login() async {String userSig = GenerateTestUserSig.genTestSig(userID, sdkAppID, secretKey);TUIResult result = await TUICallKit.instance.login(sdkAppID, userID, userSig);if (result.code.isEmpty) { print('Login success'); } else { print('Login failed: ${result.code} ${result.message}'); }}
Parameter | Type | Description |
userID | String | Customers define their own User ID based on their business. You can only include letters (a-z, A-Z), digits (0-9), underscores, and hyphens. |
sdkAppID | int | |
secretKey | String | |
userSig | String | A security protection signature used for user log in authentication to confirm the user's identity and prevent malicious attackers from stealing your cloud service usage rights. |
Note:
Development Environment: If you are in the local development and debugging stage, you can use the local
GenerateTestUserSig.genTestSig
function to generate userSig. In this method, the SDKSecretKey is vulnerable to decompilation and reverse engineering, and once your key is leaked, attackers can steal your Tencent Cloud traffic.Production Environment: If your project is going to be launched, please adopt the method of Server-side Generation of UserSig.
Step 6. Make your first phone call
After both the caller and callee have successfully signed in, the caller can initiate an audio or video call by calling the TUICallKit's call method and specifying the call type and the callee's userId. At this point, the callee will receive an incoming call invitation.
TUICallKit.instance.call('Android', TUICallMediaType.audio);import 'package:tencent_calls_uikit/tencent_calls_uikit.dart';......void call() {TUICallKit.instance.call('Android', TUICallMediaType.audio);}
| |
Caller | Callee |
Additional Features
FAQs
Suggestions and Feedback
If you have any suggestions or feedback, please contact info_rtc@tencent.com.