tencent cloud

All product documents
Chat
Android&iOS&Flutter
Last updated: 2024-05-08 11:37:24
Android&iOS&Flutter
Last updated: 2024-05-08 11:37:24
This document describes how to use the Call Status Callback of the TUICallKit component.

Call Status Monitoring

If your business needs to monitor the status of calls, such as the start and end of a call and other events during the call, you can refer to the following code:
Android(Kotlin)
Android(Java)
iOS(Swift)
iOS(Objective-C)
Flutter(Dart)
private val observer: TUICallObserver = object : TUICallObserver() {
override fun onCallBegin(roomId: TUICommonDefine.RoomId?, callMediaType: TUICallDefine.MediaType?, callRole: TUICallDefine.Role?) {
}
override fun onCallEnd(roomId: TUICommonDefine.RoomId?, callMediaType: TUICallDefine.MediaType?, callRole: TUICallDefine.Role?, totalTime: Long) {
}
override fun onUserNetworkQualityChanged(networkQualityList: MutableList<TUICommonDefine.NetworkQualityInfo>?) {
}
}
private fun initData() {
TUICallEngine.createInstance(context).addObserver(observer)
}
private TUICallObserver observer = new TUICallObserver() {
@Override
public void onCallBegin(TUICommonDefine.RoomId roomId, TUICallDefine.MediaType callMediaType, TUICallDefine.Role callRole) {
}
public void onCallEnd(TUICommonDefine.RoomId roomId, TUICallDefine.MediaType callMediaType,TUICallDefine.Role callRole, long totalTime) {
}
public void onUserNetworkQualityChanged(List<TUICommonDefine.NetworkQualityInfo> networkQualityList) {
}
};

private void initData(){
TUICallEngine.createInstance(context).addObserver(observer);
}
import TUICallEngine

TUICallEngine.createInstance().addObserver(self)

public func onCallBegin(roomId: TUIRoomId, callMediaType: TUICallMediaType, callRole: TUICallRole) {

}
public func onCallEnd(roomId: TUIRoomId, callMediaType: TUICallMediaType, callRole: TUICallRole, totalTime: Float) {

}
public func onUserNetworkQualityChanged(networkQualityList: [TUINetworkQualityInfo]) {

}
#import <TUICallEngine/TUICallEngine.h>

[[TUICallEngine createInstance] addObserver:self];

- (void)onCallBegin:(TUIRoomId *)roomId callMediaType:(TUICallMediaType)callMediaType callRole:(TUICallRole)callRole {

}
- (void)onCallEnd:(TUIRoomId *)roomId callMediaType:(TUICallMediaType)callMediaType callRole:(TUICallRole)callRole totalTime:(float)totalTime {

}
- (void)onUserNetworkQualityChanged:(NSArray<TUINetworkQualityInfo *> *)networkQualityList {

}
TUICallObserver observer = TUICallObserver(
onError: (int code, String message) {
// Your callback handling logic
}, onCallBegin: (TUIRoomId roomId, TUICallMediaType callMediaType, TUICallRole callRole) {
// Your callback handling logic
}, onCallEnd: (TUIRoomId roomId, TUICallMediaType callMediaType, TUICallRole callRole, double totalTime) {
// Your callback handling logic
},, onUserNetworkQualityChanged: (List<TUINetworkQualityInfo> networkQualityList) {
// Your callback handling logic
}, onCallReceived: (String callerId, List<String> calleeIdList, String groupId, TUICallMediaType callMediaType) {
// Your callback handling logic
}
))

TUICallEngine.instance.addObserver(observer);
Note:
On the Android platform, when setting TUICallObserver to monitor callbacks, ensure the callback's class is not cleared. For example, it's not recommended to add monitoring in LoginActivity because the callback will be cleared when LoginActivity is terminated; it's advised to monitor in the Application class or the main interface.


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon