mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Fix lost call transactions after rebuilding callUIAdapter
// FREEBIE
This commit is contained in:
parent
145a816315
commit
c5fc671c31
1 changed files with 18 additions and 2 deletions
|
@ -31,6 +31,23 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
|||
// CallKit handles incoming ringer stop/start for us. Yay!
|
||||
let hasManualRinger = false
|
||||
|
||||
// Instantiating more than one CXProvider can cause us to miss call transactions, so
|
||||
// we maintain the provider across Adaptees using a singleton pattern
|
||||
private static var _sharedProvider: CXProvider?
|
||||
class func sharedProvider(useSystemCallLog: Bool) -> CXProvider {
|
||||
let configuration = buildProviderConfiguration(useSystemCallLog: useSystemCallLog)
|
||||
|
||||
if let sharedProvider = self._sharedProvider {
|
||||
sharedProvider.configuration = configuration
|
||||
return sharedProvider
|
||||
} else {
|
||||
SwiftSingletons.register(self)
|
||||
let provider = CXProvider(configuration: configuration)
|
||||
_sharedProvider = provider
|
||||
return provider
|
||||
}
|
||||
}
|
||||
|
||||
// The app's provider configuration, representing its CallKit capabilities
|
||||
class func buildProviderConfiguration(useSystemCallLog: Bool) -> CXProviderConfiguration {
|
||||
let localizedName = NSLocalizedString("APPLICATION_NAME", comment: "Name of application")
|
||||
|
@ -71,8 +88,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
|||
self.contactsManager = contactsManager
|
||||
self.notificationsAdapter = notificationsAdapter
|
||||
|
||||
let providerConfiguration = type(of: self).buildProviderConfiguration(useSystemCallLog: useSystemCallLog)
|
||||
self.provider = CXProvider(configuration: providerConfiguration)
|
||||
self.provider = type(of: self).sharedProvider(useSystemCallLog: useSystemCallLog)
|
||||
|
||||
self.audioActivity = AudioActivity(audioDescription: "[CallKitCallUIAdaptee]")
|
||||
self.showNamesOnCallScreen = showNamesOnCallScreen
|
||||
|
|
Loading…
Reference in a new issue