@kaleyra/video-react-native-module 1.0.0
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.
- package/LICENSE +165 -0
- package/README.md +292 -0
- package/android/build.gradle +100 -0
- package/android/gradle.properties +9 -0
- package/android/settings.gradle +6 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/assets/kaleyra_video_wrapper_info.txt +1 -0
- package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeAccessTokenProvider.kt +22 -0
- package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeContextContainer.kt +9 -0
- package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeVideoHybridBridge.kt +30 -0
- package/android/src/main/java/com/kaleyra/video_react_native_module/VideoNativeEmitter.kt +45 -0
- package/android/src/main/java/com/kaleyra/video_react_native_module/VideoNativeModule.kt +109 -0
- package/android/src/main/java/com/kaleyra/video_react_native_module/VideoReactPackage.kt +20 -0
- package/index.ts +47 -0
- package/ios/PluginInfo/_KaleyraVideoHybridVersionInfo.swift +31 -0
- package/ios/ReactEvents/ReactNativeEventEmitter.swift +31 -0
- package/ios/ReactEvents/VideoNativeEmitter.m +17 -0
- package/ios/ReactEvents/VideoNativeEmitter.swift +42 -0
- package/ios/ReactNativePlugin-Bridging-Header.h +5 -0
- package/ios/ReactNativePlugin.xcodeproj/project.pbxproj +301 -0
- package/ios/VideoNativeModule.m +45 -0
- package/ios/VideoNativeModule.swift +154 -0
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/native-bridge/TypeScript/Environments.js +41 -0
- package/lib/commonjs/native-bridge/TypeScript/Events.js +46 -0
- package/lib/commonjs/native-bridge/TypeScript/Regions.js +47 -0
- package/lib/commonjs/native-bridge/TypeScript/UserDetailsFormatValidator.js +32 -0
- package/lib/commonjs/native-bridge/TypeScript/errors/IllegalArgumentError.js +12 -0
- package/lib/commonjs/native-bridge/TypeScript/types/AccessTokenRequest.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/AccessTokenResponse.js +36 -0
- package/lib/commonjs/native-bridge/TypeScript/types/AudioCallOptions.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/AudioCallType.js +19 -0
- package/lib/commonjs/native-bridge/TypeScript/types/CallDisplayMode.js +23 -0
- package/lib/commonjs/native-bridge/TypeScript/types/CallKitConfiguration.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/CallOptions.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/CallType.js +23 -0
- package/lib/commonjs/native-bridge/TypeScript/types/ChatToolConfiguration.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/CreateCallOptions.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/Environment.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/IosConfiguration.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/KaleyraVideoConfiguration.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/RecordingType.js +23 -0
- package/lib/commonjs/native-bridge/TypeScript/types/Region.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/ScreenShareToolConfiguration.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/Session.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/Tools.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/UserDetails.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/UserDetailsFormat.js +4 -0
- package/lib/commonjs/native-bridge/TypeScript/types/VoipHandlingStrategy.js +19 -0
- package/lib/commonjs/src/KaleyraVideo.js +259 -0
- package/lib/commonjs/src/ReactNativeEventEmitter.js +40 -0
- package/lib/commonjs/src/events/Events.js +4 -0
- package/lib/module/index.js +2 -0
- package/lib/module/native-bridge/TypeScript/Environments.js +37 -0
- package/lib/module/native-bridge/TypeScript/Events.js +43 -0
- package/lib/module/native-bridge/TypeScript/Regions.js +43 -0
- package/lib/module/native-bridge/TypeScript/UserDetailsFormatValidator.js +28 -0
- package/lib/module/native-bridge/TypeScript/errors/IllegalArgumentError.js +8 -0
- package/lib/module/native-bridge/TypeScript/types/AccessTokenRequest.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/AccessTokenResponse.js +32 -0
- package/lib/module/native-bridge/TypeScript/types/AudioCallOptions.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/AudioCallType.js +16 -0
- package/lib/module/native-bridge/TypeScript/types/CallDisplayMode.js +20 -0
- package/lib/module/native-bridge/TypeScript/types/CallKitConfiguration.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/CallOptions.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/CallType.js +20 -0
- package/lib/module/native-bridge/TypeScript/types/ChatToolConfiguration.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/CreateCallOptions.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/Environment.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/IosConfiguration.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/KaleyraVideoConfiguration.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/RecordingType.js +20 -0
- package/lib/module/native-bridge/TypeScript/types/Region.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/ScreenShareToolConfiguration.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/Session.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/Tools.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/UserDetails.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/UserDetailsFormat.js +3 -0
- package/lib/module/native-bridge/TypeScript/types/VoipHandlingStrategy.js +16 -0
- package/lib/module/src/KaleyraVideo.js +249 -0
- package/lib/module/src/ReactNativeEventEmitter.js +36 -0
- package/lib/module/src/events/Events.js +3 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/native-bridge/TypeScript/Environments.d.ts +28 -0
- package/lib/typescript/native-bridge/TypeScript/Events.d.ts +40 -0
- package/lib/typescript/native-bridge/TypeScript/Regions.d.ts +32 -0
- package/lib/typescript/native-bridge/TypeScript/UserDetailsFormatValidator.d.ts +4 -0
- package/lib/typescript/native-bridge/TypeScript/errors/IllegalArgumentError.d.ts +6 -0
- package/lib/typescript/native-bridge/TypeScript/types/AccessTokenRequest.d.ts +4 -0
- package/lib/typescript/native-bridge/TypeScript/types/AccessTokenResponse.d.ts +12 -0
- package/lib/typescript/native-bridge/TypeScript/types/AudioCallOptions.d.ts +11 -0
- package/lib/typescript/native-bridge/TypeScript/types/AudioCallType.d.ts +13 -0
- package/lib/typescript/native-bridge/TypeScript/types/CallDisplayMode.d.ts +17 -0
- package/lib/typescript/native-bridge/TypeScript/types/CallKitConfiguration.d.ts +26 -0
- package/lib/typescript/native-bridge/TypeScript/types/CallOptions.d.ts +13 -0
- package/lib/typescript/native-bridge/TypeScript/types/CallType.d.ts +17 -0
- package/lib/typescript/native-bridge/TypeScript/types/ChatToolConfiguration.d.ts +15 -0
- package/lib/typescript/native-bridge/TypeScript/types/CreateCallOptions.d.ts +15 -0
- package/lib/typescript/native-bridge/TypeScript/types/Environment.d.ts +9 -0
- package/lib/typescript/native-bridge/TypeScript/types/IosConfiguration.d.ts +23 -0
- package/lib/typescript/native-bridge/TypeScript/types/KaleyraVideoConfiguration.d.ts +33 -0
- package/lib/typescript/native-bridge/TypeScript/types/RecordingType.d.ts +17 -0
- package/lib/typescript/native-bridge/TypeScript/types/Region.d.ts +9 -0
- package/lib/typescript/native-bridge/TypeScript/types/ScreenShareToolConfiguration.d.ts +19 -0
- package/lib/typescript/native-bridge/TypeScript/types/Session.d.ts +16 -0
- package/lib/typescript/native-bridge/TypeScript/types/Tools.d.ts +42 -0
- package/lib/typescript/native-bridge/TypeScript/types/UserDetails.d.ts +29 -0
- package/lib/typescript/native-bridge/TypeScript/types/UserDetailsFormat.d.ts +19 -0
- package/lib/typescript/native-bridge/TypeScript/types/VoipHandlingStrategy.d.ts +13 -0
- package/lib/typescript/src/KaleyraVideo.d.ts +125 -0
- package/lib/typescript/src/ReactNativeEventEmitter.d.ts +15 -0
- package/lib/typescript/src/events/Events.d.ts +37 -0
- package/native-bridge/LICENSE +165 -0
- package/native-bridge/TypeScript/Environments.ts +44 -0
- package/native-bridge/TypeScript/Events.ts +43 -0
- package/native-bridge/TypeScript/Regions.ts +51 -0
- package/native-bridge/TypeScript/UserDetailsFormatValidator.ts +35 -0
- package/native-bridge/TypeScript/errors/IllegalArgumentError.ts +9 -0
- package/native-bridge/TypeScript/types/AccessTokenRequest.ts +7 -0
- package/native-bridge/TypeScript/types/AccessTokenResponse.ts +41 -0
- package/native-bridge/TypeScript/types/AudioCallOptions.ts +15 -0
- package/native-bridge/TypeScript/types/AudioCallType.ts +17 -0
- package/native-bridge/TypeScript/types/CallDisplayMode.ts +22 -0
- package/native-bridge/TypeScript/types/CallKitConfiguration.ts +32 -0
- package/native-bridge/TypeScript/types/CallOptions.ts +18 -0
- package/native-bridge/TypeScript/types/CallType.ts +22 -0
- package/native-bridge/TypeScript/types/ChatToolConfiguration.ts +21 -0
- package/native-bridge/TypeScript/types/CreateCallOptions.ts +20 -0
- package/native-bridge/TypeScript/types/Environment.ts +12 -0
- package/native-bridge/TypeScript/types/IosConfiguration.ts +29 -0
- package/native-bridge/TypeScript/types/KaleyraVideoConfiguration.ts +42 -0
- package/native-bridge/TypeScript/types/RecordingType.ts +22 -0
- package/native-bridge/TypeScript/types/Region.ts +12 -0
- package/native-bridge/TypeScript/types/ScreenShareToolConfiguration.ts +24 -0
- package/native-bridge/TypeScript/types/Session.ts +20 -0
- package/native-bridge/TypeScript/types/Tools.ts +50 -0
- package/native-bridge/TypeScript/types/UserDetails.ts +37 -0
- package/native-bridge/TypeScript/types/UserDetailsFormat.ts +23 -0
- package/native-bridge/TypeScript/types/VoipHandlingStrategy.ts +17 -0
- package/native-bridge/android/build.gradle +72 -0
- package/native-bridge/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/native-bridge/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/native-bridge/android/gradle.properties +22 -0
- package/native-bridge/android/gradlew +234 -0
- package/native-bridge/android/gradlew.bat +89 -0
- package/native-bridge/android/settings.gradle +1 -0
- package/native-bridge/android/src/main/AndroidManifest.xml +1 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/AccessTokenProvider.kt +8 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/CallOptionsProxy.kt +9 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ContextContainer.kt +10 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/DTOs.kt +407 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/SDKAccessTokenProviderProxy.kt +16 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoHybridBridge.kt +21 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoSDKHybridBridge.kt +64 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/configurator/CachedSDKConfigurator.kt +15 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/configurator/VideoSDKConfigurator.kt +46 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/connector/CachedUserConnector.kt +15 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/connector/VideoSDKCachedUserConnector.kt +60 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/Events.kt +29 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/EventsEmitter.kt +8 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/EventsReporter.kt +9 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CallEventsReporter.kt +54 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ChatEventsReporter.kt +43 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CrossPlatformModuleStatus.kt +29 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ModuleEventsReporter.kt +34 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/SDKEventsReporter.kt +63 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/CallDisplayExtension.kt +15 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ConfigurationExtension.kt +39 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/EnvironmentExtension.kt +12 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RecordingTypeExtension.kt +15 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RegionExtension.kt +13 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ScreenShareToolConfigurationExtension.kt +15 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ToolsExtension.kt +95 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/UserExtensions.kt +35 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/notifications/KaleyraVideoNotificationReceiver.kt +139 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/notifications/KaleyraVideoNotificationService.kt +85 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/ConfigurationEntity.kt +27 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/ConnectedUserEntity.kt +30 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/Converters.kt +25 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsDao.kt +21 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsEntity.kt +22 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/VideoHybridBridgeRepository.kt +39 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ui/SDKUserInterfacePresenter.kt +49 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ui/UserInterfacePresenter.kt +14 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetails.kt +18 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetailsFormatter.kt +59 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/SDKCachedUserDetails.kt +74 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/utils/CaseInsensitiveEnumTypeAdapterFactory.kt +48 -0
- package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/utils/TLSSocketFactoryCompat.kt +76 -0
- package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.pbxproj +1399 -0
- package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/xcshareddata/IDETemplateMacros.plist +9 -0
- package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/xcshareddata/xcschemes/KaleyraVideoHybridNativeBridge.xcscheme +79 -0
- package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcworkspace/contents.xcworkspacedata +10 -0
- package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native-bridge/iOS/Podfile +28 -0
- package/native-bridge/iOS/Podfile.lock +20 -0
- package/native-bridge/iOS/Source/Abstractions/BandyerSDKProtocol.swift +24 -0
- package/native-bridge/iOS/Source/Abstractions/CallWindowProtocol.swift +18 -0
- package/native-bridge/iOS/Source/AccessToken/AccessTokenRequester.swift +9 -0
- package/native-bridge/iOS/Source/AccessToken/TokenProvider.swift +78 -0
- package/native-bridge/iOS/Source/Broadcast/BroadcastConfigurationPlistReader.swift +49 -0
- package/native-bridge/iOS/Source/Concurrency/DispatchQueue+isMain.swift +19 -0
- package/native-bridge/iOS/Source/Concurrency/Lock.swift +21 -0
- package/native-bridge/iOS/Source/Concurrency/MainQueueDispatcher.swift +23 -0
- package/native-bridge/iOS/Source/Concurrency/MainQueueRelay.swift +18 -0
- package/native-bridge/iOS/Source/DTOs/AccessTokenRequest+Encodable.swift +27 -0
- package/native-bridge/iOS/Source/DTOs/AccessTokenResponse+Decodable.swift +24 -0
- package/native-bridge/iOS/Source/DTOs/Array+JSON.swift +6 -0
- package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Bandyer.swift +14 -0
- package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Decodable.swift +18 -0
- package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Equatable.swift +12 -0
- package/native-bridge/iOS/Source/DTOs/AudioCallType+Bandyer.swift +18 -0
- package/native-bridge/iOS/Source/DTOs/AudioCallType+Decodable.swift +25 -0
- package/native-bridge/iOS/Source/DTOs/CallKitConfiguration+Decodable.swift +20 -0
- package/native-bridge/iOS/Source/DTOs/CallOptions+Bandyer.swift +14 -0
- package/native-bridge/iOS/Source/DTOs/CallOptions+Decodable.swift +16 -0
- package/native-bridge/iOS/Source/DTOs/CallOptions+Equatable.swift +12 -0
- package/native-bridge/iOS/Source/DTOs/CallType+Bandyer.swift +20 -0
- package/native-bridge/iOS/Source/DTOs/CallType+Decodable.swift +27 -0
- package/native-bridge/iOS/Source/DTOs/ChatToolConfiguration+Decodable.swift +18 -0
- package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Decodable.swift +22 -0
- package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Equatable.swift +13 -0
- package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Intent.swift +17 -0
- package/native-bridge/iOS/Source/DTOs/DTOs.swift +314 -0
- package/native-bridge/iOS/Source/DTOs/Environment+Bandyer.swift +20 -0
- package/native-bridge/iOS/Source/DTOs/Environment+Decodable.swift +16 -0
- package/native-bridge/iOS/Source/DTOs/IosConfiguration+Decodable.swift +18 -0
- package/native-bridge/iOS/Source/DTOs/JSONDecodable.swift +27 -0
- package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+Bandyer.swift +158 -0
- package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+Decodable.swift +28 -0
- package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+UserInterfacePresenterConfiguration.swift +29 -0
- package/native-bridge/iOS/Source/DTOs/RecordingType+Bandyer.swift +33 -0
- package/native-bridge/iOS/Source/DTOs/RecordingType+Decodable.swift +27 -0
- package/native-bridge/iOS/Source/DTOs/Region+Bandyer.swift +22 -0
- package/native-bridge/iOS/Source/DTOs/Region+Decodable.swift +16 -0
- package/native-bridge/iOS/Source/DTOs/ScreenShareToolConfiguration+Decodable.swift +18 -0
- package/native-bridge/iOS/Source/DTOs/Tools+Decodable.swift +24 -0
- package/native-bridge/iOS/Source/DTOs/UserDetails+Bandyer.swift +18 -0
- package/native-bridge/iOS/Source/DTOs/UserDetails+Decodable.swift +28 -0
- package/native-bridge/iOS/Source/DTOs/UserDetailsFormat+Decodable.swift +19 -0
- package/native-bridge/iOS/Source/DTOs/VoipHandlingStrategy+Decodable.swift +25 -0
- package/native-bridge/iOS/Source/Events/Emitter/EventEmitter.swift +8 -0
- package/native-bridge/iOS/Source/Events/Events+CaseIterable.swift +18 -0
- package/native-bridge/iOS/Source/Events/Events+Description.swift +28 -0
- package/native-bridge/iOS/Source/Events/Events.swift +21 -0
- package/native-bridge/iOS/Source/Events/Reporters/CallClientEventsReporter.swift +46 -0
- package/native-bridge/iOS/Source/Events/Reporters/ChatClientEventsReporter.swift +46 -0
- package/native-bridge/iOS/Source/Events/Reporters/ClientState.swift +61 -0
- package/native-bridge/iOS/Source/Events/Reporters/EventsReporter.swift +69 -0
- package/native-bridge/iOS/Source/Events/Reporters/PushTokenEventsReporter.swift +34 -0
- package/native-bridge/iOS/Source/Extensions/URL+FromString.swift +26 -0
- package/native-bridge/iOS/Source/KaleyraVideoHybridNativeBridge.h +14 -0
- package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridge.swift +173 -0
- package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridgeError.swift +33 -0
- package/native-bridge/iOS/Source/UI/KaleyraVideoSDKUserInterfacePresenter.swift +249 -0
- package/native-bridge/iOS/Source/UI/Presenters/PresentingViewControllerViewControllerPresenter.swift +44 -0
- package/native-bridge/iOS/Source/UI/Presenters/ViewControllerPresenter.swift +17 -0
- package/native-bridge/iOS/Source/UI/Presenters/WindowViewControllerPresenter.swift +111 -0
- package/native-bridge/iOS/Source/UI/UserInterfacePresenter+MainQueueRelay.swift +30 -0
- package/native-bridge/iOS/Source/UI/UserInterfacePresenter.swift +14 -0
- package/native-bridge/iOS/Source/User Details/Cache/UsersDetailsCache.swift +36 -0
- package/native-bridge/iOS/Source/User Details/Formatter/FormatterProxy.swift +47 -0
- package/native-bridge/iOS/Source/User Details/Formatter/UserDetailsFormatter.swift +83 -0
- package/native-bridge/iOS/Source/User Details/Providers/UsersDetailsProvider.swift +39 -0
- package/package.json +147 -0
- package/src/KaleyraVideo.ts +343 -0
- package/src/ReactNativeEventEmitter.ts +51 -0
- package/src/events/Events.ts +46 -0
- package/video-react-native-module.podspec +36 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
import Bandyer
|
|
6
|
+
|
|
7
|
+
@available(iOS 12.0, *)
|
|
8
|
+
enum ClientState: String {
|
|
9
|
+
case stopped = "stopped"
|
|
10
|
+
case connecting = "connecting"
|
|
11
|
+
case ready = "ready"
|
|
12
|
+
case paused = "paused"
|
|
13
|
+
case reconnecting = "reconnecting"
|
|
14
|
+
case failed = "failed"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@available(iOS 12.0, *)
|
|
18
|
+
extension ClientState {
|
|
19
|
+
|
|
20
|
+
init?(clientState: CallClientState) {
|
|
21
|
+
switch clientState {
|
|
22
|
+
case .stopped:
|
|
23
|
+
self = .stopped
|
|
24
|
+
case .starting:
|
|
25
|
+
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
|
|
53
|
+
case .reconnecting:
|
|
54
|
+
self = .reconnecting
|
|
55
|
+
case .failed:
|
|
56
|
+
self = .failed
|
|
57
|
+
default:
|
|
58
|
+
return nil
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
import Bandyer
|
|
6
|
+
|
|
7
|
+
@available(iOS 12.0, *)
|
|
8
|
+
protocol SDKEventReporter {
|
|
9
|
+
|
|
10
|
+
func start()
|
|
11
|
+
func stop()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@available(iOS 12.0, *)
|
|
15
|
+
class EventsReporter: SDKEventReporter {
|
|
16
|
+
|
|
17
|
+
// MARK: - Properties
|
|
18
|
+
|
|
19
|
+
private let emitter: EventEmitter
|
|
20
|
+
private let sdk: BandyerSDKProtocol
|
|
21
|
+
|
|
22
|
+
private(set) var callClientEventReporter: CallClientEventsReporter?
|
|
23
|
+
private(set) var chatClientEventReporter: ChatClientEventsReporter?
|
|
24
|
+
|
|
25
|
+
// MARK: - Init
|
|
26
|
+
|
|
27
|
+
init(emitter: EventEmitter, sdk: BandyerSDKProtocol) {
|
|
28
|
+
self.emitter = emitter
|
|
29
|
+
self.sdk = sdk
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// MARK: - Start Reporting Events
|
|
33
|
+
|
|
34
|
+
func start() {
|
|
35
|
+
startReportingCallClientEvents(sdk.callClient)
|
|
36
|
+
startReportingChatClientEvents(sdk.chatClient)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private func startReportingCallClientEvents(_ callClient: CallClient) {
|
|
40
|
+
guard callClientEventReporter == nil else { return }
|
|
41
|
+
|
|
42
|
+
callClientEventReporter = .init(client: callClient, emitter: emitter)
|
|
43
|
+
callClientEventReporter?.start()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private func startReportingChatClientEvents(_ chatClient: ChatClient) {
|
|
47
|
+
guard chatClientEventReporter == nil else { return }
|
|
48
|
+
|
|
49
|
+
chatClientEventReporter = .init(client: chatClient, emitter: emitter)
|
|
50
|
+
chatClientEventReporter?.start()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: - Stop Reporting Events
|
|
54
|
+
|
|
55
|
+
func stop() {
|
|
56
|
+
stopCallClientEventReporter()
|
|
57
|
+
stopChatClientEventReporter()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private func stopCallClientEventReporter() {
|
|
61
|
+
callClientEventReporter?.stop()
|
|
62
|
+
callClientEventReporter = nil
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private func stopChatClientEventReporter() {
|
|
66
|
+
chatClientEventReporter?.stop()
|
|
67
|
+
chatClientEventReporter = nil
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
import PushKit
|
|
6
|
+
|
|
7
|
+
@available(iOS 12.0, *)
|
|
8
|
+
class PushTokenEventsReporter: NSObject, PKPushRegistryDelegate {
|
|
9
|
+
|
|
10
|
+
private let emitter: EventEmitter
|
|
11
|
+
private(set) var lastToken: String?
|
|
12
|
+
|
|
13
|
+
init(emitter: EventEmitter) {
|
|
14
|
+
self.emitter = emitter
|
|
15
|
+
super.init()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// MARK: - Push registry delegate
|
|
19
|
+
|
|
20
|
+
func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) {
|
|
21
|
+
let token = credentials.tokenAsString
|
|
22
|
+
|
|
23
|
+
guard !token.isEmpty else { return }
|
|
24
|
+
|
|
25
|
+
emitter.sendEvent(Events.iOSVoipPushTokenUpdated, args: token)
|
|
26
|
+
|
|
27
|
+
lastToken = token
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
|
|
31
|
+
emitter.sendEvent(Events.iOSVoipPushTokenInvalidated, args: nil)
|
|
32
|
+
lastToken = nil
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
|
|
6
|
+
@available(iOS 12.0, *)
|
|
7
|
+
extension URL {
|
|
8
|
+
|
|
9
|
+
static func fromString(_ string: String) throws -> URL {
|
|
10
|
+
guard let url = URL(string: string.unescape()) else {
|
|
11
|
+
throw VideoHybridNativeBridgeError.unableToInitializeURLError(urlString: string)
|
|
12
|
+
}
|
|
13
|
+
return url
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@available(iOS 12.0, *)
|
|
18
|
+
private extension String {
|
|
19
|
+
|
|
20
|
+
func unescape() -> String {
|
|
21
|
+
guard let unescaped = try? JSONDecoder().decode(String.self, from: self.data(using: .utf8)!) else {
|
|
22
|
+
return self
|
|
23
|
+
}
|
|
24
|
+
return unescaped
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
#import <Foundation/Foundation.h>
|
|
5
|
+
|
|
6
|
+
//! Project version number for KaleyraVideoHybridNativeBridge.
|
|
7
|
+
FOUNDATION_EXPORT double KaleyraVideoHybridNativeBridgeVersionNumber;
|
|
8
|
+
|
|
9
|
+
//! Project version string for KaleyraVideoHybridNativeBridge.
|
|
10
|
+
FOUNDATION_EXPORT const unsigned char KaleyraVideoHybridNativeBridgeVersionString[];
|
|
11
|
+
|
|
12
|
+
// In this header, you should import all the public headers of your framework using statements like #import <KaleyraVideoHybridNativeBridge/PublicHeader.h>
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
import Bandyer
|
|
6
|
+
|
|
7
|
+
@available(iOS 12.0, *)
|
|
8
|
+
class VideoHybridNativeBridge {
|
|
9
|
+
|
|
10
|
+
// MARK: - Properties
|
|
11
|
+
|
|
12
|
+
private let sdk: BandyerSDKProtocol
|
|
13
|
+
private let reporter: SDKEventReporter
|
|
14
|
+
private let emitter: EventEmitter
|
|
15
|
+
private let uiPresenter: UserInterfacePresenter
|
|
16
|
+
private let formatterProxy: FormatterProxy
|
|
17
|
+
private let usersCache: UsersDetailsCache
|
|
18
|
+
private let accessTokenProviderFactory: () -> AccessTokenProvider
|
|
19
|
+
|
|
20
|
+
private var pushTokenEventReporter: PushTokenEventsReporter?
|
|
21
|
+
|
|
22
|
+
private var isConfigured: Bool {
|
|
23
|
+
sdk.config != nil
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// MARK: - Init
|
|
27
|
+
|
|
28
|
+
init(sdk: BandyerSDKProtocol,
|
|
29
|
+
reporter: SDKEventReporter,
|
|
30
|
+
emitter: EventEmitter,
|
|
31
|
+
uiPresenter: UserInterfacePresenter,
|
|
32
|
+
formatterProxy: FormatterProxy,
|
|
33
|
+
usersCache: UsersDetailsCache,
|
|
34
|
+
accessTokenProviderFactory: @escaping () -> AccessTokenProvider) {
|
|
35
|
+
self.sdk = sdk
|
|
36
|
+
self.reporter = reporter
|
|
37
|
+
self.emitter = emitter
|
|
38
|
+
self.uiPresenter = uiPresenter
|
|
39
|
+
self.formatterProxy = formatterProxy
|
|
40
|
+
self.usersCache = usersCache
|
|
41
|
+
self.accessTokenProviderFactory = accessTokenProviderFactory
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
convenience init(emitter: EventEmitter,
|
|
45
|
+
rootViewController: UIViewController?,
|
|
46
|
+
accessTokenProviderFactory: @escaping () -> AccessTokenProvider) {
|
|
47
|
+
let sdk = BandyerSDK.instance
|
|
48
|
+
let formatterProxy = FormatterProxy()
|
|
49
|
+
|
|
50
|
+
self.init(sdk: sdk,
|
|
51
|
+
reporter: EventsReporter(emitter: emitter, sdk: sdk),
|
|
52
|
+
emitter: emitter,
|
|
53
|
+
uiPresenter: MainQueueRelay(KaleyraVideoSDKUserInterfacePresenter(rootViewController: rootViewController, formatter: formatterProxy)),
|
|
54
|
+
formatterProxy: formatterProxy,
|
|
55
|
+
usersCache: .init(),
|
|
56
|
+
accessTokenProviderFactory: accessTokenProviderFactory)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// MARK: - Plugin Implementation
|
|
60
|
+
|
|
61
|
+
func configureSDK(_ config: KaleyraVideoConfiguration) throws {
|
|
62
|
+
configurePushEventsReporterIfNeeded(config: config)
|
|
63
|
+
|
|
64
|
+
if config.logEnabled ?? false {
|
|
65
|
+
BandyerSDK.logLevel = .all
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let sdkConfig = try config.makeBandyerConfig(registryDelegate: pushTokenEventReporter)
|
|
69
|
+
|
|
70
|
+
sdk.userDetailsProvider = UsersDetailsProvider(cache: usersCache, formatter: formatterProxy)
|
|
71
|
+
sdk.configure(sdkConfig)
|
|
72
|
+
|
|
73
|
+
reporter.start()
|
|
74
|
+
|
|
75
|
+
uiPresenter.configure(with: config.uiPresenterConfiguration())
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func callClientStateDescription() throws -> String {
|
|
79
|
+
try checkIsConfigured()
|
|
80
|
+
|
|
81
|
+
return sdk.callClient.state.description
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
func connect(userID: String) throws {
|
|
85
|
+
try checkIsConfigured()
|
|
86
|
+
|
|
87
|
+
let provider = accessTokenProviderFactory()
|
|
88
|
+
sdk.connect(Bandyer.Session(userId: userID, tokenProvider: provider))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
func getCurrentVoIPPushToken() throws -> String? {
|
|
92
|
+
try checkIsConfigured()
|
|
93
|
+
|
|
94
|
+
return pushTokenEventReporter?.lastToken
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
func setUserDetailsFormat(_ format: UserDetailsFormat) {
|
|
98
|
+
formatterProxy.formatter = UserDetailsFormatter(format: format.userDetailsFormatDefault)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
func startCall(_ options: CreateCallOptions) throws {
|
|
102
|
+
try checkIsConfigured()
|
|
103
|
+
|
|
104
|
+
uiPresenter.presentCall(options)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
func startChat(_ userID: String) throws {
|
|
108
|
+
try checkIsConfigured()
|
|
109
|
+
|
|
110
|
+
uiPresenter.presentChat(with: userID)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
func startCallUrl(_ url: URL) throws {
|
|
114
|
+
try checkIsConfigured()
|
|
115
|
+
|
|
116
|
+
uiPresenter.presentCall(url)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
func disconnect() throws {
|
|
120
|
+
try checkIsConfigured()
|
|
121
|
+
|
|
122
|
+
sdk.disconnect()
|
|
123
|
+
reporter.stop()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
func addUsersDetails(_ details: [UserDetails]) {
|
|
127
|
+
usersCache.setItems(details.map(\.bandyerDetails))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
func removeUsersDetails() {
|
|
131
|
+
usersCache.purge()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
func verifyCurrentCall(_ verify: Bool) throws {
|
|
135
|
+
try checkIsConfigured()
|
|
136
|
+
guard let call = sdk.callRegistry.calls.first else { return }
|
|
137
|
+
|
|
138
|
+
sdk.verifiedUser(verify, for: call, completion: nil)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// MARK: - Private Functions
|
|
142
|
+
|
|
143
|
+
private func configurePushEventsReporterIfNeeded(config: KaleyraVideoConfiguration) {
|
|
144
|
+
guard config.voipStrategy == .automatic else { return }
|
|
145
|
+
guard pushTokenEventReporter == nil else { return }
|
|
146
|
+
|
|
147
|
+
pushTokenEventReporter = PushTokenEventsReporter(emitter: emitter)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private func checkIsConfigured() throws {
|
|
151
|
+
guard isConfigured else {
|
|
152
|
+
throw VideoHybridNativeBridgeError.sdkNotConfiguredError()
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// MARK: - Unsupported Features on iOS Platform
|
|
157
|
+
|
|
158
|
+
func reset() {
|
|
159
|
+
debugPrint("Reset is not supported for iOS platform.")
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
func clearUserCache() {
|
|
163
|
+
debugPrint("clearUserCache() is not supported for iOS platform.")
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
func handlePushNotificationPayload(_ json: String) {
|
|
167
|
+
debugPrint("handlePushNotificationPayload(_) is not supported for iOS platform - json: \(json)")
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
func setDisplayModeForCurrentCall(_ mode: String) {
|
|
171
|
+
debugPrint("setDisplayModeForCurrentCall(_) is not supported for iOS platform - mode: \(mode)")
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
|
|
6
|
+
@available(iOS 12.0, *)
|
|
7
|
+
struct VideoHybridNativeBridgeError: Error, Equatable {
|
|
8
|
+
|
|
9
|
+
private enum ErrorCodes: String {
|
|
10
|
+
|
|
11
|
+
case unsupportedFunction = "UNSUPPORTED_FUNCTION_CALL"
|
|
12
|
+
case invalidUrl = "INVALID_URL_ERROR"
|
|
13
|
+
case sdkNotConfiguredError = "SDK_NOT_CONFIGURED_ERROR"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let code: String
|
|
17
|
+
let message: String
|
|
18
|
+
|
|
19
|
+
static func unsupportedFunctionCallError(method: String) -> VideoHybridNativeBridgeError {
|
|
20
|
+
.init(code: ErrorCodes.unsupportedFunction.rawValue,
|
|
21
|
+
message: "Calling \(method) function is not supported")
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static func unableToInitializeURLError(urlString: String) -> VideoHybridNativeBridgeError {
|
|
25
|
+
.init(code: ErrorCodes.invalidUrl.rawValue,
|
|
26
|
+
message: "Unable to convert the provided string \"\(urlString)\" to URL object")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static func sdkNotConfiguredError() -> VideoHybridNativeBridgeError {
|
|
30
|
+
.init(code: ErrorCodes.sdkNotConfiguredError.rawValue,
|
|
31
|
+
message: "Kaleyra Video SDK must be configured before performing this action")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
|
|
2
|
+
// See LICENSE for licensing information
|
|
3
|
+
|
|
4
|
+
import Foundation
|
|
5
|
+
import Bandyer
|
|
6
|
+
|
|
7
|
+
@available(iOS 12.0, *)
|
|
8
|
+
struct UserInterfacePresenterConfiguration: Equatable {
|
|
9
|
+
|
|
10
|
+
enum ChatAudioButtonConfiguration: Equatable {
|
|
11
|
+
|
|
12
|
+
case disabled
|
|
13
|
+
case enabled(AudioCallOptions)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
enum ChatVideoButtonConfiguration: Equatable {
|
|
17
|
+
|
|
18
|
+
case disabled
|
|
19
|
+
case enabled(CallOptions)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let showsFeedbackWhenCallEnds: Bool
|
|
23
|
+
let chatAudioButtonConf: ChatAudioButtonConfiguration
|
|
24
|
+
let chatVideoButtonConf: ChatVideoButtonConfiguration
|
|
25
|
+
|
|
26
|
+
var chatHasAudioButton: Bool {
|
|
27
|
+
chatAudioButtonConf != .disabled
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var chatHasVideoButton: Bool {
|
|
31
|
+
chatVideoButtonConf != .disabled
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@available(iOS 12.0, *)
|
|
36
|
+
class KaleyraVideoSDKUserInterfacePresenter: NSObject, UserInterfacePresenter {
|
|
37
|
+
|
|
38
|
+
// MARK: - Properties
|
|
39
|
+
|
|
40
|
+
private let sdk: BandyerSDKProtocol
|
|
41
|
+
private let viewControllerPresenter: ViewControllerPresenter
|
|
42
|
+
private let callWindow: CallWindowProtocol
|
|
43
|
+
private let formatter: Formatter
|
|
44
|
+
|
|
45
|
+
private var configuration = UserInterfacePresenterConfiguration(showsFeedbackWhenCallEnds: false,
|
|
46
|
+
chatAudioButtonConf: .disabled,
|
|
47
|
+
chatVideoButtonConf: .disabled)
|
|
48
|
+
|
|
49
|
+
// MARK: - Init
|
|
50
|
+
|
|
51
|
+
init(sdk: BandyerSDKProtocol,
|
|
52
|
+
viewControllerPresenter: ViewControllerPresenter,
|
|
53
|
+
callWindow: CallWindowProtocol,
|
|
54
|
+
formatter: Formatter) {
|
|
55
|
+
self.sdk = sdk
|
|
56
|
+
self.viewControllerPresenter = viewControllerPresenter
|
|
57
|
+
self.callWindow = callWindow
|
|
58
|
+
self.formatter = formatter
|
|
59
|
+
|
|
60
|
+
super.init()
|
|
61
|
+
|
|
62
|
+
setupCallWindow()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
convenience init(rootViewController: UIViewController?, formatter: Formatter) {
|
|
66
|
+
self.init(sdk: BandyerSDK.instance,
|
|
67
|
+
viewControllerPresenter: KaleyraVideoSDKUserInterfacePresenter.makeViewControllerPresenter(rootViewController),
|
|
68
|
+
callWindow: KaleyraVideoSDKUserInterfacePresenter.makeCallWindow(),
|
|
69
|
+
formatter: formatter)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private static func makeCallWindow() -> CallWindow {
|
|
73
|
+
guard let instance = CallWindow.instance else {
|
|
74
|
+
return CallWindow()
|
|
75
|
+
}
|
|
76
|
+
return instance
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private static func makeViewControllerPresenter(_ rootViewController: UIViewController?) -> ViewControllerPresenter {
|
|
80
|
+
if let rootViewController = rootViewController {
|
|
81
|
+
return PresentingViewControllerViewControllerPresenter(presentingViewController: rootViewController)
|
|
82
|
+
} else {
|
|
83
|
+
return WindowViewControllerPresenter()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// MARK: - Setup
|
|
88
|
+
|
|
89
|
+
private func setupCallWindow() {
|
|
90
|
+
callWindow.callDelegate = self
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private func setupSDK() {
|
|
94
|
+
sdk.callClient.addIncomingCall(observer: self, queue: .main)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private func setupNotificationCoordinator() {
|
|
98
|
+
sdk.notificationsCoordinator?.chatListener = self
|
|
99
|
+
sdk.notificationsCoordinator?.fileShareListener = self
|
|
100
|
+
sdk.notificationsCoordinator?.formatter = formatter
|
|
101
|
+
sdk.notificationsCoordinator?.start()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// MARK: - Configuration
|
|
105
|
+
|
|
106
|
+
func configure(with configuration: UserInterfacePresenterConfiguration) {
|
|
107
|
+
self.configuration = configuration
|
|
108
|
+
|
|
109
|
+
setupSDK()
|
|
110
|
+
setupNotificationCoordinator()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// MARK: - Presenting Call UI
|
|
114
|
+
|
|
115
|
+
func presentCall(_ options: CreateCallOptions) {
|
|
116
|
+
let intent = options.makeStartOutgoingCallIntent()
|
|
117
|
+
handleCallIntent(intent)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
func presentCall(_ url: URL) {
|
|
121
|
+
let intent = JoinURLIntent(url: url)
|
|
122
|
+
handleCallIntent(intent)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private func makeCallViewControllerConfiguration() -> CallViewControllerConfiguration {
|
|
126
|
+
let builder = CallViewControllerConfigurationBuilder().withFormatter(formatter)
|
|
127
|
+
|
|
128
|
+
if configuration.showsFeedbackWhenCallEnds {
|
|
129
|
+
_ = builder.withFeedbackEnabled()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return builder.build()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// MARK: - Presenting Chat UI
|
|
136
|
+
|
|
137
|
+
func presentChat(with userID: String) {
|
|
138
|
+
let intent = OpenChatIntent.openChat(with: userID)
|
|
139
|
+
handleChatIntent(intent)
|
|
140
|
+
}
|
|
141
|
+
|
|
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()
|
|
147
|
+
controller.delegate = self
|
|
148
|
+
controller.configuration = config
|
|
149
|
+
controller.intent = intent
|
|
150
|
+
return controller
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// MARK: - Intents
|
|
154
|
+
|
|
155
|
+
private func handleChatIntent(_ intent: OpenChatIntent) {
|
|
156
|
+
let channelViewController = makeChannelViewController(intent: intent)
|
|
157
|
+
|
|
158
|
+
let continueWith: (() -> Void) = { [weak self] in
|
|
159
|
+
self?.viewControllerPresenter.present(channelViewController, animated: true, completion: nil)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if viewControllerPresenter.isPresenting {
|
|
163
|
+
viewControllerPresenter.dismissAll(animated: true, completion: continueWith)
|
|
164
|
+
} else {
|
|
165
|
+
continueWith()
|
|
166
|
+
}
|
|
167
|
+
}
|
|
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
|
+
}
|
|
179
|
+
|
|
180
|
+
// MARK: - CallWindowDelegate
|
|
181
|
+
|
|
182
|
+
@available(iOS 12.0, *)
|
|
183
|
+
extension KaleyraVideoSDKUserInterfacePresenter: CallWindowDelegate {
|
|
184
|
+
|
|
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))
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// MARK: - InAppChatNotificationTouchListener
|
|
205
|
+
|
|
206
|
+
@available(iOS 12.0, *)
|
|
207
|
+
extension KaleyraVideoSDKUserInterfacePresenter: InAppChatNotificationTouchListener {
|
|
208
|
+
|
|
209
|
+
func onTouch(_ notification: Bandyer.ChatNotification) {
|
|
210
|
+
guard let intent = OpenChatIntent.openChat(from: notification) else { return }
|
|
211
|
+
handleChatIntent(intent)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
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
|
+
// MARK: - ChannelViewControllerDelegate
|
|
226
|
+
|
|
227
|
+
@available(iOS 12.0, *)
|
|
228
|
+
extension KaleyraVideoSDKUserInterfacePresenter: ChannelViewControllerDelegate {
|
|
229
|
+
|
|
230
|
+
func channelViewControllerDidFinish(_ controller: Bandyer.ChannelViewController) {
|
|
231
|
+
viewControllerPresenter.dismiss(controller, animated: true, completion: nil)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
func channelViewController(_ controller: Bandyer.ChannelViewController, didTapAudioCallWith users: [String]) {
|
|
235
|
+
guard case let .enabled(audioOptions) = configuration.chatAudioButtonConf else { return }
|
|
236
|
+
|
|
237
|
+
let options = audioOptions.callOptions
|
|
238
|
+
let intent = StartOutgoingCallIntent(callees: users, options: options)
|
|
239
|
+
handleCallIntent(intent)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
func channelViewController(_ controller: Bandyer.ChannelViewController, didTapVideoCallWith users: [String]) {
|
|
243
|
+
guard case let .enabled(videoOptions) = configuration.chatVideoButtonConf else { return }
|
|
244
|
+
|
|
245
|
+
let options = videoOptions.callOptions
|
|
246
|
+
let intent = StartOutgoingCallIntent(callees: users, options: options)
|
|
247
|
+
handleCallIntent(intent)
|
|
248
|
+
}
|
|
249
|
+
}
|