I'm working on porting the source of an app I took from a sample to an app I created by myself by changing it to SwiftUI. I don't know how to port the following CXProviderDelegate.
If I port it as is If I port it as-is, I get an error saying that the non-class type 'VideoView' cannot conform to class protocol 'CXProviderDelegate'.
Please let me know how to port it.
extension videoTabView: CXProviderDelegate { func providerDidReset(_ provider: CXProvider) {
}
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
callCenter.ConfigureAudioSession()
callCenter.Connecting()
action.fulfill()
}
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
callCenter.ConfigureAudioSession()
if let peer = self.dataConnection?.peer {
self.call(targetPeerId: peer)
}
action.fulfill()
}
func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
self.dataConnection?.close()
self.mediaConnection?.close()
action.fulfill()
}
}
As you found, you cannot make a view type (which is a struct!) conform to CXProviderDelegate
.
You need to create a class inheriting NSObject
and make it conform to CXProviderDelegate
and use it in your view.
By the way, in Swift, type names should start with Capital letters. You should not use videoTabView
as a View name.