mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fixes #3134 - Fix answering call not opening app
- we're currently working around the widget not properly aquiring media streams by manually terminating a call before starting the web view - it seems that there's a race condition between that and the system opening the app - as such we need to delay terminating the call until the system gets a chance to handle the redirect
This commit is contained in:
committed by
Stefan Ceriu
parent
398442ff12
commit
9b9f45ea0c
@@ -192,28 +192,36 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
||||||
if let incomingCallID {
|
guard let incomingCallID else {
|
||||||
// Fixes broken videos on EC web when a CallKit session is established.
|
|
||||||
//
|
|
||||||
// Reporting an ongoing call through `reportNewIncomingCall` + `CXAnswerCallAction`
|
|
||||||
// or `reportOutgoingCall:connectedAt:` will give exclusive access for media to the
|
|
||||||
// ongoing process, which is different than the WKWebKit is running on, making EC
|
|
||||||
// unable to aquire media streams.
|
|
||||||
// Reporting the call as ended imediately after answering it works around that
|
|
||||||
// as EC gets access to media again and EX builds the right UI in `setupCallSession`
|
|
||||||
//
|
|
||||||
// https://github.com/element-hq/element-x-ios/issues/3041
|
|
||||||
// https://forums.developer.apple.com/forums/thread/685268
|
|
||||||
// https://stackoverflow.com/questions/71483732/webrtc-running-from-wkwebview-avaudiosession-development-roadblock
|
|
||||||
provider.reportCall(with: incomingCallID.callKitID, endedAt: nil, reason: .answeredElsewhere)
|
|
||||||
|
|
||||||
actionsSubject.send(.startCall(roomID: incomingCallID.roomID))
|
|
||||||
endUnansweredCallTask?.cancel()
|
|
||||||
} else {
|
|
||||||
MXLog.error("Failed answering incoming call, missing incomingCallID")
|
MXLog.error("Failed answering incoming call, missing incomingCallID")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixes broken videos on EC web when a CallKit session is established.
|
||||||
|
//
|
||||||
|
// Reporting an ongoing call through `reportNewIncomingCall` + `CXAnswerCallAction`
|
||||||
|
// or `reportOutgoingCall:connectedAt:` will give exclusive access for media to the
|
||||||
|
// ongoing process, which is different than the WKWebKit is running on, making EC
|
||||||
|
// unable to aquire media streams.
|
||||||
|
// Reporting the call as ended imediately after answering it works around that
|
||||||
|
// as EC gets access to media again and EX builds the right UI in `setupCallSession`
|
||||||
|
//
|
||||||
|
// https://github.com/element-hq/element-x-ios/issues/3041
|
||||||
|
// https://forums.developer.apple.com/forums/thread/685268
|
||||||
|
// https://stackoverflow.com/questions/71483732/webrtc-running-from-wkwebview-avaudiosession-development-roadblock
|
||||||
|
|
||||||
|
// First fullfill the action
|
||||||
action.fulfill()
|
action.fulfill()
|
||||||
|
|
||||||
|
// And delay ending the call so that the app has enough time
|
||||||
|
// to get deeplinked into
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||||
|
// Then end the and call rely on `setupCallSession` to create a new one
|
||||||
|
provider.reportCall(with: incomingCallID.callKitID, endedAt: nil, reason: .remoteEnded)
|
||||||
|
|
||||||
|
self.actionsSubject.send(.startCall(roomID: incomingCallID.roomID))
|
||||||
|
self.endUnansweredCallTask?.cancel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
|
func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
|
||||||
|
|||||||
Reference in New Issue
Block a user