livevoice-sdk-react-native 2.0.0 → 3.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/README.md +158 -7
- package/android/build.gradle +18 -6
- package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +121 -221
- package/android/src/main/java/io/livevoice/react/__SDK.kt +17 -3
- package/ios/LiveVoiceRNBridge.swift +362 -0
- package/ios/LiveVoiceSdkReactNative.mm +247 -145
- package/ios/__SDK.h +16 -2
- package/ios/livevoice_spm_backport.rb +202 -0
- package/lib/module/components/BrandingView.js +71 -50
- package/lib/module/components/BrandingView.js.map +1 -1
- package/lib/module/components/ChannelView.js +368 -54
- package/lib/module/components/ChannelView.js.map +1 -1
- package/lib/module/components/ErrorView.js +17 -16
- package/lib/module/components/ErrorView.js.map +1 -1
- package/lib/module/components/LiveVoiceSpinner.js +81 -0
- package/lib/module/components/LiveVoiceSpinner.js.map +1 -0
- package/lib/module/components/LiveVoiceView.js +351 -104
- package/lib/module/components/LiveVoiceView.js.map +1 -1
- package/lib/module/components/PasswordPrompt.js +165 -0
- package/lib/module/components/PasswordPrompt.js.map +1 -0
- package/lib/module/components/PlayButtonView.js +192 -254
- package/lib/module/components/PlayButtonView.js.map +1 -1
- package/lib/module/components/ReconnectingView.js +43 -62
- package/lib/module/components/ReconnectingView.js.map +1 -1
- package/lib/module/components/WarningView.js +12 -10
- package/lib/module/components/WarningView.js.map +1 -1
- package/lib/module/icons/branding-ios.png +0 -0
- package/lib/module/icons/camera-off-android.png +0 -0
- package/lib/module/icons/camera-off-android@2x.png +0 -0
- package/lib/module/icons/camera-off-android@3x.png +0 -0
- package/lib/module/icons/cpu-android.png +0 -0
- package/lib/module/icons/cpu-android@2x.png +0 -0
- package/lib/module/icons/cpu-android@3x.png +0 -0
- package/lib/module/icons/cpu-ios.png +0 -0
- package/lib/module/icons/cpu-ios@2x.png +0 -0
- package/lib/module/icons/cpu-ios@3x.png +0 -0
- package/lib/module/icons/lock-android.png +0 -0
- package/lib/module/icons/lock-android@2x.png +0 -0
- package/lib/module/icons/lock-android@3x.png +0 -0
- package/lib/module/icons/lock-ios.png +0 -0
- package/lib/module/icons/lock-ios@2x.png +0 -0
- package/lib/module/icons/lock-ios@3x.png +0 -0
- package/lib/module/icons/mic-off-android.png +0 -0
- package/lib/module/icons/mic-off-android@2x.png +0 -0
- package/lib/module/icons/mic-off-android@3x.png +0 -0
- package/lib/module/icons/mic-slash-ios.png +0 -0
- package/lib/module/icons/mic-slash-ios@2x.png +0 -0
- package/lib/module/icons/mic-slash-ios@3x.png +0 -0
- package/lib/module/icons/video-slash-ios.png +0 -0
- package/lib/module/icons/video-slash-ios@2x.png +0 -0
- package/lib/module/icons/video-slash-ios@3x.png +0 -0
- package/lib/module/index.js +24 -225
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/Bridge.js +236 -0
- package/lib/module/sdk/Bridge.js.map +1 -0
- package/lib/module/sdk/Event.js +160 -0
- package/lib/module/sdk/Event.js.map +1 -0
- package/lib/module/sdk/Lifecycle.js +331 -0
- package/lib/module/sdk/Lifecycle.js.map +1 -0
- package/lib/module/sdk/LiveVoiceSdk.js +365 -0
- package/lib/module/sdk/LiveVoiceSdk.js.map +1 -0
- package/lib/module/sdk/LiveVoiceState.js +234 -0
- package/lib/module/sdk/LiveVoiceState.js.map +1 -0
- package/lib/module/sdk/LogEntries.js +99 -0
- package/lib/module/sdk/LogEntries.js.map +1 -0
- package/lib/module/sdk/Models.js +2 -0
- package/lib/module/{util/UIState.js.map → sdk/Models.js.map} +1 -1
- package/lib/module/sdk/NativeSdkVersions.js +24 -0
- package/lib/module/sdk/NativeSdkVersions.js.map +1 -0
- package/lib/module/sdk/Observables.js +391 -0
- package/lib/module/sdk/Observables.js.map +1 -0
- package/lib/module/sdk/Passwords.js +298 -0
- package/lib/module/sdk/Passwords.js.map +1 -0
- package/lib/module/sdk/Playback.js +35 -0
- package/lib/module/sdk/Playback.js.map +1 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js +12 -10
- package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
- package/lib/module/util/Colors.js +14 -11
- package/lib/module/util/Colors.js.map +1 -1
- package/lib/module/util/Translations.js +46 -21
- package/lib/module/util/Translations.js.map +1 -1
- package/lib/module/util/freeze.js +26 -0
- package/lib/module/util/freeze.js.map +1 -0
- package/lib/module/util/logger.js +114 -0
- package/lib/module/util/logger.js.map +1 -0
- package/lib/typescript/src/components/BrandingView.d.ts +4 -0
- package/lib/typescript/src/components/BrandingView.d.ts.map +1 -1
- package/lib/typescript/src/components/ChannelView.d.ts +29 -3
- package/lib/typescript/src/components/ChannelView.d.ts.map +1 -1
- package/lib/typescript/src/components/ErrorView.d.ts +5 -3
- package/lib/typescript/src/components/ErrorView.d.ts.map +1 -1
- package/lib/typescript/src/components/LiveVoiceSpinner.d.ts +16 -0
- package/lib/typescript/src/components/LiveVoiceSpinner.d.ts.map +1 -0
- package/lib/typescript/src/components/LiveVoiceView.d.ts +85 -3
- package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -1
- package/lib/typescript/src/components/PasswordPrompt.d.ts +13 -0
- package/lib/typescript/src/components/PasswordPrompt.d.ts.map +1 -0
- package/lib/typescript/src/components/PlayButtonView.d.ts +12 -329
- package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -1
- package/lib/typescript/src/components/ReconnectingView.d.ts +6 -3
- package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -1
- package/lib/typescript/src/components/WarningView.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +15 -144
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/Bridge.d.ts +36 -0
- package/lib/typescript/src/sdk/Bridge.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Event.d.ts +97 -0
- package/lib/typescript/src/sdk/Event.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Lifecycle.d.ts +191 -0
- package/lib/typescript/src/sdk/Lifecycle.d.ts.map +1 -0
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +215 -0
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts +80 -0
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -0
- package/lib/typescript/src/sdk/LogEntries.d.ts +28 -0
- package/lib/typescript/src/sdk/LogEntries.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Models.d.ts +114 -0
- package/lib/typescript/src/sdk/Models.d.ts.map +1 -0
- package/lib/typescript/src/sdk/NativeSdkVersions.d.ts +6 -0
- package/lib/typescript/src/sdk/NativeSdkVersions.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Observables.d.ts +123 -0
- package/lib/typescript/src/sdk/Observables.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Passwords.d.ts +72 -0
- package/lib/typescript/src/sdk/Passwords.d.ts.map +1 -0
- package/lib/typescript/src/sdk/Playback.d.ts +9 -0
- package/lib/typescript/src/sdk/Playback.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts +35 -29
- package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -1
- package/lib/typescript/src/util/Colors.d.ts.map +1 -1
- package/lib/typescript/src/util/Translations.d.ts +30 -8
- package/lib/typescript/src/util/Translations.d.ts.map +1 -1
- package/lib/typescript/src/util/freeze.d.ts +6 -0
- package/lib/typescript/src/util/freeze.d.ts.map +1 -0
- package/lib/typescript/src/util/logger.d.ts +33 -0
- package/lib/typescript/src/util/logger.d.ts.map +1 -0
- package/livevoice-sdk-react-native.podspec +41 -16
- package/package.json +26 -14
- package/src/components/BrandingView.tsx +55 -66
- package/src/components/ChannelView.tsx +342 -48
- package/src/components/ErrorView.tsx +21 -22
- package/src/components/LiveVoiceSpinner.tsx +87 -0
- package/src/components/LiveVoiceView.tsx +360 -151
- package/src/components/PasswordPrompt.tsx +144 -0
- package/src/components/PlayButtonView.tsx +177 -279
- package/src/components/ReconnectingView.tsx +40 -86
- package/src/components/WarningView.tsx +12 -10
- package/src/icons/branding-ios.png +0 -0
- package/src/icons/camera-off-android.png +0 -0
- package/src/icons/camera-off-android@2x.png +0 -0
- package/src/icons/camera-off-android@3x.png +0 -0
- package/src/icons/cpu-android.png +0 -0
- package/src/icons/cpu-android@2x.png +0 -0
- package/src/icons/cpu-android@3x.png +0 -0
- package/src/icons/cpu-ios.png +0 -0
- package/src/icons/cpu-ios@2x.png +0 -0
- package/src/icons/cpu-ios@3x.png +0 -0
- package/src/icons/lock-android.png +0 -0
- package/src/icons/lock-android@2x.png +0 -0
- package/src/icons/lock-android@3x.png +0 -0
- package/src/icons/lock-ios.png +0 -0
- package/src/icons/lock-ios@2x.png +0 -0
- package/src/icons/lock-ios@3x.png +0 -0
- package/src/icons/mic-off-android.png +0 -0
- package/src/icons/mic-off-android@2x.png +0 -0
- package/src/icons/mic-off-android@3x.png +0 -0
- package/src/icons/mic-slash-ios.png +0 -0
- package/src/icons/mic-slash-ios@2x.png +0 -0
- package/src/icons/mic-slash-ios@3x.png +0 -0
- package/src/icons/video-slash-ios.png +0 -0
- package/src/icons/video-slash-ios@2x.png +0 -0
- package/src/icons/video-slash-ios@3x.png +0 -0
- package/src/index.tsx +105 -252
- package/src/sdk/Bridge.ts +259 -0
- package/src/sdk/Event.ts +187 -0
- package/src/sdk/Lifecycle.ts +366 -0
- package/src/sdk/LiveVoiceSdk.ts +384 -0
- package/src/sdk/LiveVoiceState.ts +259 -0
- package/src/sdk/LogEntries.ts +88 -0
- package/src/sdk/Models.ts +129 -0
- package/src/sdk/NativeSdkVersions.ts +21 -0
- package/src/sdk/Observables.ts +414 -0
- package/src/sdk/Passwords.ts +286 -0
- package/src/sdk/Playback.ts +30 -0
- package/src/specs/NativeLiveVoiceSdk.ts +56 -46
- package/src/util/Colors.ts +14 -11
- package/src/util/Translations.ts +46 -22
- package/src/util/freeze.ts +23 -0
- package/src/util/logger.ts +119 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeLiveVoiceSdkSpec.java +0 -186
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -28
- package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec-generated.cpp +0 -235
- package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec.h +0 -31
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +0 -341
- package/android/src/main/java/io/livevoice/react/Mappings.kt +0 -85
- package/android/src/main/java/io/livevoice/react/NativeModels.kt +0 -79
- package/lib/module/components/AudioOutputSwitchView.js +0 -138
- package/lib/module/components/AudioOutputSwitchView.js.map +0 -1
- package/lib/module/components/index.js +0 -22
- package/lib/module/components/index.js.map +0 -1
- package/lib/module/icons/mic.png +0 -0
- package/lib/module/util/ForegroundServiceConfig.js +0 -28
- package/lib/module/util/ForegroundServiceConfig.js.map +0 -1
- package/lib/module/util/PlayingState.js +0 -21
- package/lib/module/util/PlayingState.js.map +0 -1
- package/lib/module/util/UIState.js +0 -4
- package/lib/typescript/src/components/AudioOutputSwitchView.d.ts +0 -6
- package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +0 -1
- package/lib/typescript/src/components/index.d.ts +0 -9
- package/lib/typescript/src/components/index.d.ts.map +0 -1
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +0 -12
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +0 -1
- package/lib/typescript/src/util/PlayingState.d.ts +0 -7
- package/lib/typescript/src/util/PlayingState.d.ts.map +0 -1
- package/lib/typescript/src/util/UIState.d.ts +0 -66
- package/lib/typescript/src/util/UIState.d.ts.map +0 -1
- package/src/components/AudioOutputSwitchView.tsx +0 -146
- package/src/components/index.tsx +0 -19
- package/src/icons/mic.png +0 -0
- package/src/util/ForegroundServiceConfig.tsx +0 -32
- package/src/util/PlayingState.ts +0 -18
- package/src/util/UIState.ts +0 -89
|
@@ -12,27 +12,108 @@
|
|
|
12
12
|
//===----------------------------------------------------------------------===//
|
|
13
13
|
|
|
14
14
|
#import "LiveVoiceSdkReactNative.h"
|
|
15
|
-
|
|
15
|
+
// The SDK is reached only through LiveVoiceRNBridge.swift.
|
|
16
|
+
#if __has_include(<livevoice_sdk_react_native/livevoice_sdk_react_native-Swift.h>)
|
|
17
|
+
#import <livevoice_sdk_react_native/livevoice_sdk_react_native-Swift.h>
|
|
18
|
+
#else
|
|
19
|
+
#import "livevoice_sdk_react_native-Swift.h"
|
|
20
|
+
#endif
|
|
16
21
|
#import "React/RCTVersion.h"
|
|
17
22
|
#import "__SDK.h"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
#import <os/log.h>
|
|
24
|
+
|
|
25
|
+
static os_log_t LiveVoiceLogHandle(void) {
|
|
26
|
+
static os_log_t logHandle;
|
|
27
|
+
static dispatch_once_t onceToken;
|
|
28
|
+
dispatch_once(&onceToken, ^{
|
|
29
|
+
logHandle = os_log_create("io.livevoice.react-native", "LiveVoiceSdkReactNative");
|
|
30
|
+
});
|
|
31
|
+
return logHandle;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static NSString *LiveVoiceFormatMessage(NSString *event,
|
|
35
|
+
NSDictionary<NSString *, id> *fields) {
|
|
36
|
+
NSMutableArray<NSString *> *parts = [NSMutableArray arrayWithObject:event];
|
|
37
|
+
NSArray<NSString *> *keys =
|
|
38
|
+
[[fields allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
|
39
|
+
|
|
40
|
+
for (NSString *key in keys) {
|
|
41
|
+
id value = fields[key];
|
|
42
|
+
if (value == nil || value == [NSNull null]) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[parts addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [parts componentsJoinedByString:@" "];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static void LiveVoiceLogInfo(NSString *event, NSDictionary<NSString *, id> *fields) {
|
|
53
|
+
NSString *message = LiveVoiceFormatMessage(event, fields);
|
|
54
|
+
os_log_with_type(LiveVoiceLogHandle(), OS_LOG_TYPE_INFO, "%{public}s",
|
|
55
|
+
message.UTF8String);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@interface LiveVoiceSdkReactNative ()
|
|
59
|
+
// Ownership is protected by @synchronized(self). Never call Swift or a reply
|
|
60
|
+
// while holding it: attaching asynchronously enters the main actor.
|
|
61
|
+
@property(nonatomic, strong, nullable) LiveVoiceRNBridge *liveVoice;
|
|
62
|
+
@property(nonatomic) BOOL runtimeInvalidated;
|
|
63
|
+
@property(nonatomic) BOOL attaching;
|
|
64
|
+
@property(nonatomic, strong) NSMutableArray<void (^)(LiveVoiceRNBridge *_Nullable)> *attachReplies;
|
|
65
|
+
// Events reach JavaScript through the runtime's C++ module, which a reload
|
|
66
|
+
// destroys once `invalidate` returns. The bridge's streams end later, on the
|
|
67
|
+
// main actor, so values still queued must be dropped. This lock makes an
|
|
68
|
+
// emission and `invalidate` exclude each other; nothing else is called under it.
|
|
69
|
+
@property(nonatomic, strong) NSLock *emitLock;
|
|
70
|
+
@property(nonatomic) BOOL emitsStopped;
|
|
21
71
|
@end
|
|
22
72
|
|
|
23
73
|
@implementation LiveVoiceSdkReactNative
|
|
24
74
|
|
|
25
75
|
RCT_EXPORT_MODULE(LiveVoiceModule)
|
|
26
76
|
|
|
77
|
+
- (instancetype)init {
|
|
78
|
+
if ((self = [super init])) _emitLock = [NSLock new];
|
|
79
|
+
return self;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Runs `emit` unless the runtime went away; `invalidate` waits for one in progress.
|
|
83
|
+
- (void)emitUnlessInvalidated:(void (NS_NOESCAPE ^)(void))emit {
|
|
84
|
+
[self.emitLock lock];
|
|
85
|
+
if (!self.emitsStopped) emit();
|
|
86
|
+
[self.emitLock unlock];
|
|
87
|
+
}
|
|
88
|
+
|
|
27
89
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
28
90
|
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
29
91
|
return std::make_shared<facebook::react::NativeLiveVoiceSdkSpecJSI>(params);
|
|
30
92
|
}
|
|
31
93
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
94
|
+
static void LiveVoiceReject(RCTPromiseRejectBlock reject, NSString *error) {
|
|
95
|
+
NSDictionary *wire = [NSJSONSerialization JSONObjectWithData:[error dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
|
|
96
|
+
NSString *code = [wire isKindOfClass:[NSDictionary class]] ? wire[@"code"] : nil;
|
|
97
|
+
reject([code isKindOfClass:[NSString class]] ? code : @"generic", error, nil);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// Calls `use` with the attached bridge, attaching it first if needed, or with
|
|
101
|
+
/// nil once the runtime went away.
|
|
102
|
+
- (void)withBridge:(void (^)(LiveVoiceRNBridge *_Nullable))use {
|
|
103
|
+
BOOL invalidated = NO;
|
|
104
|
+
LiveVoiceRNBridge *attached;
|
|
105
|
+
@synchronized(self) {
|
|
106
|
+
invalidated = self.runtimeInvalidated;
|
|
107
|
+
attached = self.liveVoice;
|
|
108
|
+
if (!invalidated && !attached) {
|
|
109
|
+
if (!self.attachReplies) self.attachReplies = [NSMutableArray new];
|
|
110
|
+
[self.attachReplies addObject:use];
|
|
111
|
+
if (self.attaching) return;
|
|
112
|
+
self.attaching = YES;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (invalidated) { use(nil); return; }
|
|
116
|
+
if (attached) { use(attached); return; }
|
|
36
117
|
|
|
37
118
|
NSDictionary *versionInfo = RCTGetReactNativeVersion();
|
|
38
119
|
NSString *major = versionInfo[RCTVersionMajor];
|
|
@@ -41,195 +122,216 @@ RCT_EXPORT_MODULE(LiveVoiceModule)
|
|
|
41
122
|
NSString *const PLATFORM_VERSION =
|
|
42
123
|
[NSString stringWithFormat:@"%@.%@.%@", major, minor, patch];
|
|
43
124
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
125
|
+
__weak LiveVoiceSdkReactNative *weakSelf = self;
|
|
126
|
+
[LiveVoiceRNBridge
|
|
127
|
+
startWithReactNativeVersion:PLATFORM_VERSION
|
|
128
|
+
wrapperVersion:SDK_VERSION
|
|
129
|
+
onState:^(NSString *value) {
|
|
130
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
131
|
+
[module emitUnlessInvalidated:^{ [module emitOnState:value]; }];
|
|
132
|
+
}
|
|
133
|
+
onPasswordRequest:^(NSString *value) {
|
|
134
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
135
|
+
[module emitUnlessInvalidated:^{ [module emitOnPasswordRequest:value]; }];
|
|
136
|
+
}
|
|
137
|
+
onPasswordRequestCancelled:^(NSString *value) {
|
|
138
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
139
|
+
[module emitUnlessInvalidated:^{ [module emitOnPasswordRequestCancelled:value]; }];
|
|
140
|
+
}
|
|
141
|
+
onPasswordStoreRequest:^(NSString *value) {
|
|
142
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
143
|
+
[module emitUnlessInvalidated:^{ [module emitOnPasswordStoreRequest:value]; }];
|
|
144
|
+
}
|
|
145
|
+
onLogEntry:^(NSString *value) {
|
|
146
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
147
|
+
[module emitUnlessInvalidated:^{ [module emitOnLogEntry:value]; }];
|
|
148
|
+
}
|
|
149
|
+
completion:^(LiveVoiceRNBridge *created) {
|
|
150
|
+
LiveVoiceSdkReactNative *module = weakSelf;
|
|
151
|
+
if (!module) { [created invalidate]; return; }
|
|
152
|
+
NSArray<void (^)(LiveVoiceRNBridge *_Nullable)> *replies;
|
|
153
|
+
BOOL invalidated;
|
|
154
|
+
@synchronized(module) {
|
|
155
|
+
invalidated = module.runtimeInvalidated;
|
|
156
|
+
if (!invalidated) module.liveVoice = created;
|
|
157
|
+
module.attaching = NO;
|
|
158
|
+
replies = [module.attachReplies copy];
|
|
159
|
+
module.attachReplies = nil;
|
|
160
|
+
}
|
|
161
|
+
if (invalidated) [created invalidate];
|
|
162
|
+
else LiveVoiceLogInfo(@"LV_INIT", @{@"platformVersion" : PLATFORM_VERSION});
|
|
163
|
+
for (void (^pending)(LiveVoiceRNBridge *_Nullable) in replies) pending(invalidated ? nil : created);
|
|
164
|
+
}];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
- (void)initialize:(NSString *)configuration
|
|
168
|
+
resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
169
|
+
[self withBridge:^(LiveVoiceRNBridge *bridge) {
|
|
170
|
+
if (bridge == nil) { LiveVoiceReject(reject, [LiveVoiceRNBridge errorJSONWithCode:@"cancelled"]); return; }
|
|
171
|
+
[bridge initializeWithConfiguration:configuration completion:^(NSString *snapshot, NSString *error) {
|
|
172
|
+
if (error != nil) LiveVoiceReject(reject, error);
|
|
173
|
+
else resolve(snapshot);
|
|
174
|
+
}];
|
|
175
|
+
}];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
- (void)execute:(NSString *)command payload:(NSString *)arguments
|
|
179
|
+
resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
180
|
+
LiveVoiceRNBridge *bridge;
|
|
181
|
+
BOOL invalidated;
|
|
182
|
+
@synchronized(self) { bridge = self.liveVoice; invalidated = self.runtimeInvalidated; }
|
|
183
|
+
if (bridge == nil) {
|
|
184
|
+
LiveVoiceReject(reject, [LiveVoiceRNBridge errorJSONWithCode:invalidated ? @"cancelled" : @"not_initialized"]);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
[bridge executeWithName:command arguments:arguments completion:^(NSString *value, NSString *error) {
|
|
188
|
+
if (error != nil) LiveVoiceReject(reject, error);
|
|
189
|
+
else resolve(value ?: @"null");
|
|
190
|
+
}];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
- (NSString *)getErrorMessages {
|
|
194
|
+
return LiveVoiceRNBridge.errorMessages;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Works before `initialize`: attaches the bridge first if needed, so the
|
|
198
|
+
// preference reaches native and the snapshot later carries it. Ignored once
|
|
199
|
+
// the runtime went away.
|
|
200
|
+
- (void)setAudioOutput:(NSString *)payload {
|
|
201
|
+
[self withBridge:^(LiveVoiceRNBridge *bridge) {
|
|
202
|
+
[bridge setAudioOutput:payload];
|
|
203
|
+
}];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
- (void)writeLogEntry:(NSString *)payload {
|
|
207
|
+
[LiveVoiceRNBridge writeLogEntry:payload];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
- (void)answerPasswordRequest:(NSString *)payload {
|
|
211
|
+
[[self bridgeSnapshot] answerPasswordRequest:payload];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
- (void)answerPasswordStoreRequest:(NSString *)payload {
|
|
215
|
+
[[self bridgeSnapshot] answerPasswordStoreRequest:payload];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
- (void)setPasswordStore:(NSString *)payload {
|
|
219
|
+
[[self bridgeSnapshot] setPasswordStore:payload];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
- (LiveVoiceRNBridge *)bridgeSnapshot {
|
|
223
|
+
@synchronized(self) { return self.runtimeInvalidated ? nil : self.liveVoice; }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
- (void)invalidate {
|
|
227
|
+
[self.emitLock lock];
|
|
228
|
+
self.emitsStopped = YES;
|
|
229
|
+
[self.emitLock unlock];
|
|
230
|
+
LiveVoiceRNBridge *bridge;
|
|
231
|
+
NSArray<void (^)(LiveVoiceRNBridge *_Nullable)> *replies;
|
|
232
|
+
@synchronized(self) {
|
|
233
|
+
self.runtimeInvalidated = YES;
|
|
234
|
+
bridge = self.liveVoice;
|
|
235
|
+
self.liveVoice = nil;
|
|
236
|
+
replies = [self.attachReplies copy];
|
|
237
|
+
self.attachReplies = nil;
|
|
238
|
+
}
|
|
239
|
+
[bridge invalidate];
|
|
240
|
+
for (void (^pending)(LiveVoiceRNBridge *_Nullable) in replies) pending(nil);
|
|
95
241
|
}
|
|
96
242
|
|
|
97
243
|
#pragma mark - Actions
|
|
98
244
|
|
|
99
|
-
- (void)
|
|
100
|
-
|
|
101
|
-
useSpeaker ? @"speaker" : @"receiver");
|
|
102
|
-
[LiveVoice setAudioOutputToSpeaker:useSpeaker];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
- (void)startChannel:(double)channelID {
|
|
106
|
-
NSLog(@"[SDK] %s %d", __PRETTY_FUNCTION__, (int)channelID);
|
|
107
|
-
[LiveVoice startWithChannelID:channelID];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
- (void)stopChannel {
|
|
111
|
-
NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
|
|
112
|
-
[LiveVoice stop];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
#pragma mark - Subtitles
|
|
116
|
-
|
|
117
|
-
- (void)startSubtitles:(double)channelId {
|
|
118
|
-
NSLog(@"[SDK] %s channel: %f", __PRETTY_FUNCTION__, channelId);
|
|
119
|
-
NSNumber *_Nullable optionalChannelID =
|
|
120
|
-
(channelId == -1) ? nil : [NSNumber numberWithLongLong:channelId];
|
|
121
|
-
[LiveVoice startSubtitlesWithChannelID:optionalChannelID];
|
|
245
|
+
- (void)openLiveVoiceWebsite {
|
|
246
|
+
[LiveVoiceRNBridge openLiveVoiceWebsite];
|
|
122
247
|
}
|
|
123
248
|
|
|
124
|
-
- (
|
|
125
|
-
|
|
126
|
-
[LiveVoice stopSubtitles];
|
|
249
|
+
- (nonnull NSString *)getSdkVersion {
|
|
250
|
+
return SDK_VERSION;
|
|
127
251
|
}
|
|
128
252
|
|
|
129
|
-
- (
|
|
130
|
-
|
|
253
|
+
- (nonnull NSString *)getNativeSdkVersion {
|
|
254
|
+
return LiveVoiceRNBridge.nativeSdkVersion;
|
|
131
255
|
}
|
|
132
256
|
|
|
133
257
|
#pragma mark - Translations
|
|
134
258
|
|
|
135
259
|
- (nonnull NSString *)channelStatusOffline {
|
|
136
|
-
return [
|
|
260
|
+
return [LiveVoiceRNBridge translation:@"channel_status_offline" seconds:0];
|
|
137
261
|
}
|
|
138
262
|
|
|
139
263
|
- (nonnull NSString *)errorScreenRetrying {
|
|
140
|
-
return [
|
|
264
|
+
return [LiveVoiceRNBridge translation:@"error_screen_retrying" seconds:0];
|
|
141
265
|
}
|
|
142
266
|
|
|
143
267
|
- (nonnull NSString *)errorScreenRetryingIn:(double)seconds {
|
|
144
|
-
return [
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
- (nonnull NSString *)sdkErrorGeneric {
|
|
148
|
-
return [Translations sdk_error_generic];
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
- (nonnull NSString *)sdkErrorInactive {
|
|
152
|
-
return [Translations sdk_error_inactive];
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
- (nonnull NSString *)sdkErrorInvalidApiKey {
|
|
156
|
-
return [Translations sdk_error_invalid_api_key];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
- (nonnull NSString *)sdkErrorListenerLimitReached {
|
|
160
|
-
return [Translations sdk_error_listener_limit_reached];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
- (nonnull NSString *)sdkErrorNoNetwork {
|
|
164
|
-
return [Translations sdk_error_no_network];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
- (nonnull NSString *)sdkErrorNotFound {
|
|
168
|
-
return [Translations sdk_error_not_found];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
- (nonnull NSString *)sdkErrorRequestFailed:(double)errorCode {
|
|
172
|
-
return [Translations
|
|
173
|
-
sdk_error_request_failed:[NSString stringWithFormat:@"%1.0f", errorCode]];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
- (nonnull NSString *)sdkErrorWrongPassword {
|
|
177
|
-
return [Translations sdk_error_wrong_password];
|
|
268
|
+
return [LiveVoiceRNBridge translation:@"error_screen_retrying_in" seconds:(NSInteger)seconds];
|
|
178
269
|
}
|
|
179
270
|
|
|
180
271
|
- (nonnull NSString *)sdkNoMatchingChannels {
|
|
181
|
-
return [
|
|
272
|
+
return [LiveVoiceRNBridge translation:@"sdk_no_matching_channels" seconds:0];
|
|
182
273
|
}
|
|
183
274
|
|
|
184
275
|
- (nonnull NSString *)streamingByTitle {
|
|
185
|
-
return [
|
|
276
|
+
return [LiveVoiceRNBridge translation:@"streaming_by_title" seconds:0];
|
|
186
277
|
}
|
|
187
278
|
|
|
188
279
|
- (nonnull NSString *)accessibilityChannelPlay {
|
|
189
|
-
return [
|
|
280
|
+
return [LiveVoiceRNBridge translation:@"a11y_channel_play" seconds:0];
|
|
190
281
|
}
|
|
191
282
|
|
|
192
283
|
- (nonnull NSString *)accessibilityChannelStatusMuted {
|
|
193
|
-
return [
|
|
284
|
+
return [LiveVoiceRNBridge translation:@"a11y_channel_status_muted" seconds:0];
|
|
194
285
|
}
|
|
195
286
|
|
|
196
287
|
- (nonnull NSString *)accessibilityChannelStop {
|
|
197
|
-
return [
|
|
288
|
+
return [LiveVoiceRNBridge translation:@"a11y_channel_stop" seconds:0];
|
|
198
289
|
}
|
|
199
290
|
|
|
200
291
|
- (nonnull NSString *)isAiChannelStatusMessage {
|
|
201
|
-
return [
|
|
292
|
+
return [LiveVoiceRNBridge translation:@"channel_status_is_ai" seconds:0];
|
|
202
293
|
}
|
|
203
294
|
|
|
204
295
|
- (nonnull NSString *)noChannels {
|
|
205
|
-
return [
|
|
296
|
+
return [LiveVoiceRNBridge translation:@"no_channels" seconds:0];
|
|
206
297
|
}
|
|
207
298
|
|
|
208
299
|
- (nonnull NSString *)errorRetryNowButton {
|
|
209
|
-
return [
|
|
300
|
+
return [LiveVoiceRNBridge translation:@"action_retry_now" seconds:0];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
#pragma mark - Password prompt
|
|
304
|
+
|
|
305
|
+
- (nonnull NSString *)passwordPromptTitle {
|
|
306
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_title" seconds:0];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
- (nonnull NSString *)passwordPromptChannelMessage {
|
|
310
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_channel_message" seconds:0];
|
|
210
311
|
}
|
|
211
312
|
|
|
212
|
-
|
|
313
|
+
- (nonnull NSString *)passwordPromptEventMessage {
|
|
314
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_event_message" seconds:0];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
- (nonnull NSString *)passwordPromptWrongPassword {
|
|
318
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_wrong_password" seconds:0];
|
|
319
|
+
}
|
|
213
320
|
|
|
214
|
-
- (
|
|
215
|
-
|
|
216
|
-
[self emitOnUiStateChanged:serializedState];
|
|
321
|
+
- (nonnull NSString *)passwordPromptField {
|
|
322
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_field" seconds:0];
|
|
217
323
|
}
|
|
218
324
|
|
|
219
|
-
- (
|
|
220
|
-
|
|
221
|
-
useSpeaker ? @"speaker" : @"receiver");
|
|
222
|
-
[self emitOnAudioOutputChanged:useSpeaker];
|
|
325
|
+
- (nonnull NSString *)passwordPromptCancelButton {
|
|
326
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_cancel_button" seconds:0];
|
|
223
327
|
}
|
|
224
328
|
|
|
225
|
-
- (
|
|
226
|
-
|
|
227
|
-
[self emitOnAvailableSubtitleConfigsChanged:available];
|
|
329
|
+
- (nonnull NSString *)passwordPromptChannelConfirmButton {
|
|
330
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_channel_confirm_button" seconds:0];
|
|
228
331
|
}
|
|
229
332
|
|
|
230
|
-
- (
|
|
231
|
-
|
|
232
|
-
[self emitOnSubtitlesChanged:subtitles];
|
|
333
|
+
- (nonnull NSString *)passwordPromptEventConfirmButton {
|
|
334
|
+
return [LiveVoiceRNBridge translation:@"password_prompt_event_confirm_button" seconds:0];
|
|
233
335
|
}
|
|
234
336
|
|
|
235
337
|
@end
|
package/ios/__SDK.h
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
//
|
|
3
|
+
// This source file is part of the LiveVoice SDK project
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) LiveVoice GmbH
|
|
6
|
+
// Licensed under the MIT license
|
|
7
|
+
//
|
|
8
|
+
// See LICENSE for license information
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: MIT
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
13
|
+
|
|
14
|
+
// GENERATED CODE - DO NOT MODIFY BY HAND.
|
|
15
|
+
// Generated by tool/generate-native-versions.mjs from package.json.
|
|
2
16
|
#import <Foundation/Foundation.h>
|
|
3
17
|
|
|
4
|
-
NSString* const SDK_VERSION = @"
|
|
18
|
+
NSString* const SDK_VERSION = @"3.0.0";
|