Ver código fonte

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).
master
Saúl Ibarra Corretgé 6 anos atrás
pai
commit
9a92dc578c
1 arquivos alterados com 7 adições e 3 exclusões
  1. 7
    3
      ios/sdk/src/callkit/JMCallKitProxy.swift

+ 7
- 3
ios/sdk/src/callkit/JMCallKitProxy.swift Ver arquivo

@@ -27,7 +27,7 @@ import Foundation
27 27
 
28 28
     // MARK: - CallKit proxy
29 29
 
30
-    private static let provider: CXProvider = {
30
+    private static var provider: CXProvider = {
31 31
         let configuration = CXProviderConfiguration(localizedName: "")
32 32
         return CXProvider(configuration: configuration)
33 33
     }()
@@ -52,9 +52,13 @@ import Foundation
52 52
     /// Defaults to enabled, set to false when you don't want to use CallKit.
53 53
     @objc public static var enabled: Bool = true {
54 54
         didSet {
55
-            if enabled == false {
55
+            provider.invalidate()
56
+            if enabled {
57
+                guard isProviderConfigured() else  { return; }
58
+                provider = CXProvider(configuration: providerConfiguration!)
59
+                provider.setDelegate(emitter, queue: nil)
60
+            } else {
56 61
                 provider.setDelegate(nil, queue: nil)
57
-                provider.invalidate()
58 62
             }
59 63
         }
60 64
     }

Carregando…
Cancelar
Salvar