Skip to content

Commit 3df76e0

Browse files
committed
Bring call duration into the calling native SDKs
1 parent 8467990 commit 3df76e0

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Manage the call duration events using Calling SDKs
3+
titleSuffix: An Azure Communication Services how-to guide
4+
description: Use Azure Communication Services Calling SDKs to handle call duration events
5+
6+
ms.author: jorgegarc
7+
ms.service: azure-communication-services
8+
ms.subservice: calling
9+
ms.topic: how-to
10+
ms.date: 09/01/2024
11+
ms.custom: template-how-to
12+
zone_pivot_groups: acs-plat-ios-android-windows
13+
---
14+
15+
# Manage call duration
16+
17+
## Start Time
18+
19+
The ability to use **call start time events** allows developers to capture and utilize the exact time a call is initiated. By subscribing to these events, developers gain valuable insights that can be applied in various use cases, such as performance tracking and user experience enhancements, among other uses.
20+
21+
### Use Cases
22+
23+
#### Enhanced User Experience
24+
Developers can use the call start time to display call duration to users in real time, improving the user experience by providing transparency on how long the user has been in the call.
25+
26+
**Example:** In a video conferencing app, the UI can display an active call timer showing how long the participants have been in the meeting, increasing user engagement.
27+
28+
By utilizing the call start time API events, developers can build more robust, feature-rich applications that improve the user experience, ensure compliance, and support detailed performance monitoring.
29+
30+
#### Performance and Monitoring Analytics
31+
By retrieving the call start time, developers can measure call duration and integrate with monitoring systems to analyze the performance of calls. This information is crucial for identifying call quality issues, optimizing network performance, and understanding user behavior.
32+
33+
**Example:** A customer support center can track how long agents stay on calls and identify trends related to call durations, improving resource management.
34+
35+
## Prerequisites
36+
37+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F)
38+
- A deployed Communication Services resource. [Create a Communication Services resource](../../quickstarts/create-communication-resource.md)
39+
- A user access token to enable the calling client. For more information, see [Create and manage access tokens](../../quickstarts/identity/access-tokens.md).
40+
- Optional: Complete the quickstart to [add voice calling to your application](../../quickstarts/voice-video-calling/getting-started-with-calling.md)
41+
42+
::: zone pivot="platform-android"
43+
[!INCLUDE [Manage Call duration events using Android](./includes/call-duration/android.md)]
44+
::: zone-end
45+
46+
::: zone pivot="platform-ios"
47+
[!INCLUDE [Manage Call duration events using iOS](./includes/call-duration/ios.md)]
48+
::: zone-end
49+
50+
::: zone pivot="platform-windows"
51+
[!INCLUDE [Manage Call duration events using Windows](./includes/call-duration/windows.md)]
52+
::: zone-end
53+
54+
## Next steps
55+
56+
- [Learn how to manage calls](./manage-calls.md)
57+
- [Learn about the UI Library](../../concepts/ui-library/ui-library-overview.md)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
author: iaulakh
3+
ms.service: azure-communication-services
4+
ms.topic: include
5+
ms.date: 09/01/2024
6+
ms.author: iaulakh
7+
---
8+
[!INCLUDE [Install SDK](../install-sdk/install-sdk-android.md)]
9+
10+
## Get call start time
11+
To retrieve the call start time, subscribe to the `addOnStartTimeUpdatedListener` on the `CommonCall` object. The start time is returned as a `Date` object, indicating when the call was bootstrapped.
12+
13+
``` java
14+
CommonCall call;
15+
PropertyChangedListener onStartTimeUpdated = this::OnStartTimeUpdated;
16+
17+
// subscribe to start time updated
18+
call.addOnStartTimeUpdatedListener(onStartTimeUpdated);
19+
20+
// get start time
21+
private void OnStartTimeUpdated(PropertyChangedEvent propertyChangedEvent) {
22+
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
23+
dateFormatter.setTimeZone(TimeZone.getDefault());
24+
String dateString = dateFormatter.format(call.getStartTime());
25+
// dateString with dateFormatter
26+
}
27+
28+
// unsubscribe to start time updated
29+
call.removeOnStartTimeUpdatedListener(onStartTimeUpdated);
30+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
author: iaulakh
3+
ms.service: azure-communication-services
4+
ms.topic: include
5+
ms.date: 09/01/2024
6+
ms.author: iaulakh
7+
---
8+
[!INCLUDE [Install SDK](../install-sdk/install-sdk-ios.md)]
9+
10+
## Get call start time
11+
To retrieve the call start time, set the `didUpdateStartTime` on the `CallDelegate`. The start time is returned as a `Date` object, indicating when the indicating when the call was bootstrapped.
12+
13+
``` swift
14+
class CallObserver : NSObject, CallDelegate
15+
{
16+
// subscribe to didUpdateStartTime
17+
public func call(_ call: Call, didUpdateStartTime args: PropertyChangedEventArgs) {
18+
let dateFormatter = DateFormatter()
19+
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
20+
dateFormatter.timeZone = TimeZone.current
21+
let dateString = dateFormatter.string(from: call.startTime)
22+
print("==> didUpdateStartTime for call: \(dateString)")
23+
}
24+
}
25+
26+
// set call delegate
27+
call.delegate = CallObserver()
28+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
author: iaulakh
3+
ms.service: azure-communication-services
4+
ms.topic: include
5+
ms.date: 09/01/2024
6+
ms.author: iaulakh
7+
---
8+
[!INCLUDE [Install SDK](../install-sdk/install-sdk-windows.md)]
9+
10+
## Get call start time
11+
To retrieve the call start time, subscribe to the `StartTimeUpdated` on the `CommonCommunicationCall` object. The start time is returned as a `DateTimeOffset` object, indicating when the call was bootstrapped.
12+
13+
``` cs
14+
CommonCommunicationCall call;
15+
16+
// subscribe to start time updated
17+
call.StartTimeUpdated += Call_OnStartTimeUpdated;
18+
19+
private async void Call_OnStartTimeUpdated(object sender, PropertyChangedEventArgs args)
20+
{
21+
// call.StartTime
22+
}
23+
24+
// unsubscribe to start time updated
25+
call.StartTimeUpdated -= Call_OnStartTimeUpdated;
26+
```

articles/communication-services/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ items:
336336
href: how-tos/cte-calling-sdk/manage-calls.md
337337
- name: Manage Teams meeting Lobby
338338
href: how-tos/calling-sdk/lobby.md
339+
- name: Manage call duration
340+
href: how-tos/calling-sdk/call-duration.md
339341
- name: PowerPoint Live
340342
href: how-tos/calling-sdk/powerpoint-live.md
341343
- name: Record calls

0 commit comments

Comments
 (0)