Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
9a92dc578c
1 muutettua tiedostoa jossa 7 lisäystä ja 3 poistoa
  1. 7
    3
      ios/sdk/src/callkit/JMCallKitProxy.swift

+ 7
- 3
ios/sdk/src/callkit/JMCallKitProxy.swift Näytä tiedosto

27
 
27
 
28
     // MARK: - CallKit proxy
28
     // MARK: - CallKit proxy
29
 
29
 
30
-    private static let provider: CXProvider = {
30
+    private static var provider: CXProvider = {
31
         let configuration = CXProviderConfiguration(localizedName: "")
31
         let configuration = CXProviderConfiguration(localizedName: "")
32
         return CXProvider(configuration: configuration)
32
         return CXProvider(configuration: configuration)
33
     }()
33
     }()
52
     /// Defaults to enabled, set to false when you don't want to use CallKit.
52
     /// Defaults to enabled, set to false when you don't want to use CallKit.
53
     @objc public static var enabled: Bool = true {
53
     @objc public static var enabled: Bool = true {
54
         didSet {
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
                 provider.setDelegate(nil, queue: nil)
61
                 provider.setDelegate(nil, queue: nil)
57
-                provider.invalidate()
58
             }
62
             }
59
         }
63
         }
60
     }
64
     }

Loading…
Peruuta
Tallenna