瀏覽代碼

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 年之前
父節點
當前提交
9a92dc578c
共有 1 個檔案被更改,包括 7 行新增3 行删除
  1. 7
    3
      ios/sdk/src/callkit/JMCallKitProxy.swift

+ 7
- 3
ios/sdk/src/callkit/JMCallKitProxy.swift 查看文件

@@ -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
     }

Loading…
取消
儲存