Skip to content

Commit 3fc909a

Browse files
authored
Merge pull request #286561 from garchiro7/native-add-call-duration-events
Bring call duration into the calling native SDKs
2 parents 1046469 + 509834e commit 3fc909a

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed

articles/communication-services/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ items:
331331
href: how-tos/cte-calling-sdk/manage-calls.md
332332
- name: Manage Teams meeting Lobby
333333
href: how-tos/calling-sdk/lobby.md
334+
- name: Manage call duration
335+
href: tutorials/call-duration.md
334336
- name: PowerPoint Live
335337
href: how-tos/calling-sdk/powerpoint-live.md
336338
- name: Record calls
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
author: garchiro7
6+
7+
ms.author: jorgegarc
8+
ms.service: azure-communication-services
9+
ms.subservice: calling
10+
ms.topic: how-to
11+
ms.date: 09/01/2024
12+
ms.custom: template-how-to
13+
zone_pivot_groups: acs-plat-ios-android-windows
14+
---
15+
16+
# Manage call duration
17+
18+
Provides developers with the capability to programmatically trigger and track events when a call starts. Capturing the initiation of a call enables businesses to execute crucial workflows, including logging call metadata, initiating timers for duration tracking, or triggering user interface updates to reflect the real-time call status.
19+
20+
## Start time
21+
22+
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.
23+
24+
### Use cases
25+
26+
#### Enhanced user experience
27+
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.
28+
29+
**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.
30+
31+
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.
32+
33+
#### Performance and monitoring analytics
34+
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.
35+
36+
**Example:** A customer support center can track how long agents stay on calls and identify trends related to call durations, improving resource management.
37+
38+
## Prerequisites
39+
40+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F)
41+
- A deployed Communication Services resource. [Create a Communication Services resource](../quickstarts/create-communication-resource.md)
42+
- A user access token to enable the calling client. For more information, see [Create and manage access tokens](../quickstarts/identity/access-tokens.md).
43+
- Optional: Complete the quickstart to [add voice calling to your application](../quickstarts/voice-video-calling/getting-started-with-calling.md)
44+
45+
::: zone pivot="platform-android"
46+
[!INCLUDE [Manage Call duration events using Android](./includes/call-duration/android.md)]
47+
::: zone-end
48+
49+
::: zone pivot="platform-ios"
50+
[!INCLUDE [Manage Call duration events using iOS](./includes/call-duration/ios.md)]
51+
::: zone-end
52+
53+
::: zone pivot="platform-windows"
54+
[!INCLUDE [Manage Call duration events using Windows](./includes/call-duration/windows.md)]
55+
::: zone-end
56+
57+
## Next steps
58+
59+
- [Learn how to manage calls](../how-tos/calling-sdk/manage-calls.md)
60+
- [Learn about the UI Library](../concepts/ui-library/ui-library-overview.md)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
9+
## Get call start time
10+
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.
11+
12+
``` java
13+
CommonCall call;
14+
PropertyChangedListener onStartTimeUpdated = this::OnStartTimeUpdated;
15+
16+
// subscribe to start time updated
17+
call.addOnStartTimeUpdatedListener(onStartTimeUpdated);
18+
19+
// get start time
20+
private void OnStartTimeUpdated(PropertyChangedEvent propertyChangedEvent) {
21+
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
22+
dateFormatter.setTimeZone(TimeZone.getDefault());
23+
String dateString = dateFormatter.format(call.getStartTime());
24+
// dateString with dateFormatter
25+
}
26+
27+
// unsubscribe to start time updated
28+
call.removeOnStartTimeUpdatedListener(onStartTimeUpdated);
29+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
9+
## Get call start time
10+
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.
11+
12+
``` swift
13+
class CallObserver : NSObject, CallDelegate
14+
{
15+
// subscribe to didUpdateStartTime
16+
public func call(_ call: Call, didUpdateStartTime args: PropertyChangedEventArgs) {
17+
let dateFormatter = DateFormatter()
18+
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
19+
dateFormatter.timeZone = TimeZone.current
20+
let dateString = dateFormatter.string(from: call.startTime)
21+
print("==> didUpdateStartTime for call: \(dateString)")
22+
}
23+
}
24+
25+
// set call delegate
26+
call.delegate = CallObserver()
27+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
9+
## Get call start time
10+
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.
11+
12+
``` cs
13+
CommonCommunicationCall call;
14+
15+
// subscribe to start time updated
16+
call.StartTimeUpdated += Call_OnStartTimeUpdated;
17+
18+
private async void Call_OnStartTimeUpdated(object sender, PropertyChangedEventArgs args)
19+
{
20+
// call.StartTime
21+
}
22+
23+
// unsubscribe to start time updated
24+
call.StartTimeUpdated -= Call_OnStartTimeUpdated;
25+
```

0 commit comments

Comments
 (0)