Skip to content

Commit

Permalink
[CallKit]Custom ringtone support (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis authored Jan 3, 2025
1 parent 759cb3b commit 2c52184
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### ✅ Added
- CallKit availability policies allows you to control wether `Callkit` should be enabled/disabled based on different rules [#611](https://github.com/GetStream/stream-video-swift/pull/611)
- Support for setting a ringtone for CallKit calls [#628](https://github.com/GetStream/stream-video-swift/pull/628)

### 🐞 Fixed
- By observing the `CallKitPushNotificationAdapter.deviceToken` you will be notified with an empty `deviceToken` value, once the object unregister push notifications. [#608](https://github.com/GetStream/stream-video-swift/pull/608)
Expand Down
6 changes: 6 additions & 0 deletions Sources/StreamVideo/CallKit/CallKitAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ open class CallKitAdapter {
set { callKitService.iconTemplateImageData = newValue }
}

/// The ringtone sound to use for CallKit ringing calls.
open var ringtoneSound: String? {
get { callKitService.ringtoneSound }
set { callKitService.ringtoneSound = newValue }
}

/// The callSettings to use when joining a call (after accepting it on CallKit)
/// default: nil
open var callSettings: CallSettings? {
Expand Down
3 changes: 3 additions & 0 deletions Sources/StreamVideo/CallKit/CallKitService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ open class CallKitService: NSObject, CXProviderDelegate, @unchecked Sendable {

/// The icon data for the call template.
open var iconTemplateImageData: Data?
/// The ringtone sound to use for CallKit ringing calls.
open var ringtoneSound: String?
/// Whether the call can be held on its own or swapped with another call.
/// - Important: Holding a call isn't supported yet!
open var supportsHolding: Bool = false
Expand Down Expand Up @@ -554,6 +556,7 @@ open class CallKitService: NSObject, CXProviderDelegate, @unchecked Sendable {
configuration.supportsVideo = supportsVideo
configuration.supportedHandleTypes = supportedHandleTypes
configuration.iconTemplateImageData = iconTemplateImageData
configuration.ringtoneSound = ringtoneSound

if supportsHolding {
// Holding a call isn't supported yet.
Expand Down
28 changes: 28 additions & 0 deletions StreamVideoTests/CallKit/CallKitServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,34 @@ final class CallKitServiceTests: XCTestCase, @unchecked Sendable {
}
}

@MainActor
func test_reportIncomingCall_withIconTemplateImageData_callUpdateWasConfiguredCorrectly() throws {
subject = .init()
let expectedData = String.unique.data(using: .utf8)
subject.iconTemplateImageData = expectedData

subject.reportIncomingCall(
cid,
localizedCallerName: localizedCallerName,
callerId: callerId
) { _ in }

XCTAssertEqual(subject.callProvider.configuration.iconTemplateImageData, expectedData)
}

@MainActor
func test_reportIncomingCall_withoutIconTemplateImageData_callUpdateWasConfiguredCorrectly() throws {
subject = .init()

subject.reportIncomingCall(
cid,
localizedCallerName: localizedCallerName,
callerId: callerId
) { _ in }

XCTAssertNil(subject.callProvider.configuration.iconTemplateImageData)
}

@MainActor
func test_reportIncomingCall_callProviderWasCalledWithExpectedValues() {
// Given
Expand Down

0 comments on commit 2c52184

Please sign in to comment.