Skip to content

Commit

Permalink
Fix broken hang up widget message format
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Jun 26, 2024
1 parent 85ea31a commit c2461f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol

private func hangUp() async {
let hangUpMessage = """
"api":"toWidget",
{"api":"fromWidget",
"widgetId":"\(widgetDriver.widgetID)",
"requestId":"widgetapi-\(UUID())",
"action":"im.vector.hangup",
"data":{}
"data":{}}
"""

let result = await widgetDriver.sendMessage(hangUpMessage)
Expand Down
12 changes: 9 additions & 3 deletions ElementX/Sources/Services/ElementCall/ElementCallService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe

private let pushRegistry: PKPushRegistry
private let callController = CXCallController()
private lazy var callProvider: CXProvider = {
private let callProvider: CXProvider = {
let configuration = CXProviderConfiguration()
configuration.supportsVideo = true
configuration.includesCallsInRecents = true
Expand Down Expand Up @@ -92,8 +92,12 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
MXLog.error("Failed requesting start call action with error: \(error)")
}

try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: [])
try? AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
do { // Setup the audio session even if setting up CallKit failed, ElementCall **is** running at this point
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: [])
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
} catch {
MXLog.error("Failed setting up audio session with error: \(error)")
}
}

func tearDownCallSession() {
Expand Down Expand Up @@ -171,6 +175,8 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe

func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
// Forward this to the widget somehow
// webView.evaluateJavaScript("groupCall.setLocalVideoMuted(!groupCall.isLocalVideoMuted())")
// webView.evaluateJavaScript("groupCall.setMicrophoneMuted(!groupCall.isMicrophoneMuted())"
}

func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
Expand Down

0 comments on commit c2461f4

Please sign in to comment.