@kaleyra/video-react-native-module 1.6.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +17 -47
  2. package/android/build.gradle +24 -32
  3. package/android/gradle.properties +3 -3
  4. package/android/settings.gradle +0 -5
  5. package/android/src/main/AndroidManifest.xml +1 -1
  6. package/android/src/main/assets/kaleyra_video_wrapper_info.txt +1 -1
  7. package/android/src/main/java/com/kaleyra/video_react_native_module/VideoNativeModule.kt +0 -9
  8. package/index.ts +0 -2
  9. package/ios/PluginInfo/_KaleyraVideoHybridVersionInfo.swift +1 -1
  10. package/ios/VideoNativeModule.m +0 -6
  11. package/ios/VideoNativeModule.swift +1 -20
  12. package/lib/commonjs/src/KaleyraVideo.js +0 -34
  13. package/lib/module/src/KaleyraVideo.js +0 -34
  14. package/lib/typescript/index.d.ts +2 -2
  15. package/lib/typescript/native-bridge/TypeScript/types/UserDetails.d.ts +3 -15
  16. package/lib/typescript/src/KaleyraVideo.d.ts +1 -16
  17. package/native-bridge/TypeScript/types/UserDetails.ts +3 -18
  18. package/native-bridge/android/bridge.gradle +71 -0
  19. package/native-bridge/android/build.gradle +5 -61
  20. package/native-bridge/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  21. package/native-bridge/android/settings.gradle +8 -0
  22. package/native-bridge/android/src/main/AndroidManifest.xml +1 -1
  23. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/DTOs.kt +6 -40
  24. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/SDKAccessTokenProviderProxy.kt +9 -7
  25. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoHybridBridge.kt +0 -2
  26. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoSDKHybridBridge.kt +13 -23
  27. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/configurator/VideoSDKConfigurator.kt +32 -24
  28. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/connector/VideoSDKCachedUserConnector.kt +7 -5
  29. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CallEventsReporter.kt +27 -35
  30. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ChatEventsReporter.kt +34 -24
  31. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CrossPlatformModuleStatus.kt +14 -15
  32. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ModuleEventsReporter.kt +40 -18
  33. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/SDKEventsReporter.kt +6 -6
  34. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/CallDisplayExtension.kt +4 -3
  35. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/CallTypeExtensions.kt +12 -0
  36. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ConfigurationExtension.kt +17 -23
  37. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/EnvironmentExtension.kt +3 -3
  38. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RecordingTypeExtension.kt +5 -7
  39. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RegionExtension.kt +4 -4
  40. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ScreenShareToolConfigurationExtension.kt +5 -6
  41. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ToolsExtension.kt +49 -81
  42. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/UserExtensions.kt +24 -17
  43. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/notifications/KaleyraVideoNotificationService.kt +1 -2
  44. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsDao.kt +1 -1
  45. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsEntity.kt +2 -6
  46. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/VideoHybridBridgeRepository.kt +1 -1
  47. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ui/SDKUserInterfacePresenter.kt +22 -20
  48. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetails.kt +0 -3
  49. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/SDKCachedUserDetails.kt +22 -30
  50. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.pbxproj +84 -132
  51. package/native-bridge/iOS/Podfile +2 -2
  52. package/native-bridge/iOS/Podfile.lock +9 -9
  53. package/native-bridge/iOS/Source/Abstractions/CallWindowProtocol.swift +3 -6
  54. package/native-bridge/iOS/Source/Abstractions/KaleyraVideoSDKProtocol.swift +20 -0
  55. package/native-bridge/iOS/Source/AccessToken/AccessTokenRequester.swift +0 -1
  56. package/native-bridge/iOS/Source/AccessToken/TokenProvider.swift +1 -2
  57. package/native-bridge/iOS/Source/Broadcast/BroadcastConfigurationPlistReader.swift +0 -1
  58. package/native-bridge/iOS/Source/Concurrency/DispatchQueue+isMain.swift +0 -1
  59. package/native-bridge/iOS/Source/Concurrency/MainQueueDispatcher.swift +0 -1
  60. package/native-bridge/iOS/Source/Concurrency/MainQueueRelay.swift +0 -1
  61. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Equatable.swift +0 -1
  62. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+KaleyraVideoSDK.swift +13 -0
  63. package/native-bridge/iOS/Source/DTOs/{AudioCallType+Bandyer.swift → AudioCallType+KaleyraVideoSDK.swift} +2 -3
  64. package/native-bridge/iOS/Source/DTOs/CallOptions+Equatable.swift +0 -1
  65. package/native-bridge/iOS/Source/DTOs/CallOptions+KaleyraVideoSDK.swift +12 -0
  66. package/native-bridge/iOS/Source/DTOs/{CallType+Bandyer.swift → CallType+KaleyraVideoSDK.swift} +2 -3
  67. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+KaleyraVideoSDK.swift +12 -0
  68. package/native-bridge/iOS/Source/DTOs/DTOs.swift +3 -25
  69. package/native-bridge/iOS/Source/DTOs/{Environment+Bandyer.swift → Environment+KaleyraVideoSDK.swift} +2 -3
  70. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+KaleyraVideoSDK.swift +113 -0
  71. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+UserInterfacePresenterConfiguration.swift +0 -1
  72. package/native-bridge/iOS/Source/DTOs/RecordingType+KaleyraVideoSDK.swift +19 -0
  73. package/native-bridge/iOS/Source/DTOs/{Region+Bandyer.swift → Region+KaleyraVideoSDK.swift} +2 -3
  74. package/native-bridge/iOS/Source/DTOs/UserDetails+Decodable.swift +4 -10
  75. package/native-bridge/iOS/Source/DTOs/UserDetails+KaleyraVideoSDK.swift +15 -0
  76. package/native-bridge/iOS/Source/Events/Reporters/CallClientEventsReporter.swift +41 -16
  77. package/native-bridge/iOS/Source/Events/Reporters/ChatClientEventsReporter.swift +22 -17
  78. package/native-bridge/iOS/Source/Events/Reporters/ClientState.swift +14 -42
  79. package/native-bridge/iOS/Source/Events/Reporters/EventsReporter.swift +17 -13
  80. package/native-bridge/iOS/Source/Extensions/URL+FromString.swift +0 -2
  81. package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridge.swift +14 -43
  82. package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridgeError.swift +0 -1
  83. package/native-bridge/iOS/Source/UI/KaleyraVideoSDKUserInterfacePresenter.swift +68 -100
  84. package/native-bridge/iOS/Source/UI/Presenters/PresentingViewControllerViewControllerPresenter.swift +0 -1
  85. package/native-bridge/iOS/Source/UI/Presenters/ViewControllerPresenter.swift +0 -1
  86. package/native-bridge/iOS/Source/UI/Presenters/WindowViewControllerPresenter.swift +0 -1
  87. package/native-bridge/iOS/Source/UI/UserInterfacePresenter+MainQueueRelay.swift +0 -1
  88. package/native-bridge/iOS/Source/UI/UserInterfacePresenter.swift +0 -1
  89. package/native-bridge/iOS/Source/User Details/Cache/UsersDetailsCache.swift +6 -7
  90. package/native-bridge/iOS/Source/User Details/Providers/UsersDetailsProvider.swift +6 -19
  91. package/package.json +12 -11
  92. package/src/KaleyraVideo.ts +0 -42
  93. package/video-react-native-module.podspec +4 -4
  94. package/lib/commonjs/native-bridge/TypeScript/UserDetailsFormatValidator.js +0 -32
  95. package/lib/commonjs/native-bridge/TypeScript/types/UserDetailsFormat.js +0 -4
  96. package/lib/module/native-bridge/TypeScript/UserDetailsFormatValidator.js +0 -28
  97. package/lib/module/native-bridge/TypeScript/types/UserDetailsFormat.js +0 -3
  98. package/lib/typescript/native-bridge/TypeScript/UserDetailsFormatValidator.d.ts +0 -4
  99. package/lib/typescript/native-bridge/TypeScript/types/UserDetailsFormat.d.ts +0 -19
  100. package/native-bridge/TypeScript/UserDetailsFormatValidator.ts +0 -35
  101. package/native-bridge/TypeScript/types/UserDetailsFormat.ts +0 -23
  102. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetailsFormatter.kt +0 -59
  103. package/native-bridge/iOS/Source/Abstractions/BandyerSDKProtocol.swift +0 -25
  104. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Bandyer.swift +0 -14
  105. package/native-bridge/iOS/Source/DTOs/CallOptions+Bandyer.swift +0 -14
  106. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Intent.swift +0 -17
  107. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+Bandyer.swift +0 -158
  108. package/native-bridge/iOS/Source/DTOs/RecordingType+Bandyer.swift +0 -33
  109. package/native-bridge/iOS/Source/DTOs/UserDetails+Bandyer.swift +0 -18
  110. package/native-bridge/iOS/Source/DTOs/UserDetailsFormat+Decodable.swift +0 -19
  111. package/native-bridge/iOS/Source/Events/Reporters/PushTokenEventsReporter.swift +0 -34
  112. package/native-bridge/iOS/Source/User Details/Formatter/FormatterProxy.swift +0 -16
  113. package/native-bridge/iOS/Source/User Details/Formatter/UserDetailsFormatter.swift +0 -83
