From 9a92dc578c55b358668e7a02a8310169ea0ea6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 17 Apr 2019 17:13:26 +0200 Subject: [PATCH] ios: fix resetting CallKit's CXProvider When CallKit is enabled / disabled, a new CXProvider must be created in order to not confuse CallKit (it misbehaves otherwise). --- ios/sdk/src/callkit/JMCallKitProxy.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ios/sdk/src/callkit/JMCallKitProxy.swift b/ios/sdk/src/callkit/JMCallKitProxy.swift index de7a0f4f1..b1e4b2953 100644 --- a/ios/sdk/src/callkit/JMCallKitProxy.swift +++ b/ios/sdk/src/callkit/JMCallKitProxy.swift @@ -27,7 +27,7 @@ import Foundation // MARK: - CallKit proxy - private static let provider: CXProvider = { + private static var provider: CXProvider = { let configuration = CXProviderConfiguration(localizedName: "") return CXProvider(configuration: configuration) }() @@ -52,9 +52,13 @@ import Foundation /// Defaults to enabled, set to false when you don't want to use CallKit. @objc public static var enabled: Bool = true { didSet { - if enabled == false { + provider.invalidate() + if enabled { + guard isProviderConfigured() else { return; } + provider = CXProvider(configuration: providerConfiguration!) + provider.setDelegate(emitter, queue: nil) + } else { provider.setDelegate(nil, queue: nil) - provider.invalidate() } } }