Calculate call duration
This doc describes how to calculate the call duration through configuration.

To calculate call duration, do the following:
-
Set the
isVisibleproperty ofdurationConfigto display the current call timer. (It is displayed by default) -
Assuming that the call duration is 5 minutes, the call will automatically end when the time is up (refer to the following code). You will be notified of the end of the call duration through
durationConfig.onDurationUpdate. To end the call, you can call thehangUpmethod ofZegoUIKitPrebuiltCallServiceorZegoUIKitPrebuiltCallref.
import ZegoUIKitPrebuiltCallService from '@zegocloud/zego-uikit-prebuilt-call-rn';
import * as ZIM from 'zego-zim-react-native';
import * as ZPNs from 'zego-zpns-react-native';
ZegoUIKitPrebuiltCallService.init(
yourAppID,
yourAppSign,
userID,
userName,
[ZIM, ZPNs],
{
ringtoneConfig: {
incomingCallFileName: 'zego_incoming.mp3',
outgoingCallFileName: 'zego_outgoing.mp3',
},
requireConfig: (data) => {
return {
// \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
timingConfig: {
isDurationVisible: true,
onDurationUpdate: (duration) => {
if (duration === 5 * 60) {
ZegoUIKitPrebuiltCallService.hangUp();
}
},
},
// \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
};
},
notifyWhenAppRunningInBackgroundOrQuit: true,
isIOSSandboxEnvironment: true,
androidNotificationConfig: {
channelID: "ZegoUIKit",
channelName: "ZegoUIKit",
},
},
)
