-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathJoinSource.swift
More file actions
48 lines (41 loc) · 1.62 KB
/
JoinSource.swift
File metadata and controls
48 lines (41 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Copyright © 2026 Stream.io Inc. All rights reserved.
//
import Foundation
/// An enumeration that describes the source from which a call was joined.
///
/// Use `JoinSource` to indicate whether the join action originated from within
/// the app's own UI or through a system-level interface such as CallKit.
/// This helps distinguish the user's entry point and can be used to customize
/// behavior or analytics based on how the call was initiated.
enum JoinSource: Sendable, Equatable {
/// Carries the completion hook CallKit expects us to invoke once the SDK is
/// ready for CallKit to hand audio session ownership back to the app.
struct ActionCompletion: @unchecked Sendable {
fileprivate let identifier: UUID = .init()
private let completion: () -> Void
init(_ completion: @escaping () -> Void) {
self.completion = completion
}
/// Invokes the stored completion callback.
func complete() {
completion()
}
}
/// Indicates that the call was joined from within the app's UI.
case inApp
/// Indicates that the call was joined via CallKit integration.
case callKit(ActionCompletion)
/// Compares `JoinSource` values while treating CallKit sources as distinct
/// whenever they wrap different completion hooks.
static func == (lhs: JoinSource, rhs: JoinSource) -> Bool {
switch (lhs, rhs) {
case (.inApp, .inApp):
return true
case (.callKit(let lhs), .callKit(let rhs)):
return lhs.identifier == rhs.identifier
default:
return false
}
}
}