@@ -2,60 +2,32 @@
2
2
  // See LICENSE for licensing information
3
3
 
4
4
  import Foundation
5
- import Bandyer
5
+ import KaleyraVideoSDK
6
6
 
7
- @available(iOS 12.0, *)
8
7
  enum ClientState: String {
9
- case stopped = "stopped"
8
+ case disconnected = "disconnected"
10
9
  case connecting = "connecting"
11
- case ready = "ready"
12
- case paused = "paused"
10
+ case connected = "connected"
13
11
  case reconnecting = "reconnecting"
14
12
  case failed = "failed"
15
13
  }
16
14
 
17
- @available(iOS 12.0, *)
18
15
  extension ClientState {
19
16
 
20
- init?(clientState: CallClientState) {
21
- switch clientState {
22
- case .stopped:
23
- self = .stopped
24
- case .starting:
17
+ init?(state: KaleyraVideoSDK.ClientState) {
18
+ switch state {
19
+ case .disconnected(error: let error):
20
+ if error != nil {
21
+ self = .failed
22
+ } else {
23
+ self = .disconnected
24
+ }
25
+ case .connecting:
25
26
  self = .connecting
26
- case .running:
27
- self = .ready
28
- case .resuming:
29
- self = .connecting
30
- case .paused:
31
- self = .paused
32
- case .reconnecting:
33
- self = .reconnecting
34
- case .failed:
35
- self = .failed
36
- default:
37
- return nil
38
- }
39
- }
40
-
41
- init?(clientState: ChatClientState) {
42
- switch clientState {
43
- case .stopped:
44
- self = .stopped
45
- case .starting:
46
- self = .connecting
47
- case .running:
48
- self = .ready
49
- case .resuming:
50
- self = .connecting
51
- case .paused:
52
- self = .paused
27
+ case .connected:
28
+ self = .connected
53
29
  case .reconnecting:
54
30
  self = .reconnecting
55
- case .failed:
56
- self = .failed
57
- default:
58
- return nil
59
31
  }
60
32
  }
61
33
  }
@@ -2,29 +2,33 @@
2
2
  // See LICENSE for licensing information
3
3
 
4
4
  import Foundation
5
- import Bandyer
5
+ import KaleyraVideoSDK
6
6
 
7
- @available(iOS 12.0, *)
8
7
  protocol SDKEventReporter {
9
8
 
9
+ var lastVoIPToken: String? { get }
10
+
10
11
  func start()
11
12
  func stop()
12
13
  }
13
14
 
14
- @available(iOS 12.0, *)
15
15
  class EventsReporter: SDKEventReporter {
16
16
 
17
17
  // MARK: - Properties
18
18
 
19
19
  private let emitter: EventEmitter
20
- private let sdk: BandyerSDKProtocol
20
+ private let sdk: KaleyraVideoSDKProtocol
21
21
 
22
22
  private(set) var callClientEventReporter: CallClientEventsReporter?
23
23
  private(set) var chatClientEventReporter: ChatClientEventsReporter?
24
24
 
25
+ var lastVoIPToken: String? {
26
+ callClientEventReporter?.lastVoIPToken
27
+ }
28
+
25
29
  // MARK: - Init
26
30
 
27
- init(emitter: EventEmitter, sdk: BandyerSDKProtocol) {
31
+ init(emitter: EventEmitter, sdk: KaleyraVideoSDKProtocol) {
28
32
  self.emitter = emitter
29
33
  self.sdk = sdk
30
34
  }
@@ -32,21 +36,21 @@ class EventsReporter: SDKEventReporter {
32
36
  // MARK: - Start Reporting Events
33
37
 
34
38
  func start() {
35
- startReportingCallClientEvents(sdk.callClient)
36
- startReportingChatClientEvents(sdk.chatClient)
39
+ startReportingCallClientEvents(sdk.conference)
40
+ startReportingChatClientEvents(sdk.conversation)
37
41
  }
38
42
 
39
- private func startReportingCallClientEvents(_ callClient: CallClient) {
40
- guard callClientEventReporter == nil else { return }
43
+ private func startReportingCallClientEvents(_ conference: Conference?) {
44
+ guard let conference, callClientEventReporter == nil else { return }
41
45
 
42
- callClientEventReporter = .init(client: callClient, emitter: emitter)
46
+ callClientEventReporter = .init(conference: conference, emitter: emitter)
43
47
  callClientEventReporter?.start()
44
48
  }
45
49
 
46
- private func startReportingChatClientEvents(_ chatClient: ChatClient) {
47
- guard chatClientEventReporter == nil else { return }
50
+ private func startReportingChatClientEvents(_ conversation: Conversation?) {
51
+ guard let conversation, chatClientEventReporter == nil else { return }
48
52
 
49
- chatClientEventReporter = .init(client: chatClient, emitter: emitter)
53
+ chatClientEventReporter = .init(conversation: conversation, emitter: emitter)
50
54
  chatClientEventReporter?.start()
51
55
  }
52
56
 
@@ -3,7 +3,6 @@
3
3
 
4
4
  import Foundation
5
5
 
6
- @available(iOS 12.0, *)
7
6
  extension URL {
8
7
 
9
8
  static func fromString(_ string: String) throws -> URL {
@@ -14,7 +13,6 @@ extension URL {
14
13
  }
15
14
  }
16
15
 
17
- @available(iOS 12.0, *)
18
16
  private extension String {
19
17
 
20
18
  func unescape() -> String {
@@ -2,41 +2,35 @@
2
2
  // See LICENSE for licensing information
3
3
 
4
4
  import Foundation
5
- import Bandyer
5
+ import KaleyraVideoSDK
6
6
 
7
- @available(iOS 12.0, *)
8
7
  class VideoHybridNativeBridge {
9
8
 
10
9
  // MARK: - Properties
11
10
 
12
- private let sdk: BandyerSDKProtocol
11
+ private let sdk: KaleyraVideoSDKProtocol
13
12
  private let reporter: SDKEventReporter
14
13
  private let emitter: EventEmitter
15
14
  private let uiPresenter: UserInterfacePresenter
16
- private let formatterProxy: FormatterProxy
17
15
  private let usersCache: UsersDetailsCache
18
16
  private let accessTokenProviderFactory: () -> AccessTokenProvider
19
17
 
20
- private var pushTokenEventReporter: PushTokenEventsReporter?
21
-
22
18
  private var isConfigured: Bool {
23
19
  sdk.config != nil
24
20
  }
25
21
 
26
22
  // MARK: - Init
27
23
 
28
- init(sdk: BandyerSDKProtocol,
24
+ init(sdk: KaleyraVideoSDKProtocol,
29
25
  reporter: SDKEventReporter,
30
26
  emitter: EventEmitter,
31
27
  uiPresenter: UserInterfacePresenter,
32
- formatterProxy: FormatterProxy,
33
28
  usersCache: UsersDetailsCache,
34
29
  accessTokenProviderFactory: @escaping () -> AccessTokenProvider) {
35
30
  self.sdk = sdk
36
31
  self.reporter = reporter
37
32
  self.emitter = emitter
38
33
  self.uiPresenter = uiPresenter
39
- self.formatterProxy = formatterProxy
40
34
  self.usersCache = usersCache
41
35
  self.accessTokenProviderFactory = accessTokenProviderFactory
42
36
  }
@@ -44,14 +38,12 @@ class VideoHybridNativeBridge {
44
38
  convenience init(emitter: EventEmitter,
45
39
  rootViewController: UIViewController?,
46
40
  accessTokenProviderFactory: @escaping () -> AccessTokenProvider) {
47
- let sdk = BandyerSDK.instance
48
- let formatterProxy = FormatterProxy()
41
+ let sdk = KaleyraVideo.instance
49
42
 
50
43
  self.init(sdk: sdk,
51
44
  reporter: EventsReporter(emitter: emitter, sdk: sdk),
52
45
  emitter: emitter,
53
- uiPresenter: MainQueueRelay(KaleyraVideoSDKUserInterfacePresenter(rootViewController: rootViewController, formatter: formatterProxy)),
54
- formatterProxy: formatterProxy,
46
+ uiPresenter: MainQueueRelay(KaleyraVideoSDKUserInterfacePresenter(rootViewController: rootViewController)),
55
47
  usersCache: .init(),
56
48
  accessTokenProviderFactory: accessTokenProviderFactory)
57
49
  }
@@ -59,16 +51,17 @@ class VideoHybridNativeBridge {
59
51
  // MARK: - Plugin Implementation
60
52
 
61
53
  func configureSDK(_ config: KaleyraVideoConfiguration) throws {
62
- configurePushEventsReporterIfNeeded(config: config)
63
54
 
64
55
  if config.logEnabled ?? false {
65
- BandyerSDK.logLevel = .all
56
+ KaleyraVideo.logLevel = .all
57
+
66
58
  }
67
59
 
68
- let sdkConfig = try config.makeBandyerConfig(registryDelegate: pushTokenEventReporter)
60
+ let sdkConfig = try config.makeKaleyraVideoSDKConfig()
69
61
 
70
- sdk.userDetailsProvider = UsersDetailsProvider(cache: usersCache, formatter: formatterProxy)
71
- sdk.configure(sdkConfig)
62
+ sdk.userDetailsProvider = UsersDetailsProvider(cache: usersCache)
63
+ try sdk.configure(sdkConfig)
64
+ sdk.conference?.settings.tools = config.makeToolsConfig()
72
65
 
73
66
  reporter.start()
74
67
 
@@ -78,23 +71,19 @@ class VideoHybridNativeBridge {
78
71
  func callClientStateDescription() throws -> String {
79
72
  try checkIsConfigured()
80
73
 
81
- return sdk.callClient.state.description
74
+ return sdk.conference?.state.description ?? ""
82
75
  }
83
76
 
84
77
  func connect(userID: String) throws {
85
78
  try checkIsConfigured()
86
79
  let provider = accessTokenProviderFactory()
87
- sdk.connect(Bandyer.Session(userId: userID, tokenProvider: provider))
80
+ try sdk.connect(userId: userID, provider: provider)
88
81
  }
89
82
 
90
83
  func getCurrentVoIPPushToken() throws -> String? {
91
84
  try checkIsConfigured()
92
85
 
93
- return pushTokenEventReporter?.lastToken
94
- }
95
-
96
- func setUserDetailsFormat(_ format: UserDetailsFormat) {
97
- formatterProxy.formatter = UserDetailsFormatter(format: format.userDetailsFormatDefault)
86
+ return reporter.lastVoIPToken
98
87
  }
99
88
 
100
89
  func startCall(_ options: CreateCallOptions) throws {
@@ -129,26 +118,12 @@ class VideoHybridNativeBridge {
129
118
  usersCache.purge()
130
119
  }
131
120
 
132
- func verifyCurrentCall(_ verify: Bool) throws {
133
- try checkIsConfigured()
134
- guard let call = sdk.callRegistry.calls.first else { return }
135
-
136
- sdk.verifiedUser(verify, for: call, completion: nil)
137
- }
138
-
139
121
  func reset() {
140
122
  sdk.reset()
141
123
  }
142
124
 
143
125
  // MARK: - Private Functions
144
126
 
145
- private func configurePushEventsReporterIfNeeded(config: KaleyraVideoConfiguration) {
146
- guard config.voipStrategy == .automatic else { return }
147
- guard pushTokenEventReporter == nil else { return }
148
-
149
- pushTokenEventReporter = PushTokenEventsReporter(emitter: emitter)
150
- }
151
-
152
127
  private func checkIsConfigured() throws {
153
128
  guard isConfigured else {
154
129
  throw VideoHybridNativeBridgeError.sdkNotConfiguredError()
@@ -161,10 +136,6 @@ class VideoHybridNativeBridge {
161
136
  debugPrint("clearUserCache() is not supported for iOS platform.")
162
137
  }
163
138
 
164
- func handlePushNotificationPayload(_ json: String) {
165
- debugPrint("handlePushNotificationPayload(_) is not supported for iOS platform - json: \(json)")
166
- }
167
-
168
139
  func setDisplayModeForCurrentCall(_ mode: String) {
169
140
  debugPrint("setDisplayModeForCurrentCall(_) is not supported for iOS platform - mode: \(mode)")
170
141
  }
@@ -3,7 +3,6 @@
3
3
 
4
4
  import Foundation
5
5
 
6
- @available(iOS 12.0, *)
7
6
  struct VideoHybridNativeBridgeError: Error, Equatable {
8
7
 
9
8
  private enum ErrorCodes: String {
@@ -2,9 +2,9 @@
2
2
  // See LICENSE for licensing information
3
3
 
4
4
  import Foundation
5
- import Bandyer
5
+ import Combine
6
+ import KaleyraVideoSDK
6
7
 
7
- @available(iOS 12.0, *)
8
8
  struct UserInterfacePresenterConfiguration: Equatable {
9
9
 
10
10
  enum ChatAudioButtonConfiguration: Equatable {
@@ -32,48 +32,44 @@ struct UserInterfacePresenterConfiguration: Equatable {
32
32
  }
33
33
  }
34
34
 
35
- @available(iOS 12.0, *)
36
35
  class KaleyraVideoSDKUserInterfacePresenter: NSObject, UserInterfacePresenter {
37
36
 
38
37
  // MARK: - Properties
39
38
 
40
- private let sdk: BandyerSDKProtocol
39
+ private let sdk: KaleyraVideoSDKProtocol
41
40
  private let viewControllerPresenter: ViewControllerPresenter
42
41
  private let callWindow: CallWindowProtocol
43
- private let formatter: Formatter
44
42
 
45
43
  private var configuration = UserInterfacePresenterConfiguration(showsFeedbackWhenCallEnds: false,
46
44
  chatAudioButtonConf: .disabled,
47
45
  chatVideoButtonConf: .disabled)
48
46
 
47
+ private lazy var subscriptions = Set<AnyCancellable>()
48
+
49
49
  // MARK: - Init
50
50
 
51
- init(sdk: BandyerSDKProtocol,
51
+ init(sdk: KaleyraVideoSDKProtocol,
52
52
  viewControllerPresenter: ViewControllerPresenter,
53
- callWindow: CallWindowProtocol,
54
- formatter: Formatter) {
53
+ callWindow: CallWindowProtocol) {
55
54
  self.sdk = sdk
56
55
  self.viewControllerPresenter = viewControllerPresenter
57
56
  self.callWindow = callWindow
58
- self.formatter = formatter
59
57
 
60
58
  super.init()
61
-
62
- setupCallWindow()
63
59
  }
64
60
 
65
- convenience init(rootViewController: UIViewController?, formatter: Formatter) {
66
- self.init(sdk: BandyerSDK.instance,
61
+ convenience init(rootViewController: UIViewController?) {
62
+ self.init(sdk: KaleyraVideo.instance,
67
63
  viewControllerPresenter: KaleyraVideoSDKUserInterfacePresenter.makeViewControllerPresenter(rootViewController),
68
- callWindow: KaleyraVideoSDKUserInterfacePresenter.makeCallWindow(),
69
- formatter: formatter)
64
+ callWindow: KaleyraVideoSDKUserInterfacePresenter.makeCallWindow())
70
65
  }
71
66
 
72
67
  private static func makeCallWindow() -> CallWindow {
73
- guard let instance = CallWindow.instance else {
74
- return CallWindow()
68
+ guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else {
69
+ return .init()
75
70
  }
76
- return instance
71
+
72
+ return .init(windowScene: windowScene)
77
73
  }
78
74
 
79
75
  private static func makeViewControllerPresenter(_ rootViewController: UIViewController?) -> ViewControllerPresenter {
@@ -86,19 +82,15 @@ class KaleyraVideoSDKUserInterfacePresenter: NSObject, UserInterfacePresenter {
86
82
 
87
83
  // MARK: - Setup
88
84
 
89
- private func setupCallWindow() {
90
- callWindow.callDelegate = self
91
- }
92
-
93
85
  private func setupSDK() {
94
- sdk.callClient.addIncomingCall(observer: self, queue: .main)
86
+ sdk.conference?.callPublisher.compactMap({ $0 }).receive(on: RunLoop.main).sink { [weak self] call in
87
+ self?.present(call: call)
88
+ }.store(in: &subscriptions)
95
89
  }
96
90
 
97
91
  private func setupNotificationCoordinator() {
98
- sdk.notificationsCoordinator?.chatListener = self
99
- sdk.notificationsCoordinator?.fileShareListener = self
100
- sdk.notificationsCoordinator?.formatter = formatter
101
- sdk.notificationsCoordinator?.start()
92
+ sdk.conversation?.notifications.delegate = self
93
+ sdk.conversation?.notifications.start()
102
94
  }
103
95
 
104
96
  // MARK: - Configuration
@@ -113,46 +105,59 @@ class KaleyraVideoSDKUserInterfacePresenter: NSObject, UserInterfacePresenter {
113
105
  // MARK: - Presenting Call UI
114
106
 
115
107
  func presentCall(_ options: CreateCallOptions) {
116
- let intent = options.makeStartOutgoingCallIntent()
117
- handleCallIntent(intent)
108
+ startCall(callees: options.callees, options: options.makeCallOptions())
118
109
  }
119
110
 
120
111
  func presentCall(_ url: URL) {
121
- let intent = JoinURLIntent(url: url)
122
- handleCallIntent(intent)
112
+ sdk.conference?.join(url: url) { result in
113
+ do {
114
+ try result.get()
115
+ } catch {
116
+ debugPrint("An error occurred while starting join call \(error)")
117
+ }
118
+ }
123
119
  }
124
120
 
125
- private func makeCallViewControllerConfiguration() -> CallViewControllerConfiguration {
126
- let builder = CallViewControllerConfigurationBuilder().withFormatter(formatter)
127
-
128
- if configuration.showsFeedbackWhenCallEnds {
129
- _ = builder.withFeedbackEnabled()
121
+ private func startCall(callees: [String], options: KaleyraVideoSDK.CallOptions) {
122
+ sdk.conference?.call(callees: callees,
123
+ options: options) { result in
124
+ do {
125
+ try result.get()
126
+ } catch {
127
+ debugPrint("An error occurred while starting call \(error)")
128
+ }
130
129
  }
130
+ }
131
131
 
132
- return builder.build()
132
+ private func present(call: Call) {
133
+ let controller = CallViewController(call: call, configuration: makeCallViewControllerConfiguration())
134
+ controller.delegate = self
135
+ callWindow.makeKeyAndVisible()
136
+ callWindow.set(rootViewController: controller, animated: true, completion: nil)
137
+ }
138
+
139
+ private func makeCallViewControllerConfiguration() -> CallViewController.Configuration {
140
+ .init(feedback: configuration.showsFeedbackWhenCallEnds ? .init() : nil)
133
141
  }
134
142
 
135
143
  // MARK: - Presenting Chat UI
136
144
 
137
145
  func presentChat(with userID: String) {
138
- let intent = OpenChatIntent.openChat(with: userID)
146
+ let intent = ChatViewController.Intent.participant(id: userID)
139
147
  handleChatIntent(intent)
140
148
  }
141
149
 
142
- private func makeChannelViewController(intent: OpenChatIntent) -> ChannelViewController {
143
- let config = ChannelViewControllerConfiguration(audioButton: configuration.chatHasAudioButton,
144
- videoButton: configuration.chatHasVideoButton,
145
- formatter: formatter)
146
- let controller = ChannelViewController()
150
+ private func makeChannelViewController(intent: ChatViewController.Intent) -> ChatViewController {
151
+ let controller = ChatViewController(intent: intent,
152
+ configuration: .init(audioButton: configuration.chatHasAudioButton,
153
+ videoButton: configuration.chatHasVideoButton))
147
154
  controller.delegate = self
148
- controller.configuration = config
149
- controller.intent = intent
150
155
  return controller
151
156
  }
152
157
 
153
158
  // MARK: - Intents
154
159
 
155
- private func handleChatIntent(_ intent: OpenChatIntent) {
160
+ private func handleChatIntent(_ intent: ChatViewController.Intent) {
156
161
  let channelViewController = makeChannelViewController(intent: intent)
157
162
 
158
163
  let continueWith: (() -> Void) = { [weak self] in
@@ -165,85 +170,48 @@ class KaleyraVideoSDKUserInterfacePresenter: NSObject, UserInterfacePresenter {
165
170
  continueWith()
166
171
  }
167
172
  }
168
-
169
- private func handleCallIntent(_ intent: Intent) {
170
- callWindow.setConfiguration(makeCallViewControllerConfiguration())
171
- callWindow.presentCallViewController(for: intent) { [weak self] error in
172
- guard let self = self else { return }
173
- guard error != nil else { return }
174
-
175
- self.viewControllerPresenter.displayAlert(title: "Warning", message: "Another call ongoing", dismissButtonText: "OK")
176
- }
177
- }
178
173
  }
179
174
 
180
- // MARK: - CallWindowDelegate
175
+ // MARK: - CallViewControllerDelegate
181
176
 
182
- @available(iOS 12.0, *)
183
- extension KaleyraVideoSDKUserInterfacePresenter: CallWindowDelegate {
177
+ extension KaleyraVideoSDKUserInterfacePresenter: CallViewControllerDelegate {
184
178
 
185
- func callWindowDidFinish(_ window: Bandyer.CallWindow) {
186
- callWindow.isHidden = true
187
- }
188
-
189
- func callWindow(_ window: CallWindow, openChatWith intent: OpenChatIntent) {
190
- handleChatIntent(intent)
191
- }
192
- }
193
-
194
- // MARK: - IncomingCallObserver
195
-
196
- @available(iOS 12.0, *)
197
- extension KaleyraVideoSDKUserInterfacePresenter: IncomingCallObserver {
198
-
199
- func callClient(_ client: Bandyer.CallClient, didReceiveIncomingCall call: Bandyer.Call) {
200
- handleCallIntent(HandleIncomingCallIntent(call: call))
179
+ func callViewControllerDidFinish(_ controller: KaleyraVideoSDK.CallViewController) {
180
+ callWindow.set(rootViewController: nil, animated: true) { _ in
181
+ self.callWindow.isHidden = true
182
+ }
201
183
  }
202
184
  }
203
185
 
204
186
  // MARK: - InAppChatNotificationTouchListener
205
187
 
206
- @available(iOS 12.0, *)
207
- extension KaleyraVideoSDKUserInterfacePresenter: InAppChatNotificationTouchListener {
188
+ extension KaleyraVideoSDKUserInterfacePresenter: InAppNotificationsDelegate {
208
189
 
209
- func onTouch(_ notification: Bandyer.ChatNotification) {
210
- guard let intent = OpenChatIntent.openChat(from: notification) else { return }
190
+ func onTouch(_ notification: ChatNotification) {
191
+ let intent = ChatViewController.Intent.chat(id: notification.chatId)
211
192
  handleChatIntent(intent)
212
193
  }
213
194
  }
214
195
 
215
- // MARK: - InAppFileShareNotificationTouchListener
216
-
217
- @available(iOS 12.0, *)
218
- extension KaleyraVideoSDKUserInterfacePresenter: InAppFileShareNotificationTouchListener {
219
-
220
- func onTouch(_ notification: Bandyer.FileShareNotification) {
221
- callWindow.presentCallViewController(for: OpenDownloadsIntent()) { _ in }
222
- }
223
- }
224
-
225
196
  // MARK: - ChannelViewControllerDelegate
226
197
 
227
- @available(iOS 12.0, *)
228
- extension KaleyraVideoSDKUserInterfacePresenter: ChannelViewControllerDelegate {
198
+ extension KaleyraVideoSDKUserInterfacePresenter: ChatViewControllerDelegate {
229
199
 
230
- func channelViewControllerDidFinish(_ controller: Bandyer.ChannelViewController) {
200
+ func chatViewControllerDidFinish(_ controller: KaleyraVideoSDK.ChatViewController) {
231
201
  viewControllerPresenter.dismiss(controller, animated: true, completion: nil)
232
202
  }
233
203
 
234
- func channelViewController(_ controller: Bandyer.ChannelViewController, didTapAudioCallWith users: [String]) {
204
+ func chatViewControllerDidTapAudioCallButton(_ controller: KaleyraVideoSDK.ChatViewController) {
235
205
  guard case let .enabled(audioOptions) = configuration.chatAudioButtonConf else { return }
236
206
 
237
- let options = audioOptions.callOptions
238
- let intent = StartOutgoingCallIntent(callees: users, options: options)
239
- handleCallIntent(intent)
207
+ startCall(callees: controller.participants, options: .init(type: audioOptions.type.callType,
208
+ recording: audioOptions.recordingType?.callRecordingType))
240
209
  }
241
210
 
242
- func channelViewController(_ controller: Bandyer.ChannelViewController, didTapVideoCallWith users: [String]) {
211
+ func chatViewControllerDidTapVideoCallButton(_ controller: KaleyraVideoSDK.ChatViewController) {
243
212
  guard case let .enabled(videoOptions) = configuration.chatVideoButtonConf else { return }
244
213
 
245
- let options = videoOptions.callOptions
246
- let intent = StartOutgoingCallIntent(callees: users, options: options)
247
- handleCallIntent(intent)
214
+ startCall(callees: controller.participants, options: .init(type: .audioVideo,
215
+ recording: videoOptions.recordingType?.callRecordingType))
248
216
  }
249
217
  }
@@ -4,7 +4,6 @@
4
4
  import Foundation
5
5
  import UIKit
6
6
 
7
- @available(iOS 12.0, *)
8
7
  class PresentingViewControllerViewControllerPresenter: ViewControllerPresenter {
9
8
 
10
9
  // MARK: - Properties
@@ -4,7 +4,6 @@
4
4
  import Foundation
5
5
  import UIKit
6
6
 
7
- @available(iOS 12.0, *)
8
7
  protocol ViewControllerPresenter {
9
8
 
10
9
  var isPresenting: Bool { get }
@@ -4,7 +4,6 @@
4
4
  import Foundation
5
5
  import UIKit
6
6
 
7
- @available(iOS 12.0, *)
8
7
  class WindowViewControllerPresenter: ViewControllerPresenter {
9
8
 
10
9
  // MARK: - Nested Types
@@ -3,7 +3,6 @@
3
3
 
4
4
  import Foundation
5
5
 
6
- @available(iOS 12.0, *)
7
6
  extension MainQueueRelay: UserInterfacePresenter where Decoratee: UserInterfacePresenter {
8
7
 
9
8
  func configure(with configuration: UserInterfacePresenterConfiguration) {
@@ -3,7 +3,6 @@
3
3
 
4
4
  import Foundation
5
5
 
6
- @available(iOS 12.0, *)
7
6
  protocol UserInterfacePresenter {
8
7
 
9
8
  func configure(with configuration: UserInterfacePresenterConfiguration)
@@ -2,27 +2,26 @@
2
2
  // See LICENSE for licensing information
3
3
 
4
4
  import Foundation
5
- import Bandyer
5
+ import KaleyraVideoSDK
6
6
 
7
- @available(iOS 12.0, *)
8
7
  class UsersDetailsCache {
9
8
 
10
- private lazy var items = [String : Bandyer.UserDetails]()
9
+ private lazy var items = [String : KaleyraVideoSDK.UserDetails]()
11
10
  private let lock: Locking = NSRecursiveLock()
12
11
 
13
- func setItem(_ item: Bandyer.UserDetails, forKey key: String) {
12
+ func setItem(_ item: KaleyraVideoSDK.UserDetails, forKey key: String) {
14
13
  lock.sync {
15
14
  items[key] = item
16
15
  }
17
16
  }
18
17
 
19
- func setItems(_ items: [Bandyer.UserDetails]) {
18
+ func setItems(_ items: [KaleyraVideoSDK.UserDetails]) {
20
19
  lock.sync {
21
- items.forEach { setItem($0, forKey: $0.userID) }
20
+ items.forEach { setItem($0, forKey: $0.userId) }
22
21
  }
23
22
  }
24
23
 
25
- func item(forKey key: String) -> Bandyer.UserDetails? {
24
+ func item(forKey key: String) -> KaleyraVideoSDK.UserDetails? {
26
25
  lock.sync {
27
26
  items[key]
28
27
  }