@zelloptt/react-native-zello-sdk 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.
Files changed (196) hide show
  1. package/README.md +58 -15
  2. package/android/build.gradle +29 -10
  3. package/android/gradle.properties +4 -4
  4. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModule.kt +93 -68
  5. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModuleHelper.kt +25 -0
  6. package/ios/Extensions/ZelloContact+Extension.swift +26 -3
  7. package/ios/Extensions/ZelloHistoryVoiceMessage+Extension.swift +3 -0
  8. package/ios/Extensions/ZelloIOSSdkModule+Extension.swift +8 -2
  9. package/ios/Extensions/ZelloIncomingEmergency+Extension.swift +1 -0
  10. package/ios/Extensions/ZelloTranscription+Extension.swift +18 -0
  11. package/ios/ZelloIOSSdkModule.swift +24 -7
  12. package/ios/ZelloIOSSdkModuleBridge.m +1 -0
  13. package/ios/ZelloSdkModule.h +8 -0
  14. package/ios/ZelloSdkModule.mm +189 -0
  15. package/ios/ZelloSdkModuleImpl.swift +280 -0
  16. package/lib/commonjs/docs/assets/highlight.css +1 -1
  17. package/lib/commonjs/docs/assets/icons.js +1 -1
  18. package/lib/commonjs/docs/assets/icons.js.map +1 -1
  19. package/lib/commonjs/docs/assets/icons.svg +1 -1
  20. package/lib/commonjs/docs/assets/main.js +220 -288
  21. package/lib/commonjs/docs/assets/main.js.map +1 -1
  22. package/lib/commonjs/docs/assets/navigation.js +1 -1
  23. package/lib/commonjs/docs/assets/navigation.js.map +1 -1
  24. package/lib/commonjs/docs/assets/search.js +1 -1
  25. package/lib/commonjs/docs/assets/search.js.map +1 -1
  26. package/lib/commonjs/docs/assets/style.css +12 -4
  27. package/lib/commonjs/docs/classes/sdk.Zello.html +793 -97
  28. package/lib/commonjs/docs/classes/types.ZelloAlertMessage.html +122 -9
  29. package/lib/commonjs/docs/classes/types.ZelloChannel.html +155 -10
  30. package/lib/commonjs/docs/classes/types.ZelloChannelUser.html +86 -4
  31. package/lib/commonjs/docs/classes/types.ZelloDispatchCall.html +90 -6
  32. package/lib/commonjs/docs/classes/types.ZelloDispatchChannel.html +163 -11
  33. package/lib/commonjs/docs/classes/types.ZelloGroupConversation.html +178 -13
  34. package/lib/commonjs/docs/classes/types.ZelloHistoryAlertMessage.html +131 -10
  35. package/lib/commonjs/docs/classes/types.ZelloHistoryImageMessage.html +123 -9
  36. package/lib/commonjs/docs/classes/types.ZelloHistoryLocationMessage.html +155 -13
  37. package/lib/commonjs/docs/classes/types.ZelloHistoryTextMessage.html +131 -10
  38. package/lib/commonjs/docs/classes/types.ZelloHistoryVoiceMessage.html +145 -10
  39. package/lib/commonjs/docs/classes/types.ZelloImageMessage.html +130 -10
  40. package/lib/commonjs/docs/classes/types.ZelloIncomingEmergency.html +114 -9
  41. package/lib/commonjs/docs/classes/types.ZelloIncomingVoiceMessage.html +124 -8
  42. package/lib/commonjs/docs/classes/types.ZelloLocationMessage.html +146 -12
  43. package/lib/commonjs/docs/classes/types.ZelloOutgoingEmergency.html +98 -7
  44. package/lib/commonjs/docs/classes/types.ZelloOutgoingVoiceMessage.html +120 -9
  45. package/lib/commonjs/docs/classes/types.ZelloRecentEntry.html +114 -9
  46. package/lib/commonjs/docs/classes/types.ZelloTextMessage.html +122 -9
  47. package/lib/commonjs/docs/classes/types.ZelloTranscription.html +122 -0
  48. package/lib/commonjs/docs/classes/types.ZelloTranslation.html +91 -0
  49. package/lib/commonjs/docs/classes/types.ZelloUser.html +142 -11
  50. package/lib/commonjs/docs/classes/types.ZelloUserSupportedFeatures.html +82 -5
  51. package/lib/commonjs/docs/enums/events.ZelloEvent.html +563 -95
  52. package/lib/commonjs/docs/enums/types.ZelloAccountStatus.html +67 -5
  53. package/lib/commonjs/docs/enums/types.ZelloChannelAlertLevel.html +67 -5
  54. package/lib/commonjs/docs/enums/types.ZelloChannelConnectionStatus.html +68 -3
  55. package/lib/commonjs/docs/enums/types.ZelloChannelType.html +84 -0
  56. package/lib/commonjs/docs/enums/types.ZelloConnectionError.html +68 -3
  57. package/lib/commonjs/docs/enums/types.ZelloConnectionState.html +73 -3
  58. package/lib/commonjs/docs/enums/types.ZelloContactType.html +73 -3
  59. package/lib/commonjs/docs/enums/types.ZelloDispatchCallStatus.html +73 -3
  60. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageError.html +63 -3
  61. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageState.html +78 -3
  62. package/lib/commonjs/docs/enums/types.ZelloRecentEntryType.html +78 -3
  63. package/lib/commonjs/docs/enums/types.ZelloUserStatus.html +81 -7
  64. package/lib/commonjs/docs/hierarchy.html +29 -1
  65. package/lib/commonjs/docs/index.html +127 -29
  66. package/lib/commonjs/docs/interfaces/specs_NativeZelloSdk.Spec.html +504 -0
  67. package/lib/commonjs/docs/modules/events.html +37 -1
  68. package/lib/commonjs/docs/modules/index.html +37 -1
  69. package/lib/commonjs/docs/modules/sdk.html +37 -1
  70. package/lib/commonjs/docs/modules/specs_NativeZelloSdk.html +41 -0
  71. package/lib/commonjs/docs/modules/types.html +45 -1
  72. package/lib/commonjs/docs/modules.html +36 -1
  73. package/lib/commonjs/docs/types/types.ZelloChannelOptions.html +114 -9
  74. package/lib/commonjs/docs/types/types.ZelloConfig.html +86 -7
  75. package/lib/commonjs/docs/types/types.ZelloConsoleSettings.html +96 -9
  76. package/lib/commonjs/docs/types/types.ZelloContact.html +80 -6
  77. package/lib/commonjs/docs/types/types.ZelloCredentials.html +75 -6
  78. package/lib/commonjs/docs/types/types.ZelloHistoryMessage.html +97 -8
  79. package/lib/commonjs/docs/types/types.ZelloMessage.html +91 -7
  80. package/lib/commonjs/docs/variables/specs_NativeZelloSdk.default.html +34 -0
  81. package/lib/commonjs/events/index.js +217 -0
  82. package/lib/commonjs/events/index.js.map +1 -1
  83. package/lib/commonjs/sdk/index.js +731 -911
  84. package/lib/commonjs/sdk/index.js.map +1 -1
  85. package/lib/commonjs/specs/NativeZelloSdk.js +27 -0
  86. package/lib/commonjs/specs/NativeZelloSdk.js.map +1 -0
  87. package/lib/commonjs/types/index.js +423 -302
  88. package/lib/commonjs/types/index.js.map +1 -1
  89. package/lib/commonjs/utils/index.js +27 -4
  90. package/lib/commonjs/utils/index.js.map +1 -1
  91. package/lib/module/docs/assets/highlight.css +1 -1
  92. package/lib/module/docs/assets/icons.js +1 -1
  93. package/lib/module/docs/assets/icons.js.map +1 -1
  94. package/lib/module/docs/assets/icons.svg +1 -1
  95. package/lib/module/docs/assets/main.js +220 -288
  96. package/lib/module/docs/assets/main.js.map +1 -1
  97. package/lib/module/docs/assets/navigation.js +1 -1
  98. package/lib/module/docs/assets/navigation.js.map +1 -1
  99. package/lib/module/docs/assets/search.js +1 -1
  100. package/lib/module/docs/assets/search.js.map +1 -1
  101. package/lib/module/docs/assets/style.css +12 -4
  102. package/lib/module/docs/classes/sdk.Zello.html +793 -97
  103. package/lib/module/docs/classes/types.ZelloAlertMessage.html +122 -9
  104. package/lib/module/docs/classes/types.ZelloChannel.html +155 -10
  105. package/lib/module/docs/classes/types.ZelloChannelUser.html +86 -4
  106. package/lib/module/docs/classes/types.ZelloDispatchCall.html +90 -6
  107. package/lib/module/docs/classes/types.ZelloDispatchChannel.html +163 -11
  108. package/lib/module/docs/classes/types.ZelloGroupConversation.html +178 -13
  109. package/lib/module/docs/classes/types.ZelloHistoryAlertMessage.html +131 -10
  110. package/lib/module/docs/classes/types.ZelloHistoryImageMessage.html +123 -9
  111. package/lib/module/docs/classes/types.ZelloHistoryLocationMessage.html +155 -13
  112. package/lib/module/docs/classes/types.ZelloHistoryTextMessage.html +131 -10
  113. package/lib/module/docs/classes/types.ZelloHistoryVoiceMessage.html +145 -10
  114. package/lib/module/docs/classes/types.ZelloImageMessage.html +130 -10
  115. package/lib/module/docs/classes/types.ZelloIncomingEmergency.html +114 -9
  116. package/lib/module/docs/classes/types.ZelloIncomingVoiceMessage.html +124 -8
  117. package/lib/module/docs/classes/types.ZelloLocationMessage.html +146 -12
  118. package/lib/module/docs/classes/types.ZelloOutgoingEmergency.html +98 -7
  119. package/lib/module/docs/classes/types.ZelloOutgoingVoiceMessage.html +120 -9
  120. package/lib/module/docs/classes/types.ZelloRecentEntry.html +114 -9
  121. package/lib/module/docs/classes/types.ZelloTextMessage.html +122 -9
  122. package/lib/module/docs/classes/types.ZelloTranscription.html +122 -0
  123. package/lib/module/docs/classes/types.ZelloTranslation.html +91 -0
  124. package/lib/module/docs/classes/types.ZelloUser.html +142 -11
  125. package/lib/module/docs/classes/types.ZelloUserSupportedFeatures.html +82 -5
  126. package/lib/module/docs/enums/events.ZelloEvent.html +563 -95
  127. package/lib/module/docs/enums/types.ZelloAccountStatus.html +67 -5
  128. package/lib/module/docs/enums/types.ZelloChannelAlertLevel.html +67 -5
  129. package/lib/module/docs/enums/types.ZelloChannelConnectionStatus.html +68 -3
  130. package/lib/module/docs/enums/types.ZelloChannelType.html +84 -0
  131. package/lib/module/docs/enums/types.ZelloConnectionError.html +68 -3
  132. package/lib/module/docs/enums/types.ZelloConnectionState.html +73 -3
  133. package/lib/module/docs/enums/types.ZelloContactType.html +73 -3
  134. package/lib/module/docs/enums/types.ZelloDispatchCallStatus.html +73 -3
  135. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageError.html +63 -3
  136. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageState.html +78 -3
  137. package/lib/module/docs/enums/types.ZelloRecentEntryType.html +78 -3
  138. package/lib/module/docs/enums/types.ZelloUserStatus.html +81 -7
  139. package/lib/module/docs/hierarchy.html +29 -1
  140. package/lib/module/docs/index.html +127 -29
  141. package/lib/module/docs/interfaces/specs_NativeZelloSdk.Spec.html +504 -0
  142. package/lib/module/docs/modules/events.html +37 -1
  143. package/lib/module/docs/modules/index.html +37 -1
  144. package/lib/module/docs/modules/sdk.html +37 -1
  145. package/lib/module/docs/modules/specs_NativeZelloSdk.html +41 -0
  146. package/lib/module/docs/modules/types.html +45 -1
  147. package/lib/module/docs/modules.html +36 -1
  148. package/lib/module/docs/types/types.ZelloChannelOptions.html +114 -9
  149. package/lib/module/docs/types/types.ZelloConfig.html +86 -7
  150. package/lib/module/docs/types/types.ZelloConsoleSettings.html +96 -9
  151. package/lib/module/docs/types/types.ZelloContact.html +80 -6
  152. package/lib/module/docs/types/types.ZelloCredentials.html +75 -6
  153. package/lib/module/docs/types/types.ZelloHistoryMessage.html +97 -8
  154. package/lib/module/docs/types/types.ZelloMessage.html +91 -7
  155. package/lib/module/docs/variables/specs_NativeZelloSdk.default.html +34 -0
  156. package/lib/module/events/index.js +217 -0
  157. package/lib/module/events/index.js.map +1 -1
  158. package/lib/module/sdk/index.js +730 -912
  159. package/lib/module/sdk/index.js.map +1 -1
  160. package/lib/module/specs/NativeZelloSdk.js +25 -0
  161. package/lib/module/specs/NativeZelloSdk.js.map +1 -0
  162. package/lib/module/types/index.js +378 -301
  163. package/lib/module/types/index.js.map +1 -1
  164. package/lib/module/utils/index.js +27 -5
  165. package/lib/module/utils/index.js.map +1 -1
  166. package/lib/typescript/commonjs/src/events/index.d.ts +9 -0
  167. package/lib/typescript/commonjs/src/events/index.d.ts.map +1 -1
  168. package/lib/typescript/commonjs/src/sdk/index.d.ts +10 -0
  169. package/lib/typescript/commonjs/src/sdk/index.d.ts.map +1 -1
  170. package/lib/typescript/commonjs/src/specs/NativeZelloSdk.d.ts +55 -0
  171. package/lib/typescript/commonjs/src/specs/NativeZelloSdk.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/types/index.d.ts +106 -4
  173. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/src/utils/index.d.ts +2 -1
  175. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  176. package/lib/typescript/module/src/events/index.d.ts +9 -0
  177. package/lib/typescript/module/src/events/index.d.ts.map +1 -1
  178. package/lib/typescript/module/src/index.d.ts +4 -4
  179. package/lib/typescript/module/src/index.d.ts.map +1 -1
  180. package/lib/typescript/module/src/sdk/index.d.ts +11 -1
  181. package/lib/typescript/module/src/sdk/index.d.ts.map +1 -1
  182. package/lib/typescript/module/src/specs/NativeZelloSdk.d.ts +55 -0
  183. package/lib/typescript/module/src/specs/NativeZelloSdk.d.ts.map +1 -0
  184. package/lib/typescript/module/src/types/index.d.ts +106 -4
  185. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  186. package/lib/typescript/module/src/utils/algorithms/index.d.ts +1 -1
  187. package/lib/typescript/module/src/utils/algorithms/index.d.ts.map +1 -1
  188. package/lib/typescript/module/src/utils/index.d.ts +2 -1
  189. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  190. package/package.json +31 -15
  191. package/react-native-zello-sdk.podspec +26 -1
  192. package/src/events/index.ts +9 -0
  193. package/src/sdk/index.ts +106 -226
  194. package/src/specs/NativeZelloSdk.ts +89 -0
  195. package/src/types/index.ts +153 -6
  196. package/src/utils/index.ts +50 -3
package/src/sdk/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // noinspection JSUnusedGlobalSymbols
2
2
 
3
3
  import {
4
+ DeviceEventEmitter,
4
5
  EmitterSubscription,
5
- NativeEventEmitter,
6
6
  NativeModules,
7
7
  } from 'react-native';
8
8
  import {
@@ -48,8 +48,12 @@ import {
48
48
  bridgeIncomingEmergencyToSdkIncomingEmergency,
49
49
  } from '../utils';
50
50
  import { ZelloEvent } from '../events';
51
+ import NativeZelloSdk from '../specs/NativeZelloSdk';
51
52
 
52
- const { ZelloAndroidSdkModule, ZelloIOSSdkModule } = NativeModules;
53
+ // `ZelloIOSSdkModule` is the iOS RCTEventEmitter that owns the Zello delegate
54
+ // (see `getSdk`). All method calls go through the unified `NativeZelloSdk`
55
+ // TurboModule, which on Android also owns the delegate.
56
+ const { ZelloIOSSdkModule } = NativeModules;
53
57
 
54
58
  /**
55
59
  * Zello SDK.
@@ -136,15 +140,12 @@ export class Zello extends EventEmitter {
136
140
 
137
141
  private constructor() {
138
142
  super();
143
+ // Accessing the native module instantiates it, which registers the SDK
144
+ // delegate that drives events. The events themselves arrive on the global
145
+ // DeviceEventEmitter 'zellosdk' channel (bridgeless-safe on both platforms).
139
146
  const sdk = Zello.getSdk();
140
147
  if (sdk) {
141
- let eventEmitter: NativeEventEmitter;
142
- if (isAndroid) {
143
- eventEmitter = new NativeEventEmitter();
144
- } else {
145
- eventEmitter = new NativeEventEmitter(sdk);
146
- }
147
- this.setupEventListener(eventEmitter);
148
+ this.setupEventListener();
148
149
  }
149
150
  }
150
151
 
@@ -153,14 +154,7 @@ export class Zello extends EventEmitter {
153
154
  * @param config The configuration to set.
154
155
  */
155
156
  public configure(config: ZelloConfig) {
156
- if (isAndroid) {
157
- ZelloAndroidSdkModule.configure(
158
- config.android.enableOfflineMessagePushNotifications,
159
- config.android.enableForegroundService
160
- );
161
- } else {
162
- ZelloIOSSdkModule.configure(config.ios.isDebugBuild, config.ios.appGroup);
163
- }
157
+ NativeZelloSdk.configure(config);
164
158
  }
165
159
 
166
160
  /**
@@ -179,19 +173,11 @@ export class Zello extends EventEmitter {
179
173
  * @param credentials The credentials to use for signing in.
180
174
  */
181
175
  public connect(credentials: ZelloCredentials) {
182
- if (isAndroid) {
183
- ZelloAndroidSdkModule.connect(
184
- credentials.network,
185
- credentials.username,
186
- credentials.password
187
- );
188
- } else {
189
- ZelloIOSSdkModule.connect(
190
- credentials.network,
191
- credentials.username,
192
- credentials.password
193
- );
194
- }
176
+ NativeZelloSdk.connect(
177
+ credentials.network,
178
+ credentials.username,
179
+ credentials.password
180
+ );
195
181
  }
196
182
 
197
183
  /**
@@ -199,11 +185,7 @@ export class Zello extends EventEmitter {
199
185
  * This will trigger the {@link ZelloEvent.DISCONNECTED} event.
200
186
  */
201
187
  public disconnect() {
202
- if (isAndroid) {
203
- ZelloAndroidSdkModule.disconnect();
204
- } else {
205
- ZelloIOSSdkModule.disconnect();
206
- }
188
+ NativeZelloSdk.disconnect();
207
189
  }
208
190
 
209
191
  /**
@@ -242,11 +224,7 @@ export class Zello extends EventEmitter {
242
224
  * @param contact The contact to set as selected.
243
225
  */
244
226
  public setSelectedContact(contact: ZelloContact) {
245
- if (isAndroid) {
246
- ZelloAndroidSdkModule.setSelectedContact(contact.name, contact.type);
247
- } else {
248
- ZelloIOSSdkModule.selectContact(contact.name, contact.type);
249
- }
227
+ NativeZelloSdk.selectContact(contact.name, contact.type);
250
228
  }
251
229
 
252
230
  /**
@@ -255,11 +233,7 @@ export class Zello extends EventEmitter {
255
233
  * @param status The account status to set.
256
234
  */
257
235
  public setAccountStatus(status: ZelloAccountStatus) {
258
- if (isAndroid) {
259
- ZelloAndroidSdkModule.setAccountStatus(status);
260
- } else {
261
- ZelloIOSSdkModule.setAccountStatus(status);
262
- }
236
+ NativeZelloSdk.setAccountStatus(status);
263
237
  }
264
238
 
265
239
  /**
@@ -269,14 +243,10 @@ export class Zello extends EventEmitter {
269
243
  * @param channel The channel to connect to.
270
244
  */
271
245
  public connectChannel(channel: ZelloChannel) {
272
- if (isAndroid) {
273
- ZelloAndroidSdkModule.connectChannel(channel.name);
246
+ if (channel.type === ZelloContactType.GroupConversation) {
247
+ NativeZelloSdk.connectGroupConversation(channel.name);
274
248
  } else {
275
- if (channel.type === ZelloContactType.GroupConversation) {
276
- ZelloIOSSdkModule.connectGroupConversation(channel.name);
277
- } else {
278
- ZelloIOSSdkModule.connectChannel(channel.name);
279
- }
249
+ NativeZelloSdk.connectChannel(channel.name);
280
250
  }
281
251
  }
282
252
 
@@ -287,14 +257,10 @@ export class Zello extends EventEmitter {
287
257
  * @param channel The channel to disconnect from.
288
258
  */
289
259
  public disconnectChannel(channel: ZelloChannel) {
290
- if (isAndroid) {
291
- ZelloAndroidSdkModule.disconnectChannel(channel.name);
260
+ if (channel.type === ZelloContactType.GroupConversation) {
261
+ NativeZelloSdk.disconnectGroupConversation(channel.name);
292
262
  } else {
293
- if (channel.type === ZelloContactType.GroupConversation) {
294
- ZelloIOSSdkModule.disconnectGroupConversation(channel.name);
295
- } else {
296
- ZelloIOSSdkModule.disconnectChannel(channel.name);
297
- }
263
+ NativeZelloSdk.disconnectChannel(channel.name);
298
264
  }
299
265
  }
300
266
 
@@ -305,11 +271,7 @@ export class Zello extends EventEmitter {
305
271
  * @param contact The contact to start the voice message with.
306
272
  */
307
273
  public startVoiceMessage(contact: ZelloContact) {
308
- if (isAndroid) {
309
- ZelloAndroidSdkModule.startVoiceMessage(contact.name, contact.type);
310
- } else {
311
- ZelloIOSSdkModule.startVoiceMessage(contact.name, contact.type);
312
- }
274
+ NativeZelloSdk.startVoiceMessage(contact.name, contact.type);
313
275
  }
314
276
 
315
277
  /**
@@ -317,11 +279,7 @@ export class Zello extends EventEmitter {
317
279
  * This will trigger the {@link ZelloEvent.OUTGOING_VOICE_MESSAGE_STOPPED} event.
318
280
  */
319
281
  public stopVoiceMessage() {
320
- if (isAndroid) {
321
- ZelloAndroidSdkModule.stopVoiceMessage();
322
- } else {
323
- ZelloIOSSdkModule.stopVoiceMessage();
324
- }
282
+ NativeZelloSdk.stopVoiceMessage();
325
283
  }
326
284
 
327
285
  /**
@@ -331,11 +289,7 @@ export class Zello extends EventEmitter {
331
289
  * @param data The image data to send.
332
290
  */
333
291
  public sendImage(contact: ZelloContact, data: number[]) {
334
- if (isAndroid) {
335
- ZelloAndroidSdkModule.sendImage(contact.name, contact.type, data);
336
- } else {
337
- ZelloIOSSdkModule.sendImage(contact.name, contact.type, data);
338
- }
292
+ NativeZelloSdk.sendImage(contact.name, contact.type, data);
339
293
  }
340
294
 
341
295
  /**
@@ -344,11 +298,7 @@ export class Zello extends EventEmitter {
344
298
  * @param contact The contact to send the alert to.
345
299
  */
346
300
  public sendLocation(contact: ZelloContact) {
347
- if (isAndroid) {
348
- ZelloAndroidSdkModule.sendLocation(contact.name, contact.type);
349
- } else {
350
- ZelloIOSSdkModule.sendLocation(contact.name, contact.type);
351
- }
301
+ NativeZelloSdk.sendLocation(contact.name, contact.type);
352
302
  }
353
303
 
354
304
  /**
@@ -358,11 +308,7 @@ export class Zello extends EventEmitter {
358
308
  * @param text The text to send.
359
309
  */
360
310
  public sendText(contact: ZelloContact, text: string) {
361
- if (isAndroid) {
362
- ZelloAndroidSdkModule.sendText(contact.name, contact.type, text);
363
- } else {
364
- ZelloIOSSdkModule.sendText(contact.name, contact.type, text);
365
- }
311
+ NativeZelloSdk.sendText(contact.name, contact.type, text);
366
312
  }
367
313
 
368
314
  /**
@@ -377,11 +323,7 @@ export class Zello extends EventEmitter {
377
323
  text: string,
378
324
  level?: ZelloChannelAlertLevel
379
325
  ) {
380
- if (isAndroid) {
381
- ZelloAndroidSdkModule.sendAlert(contact.name, contact.type, text, level);
382
- } else {
383
- ZelloIOSSdkModule.sendAlert(contact.name, contact.type, text, level);
384
- }
326
+ NativeZelloSdk.sendAlert(contact.name, contact.type, text, level ?? '');
385
327
  }
386
328
 
387
329
  /**
@@ -389,11 +331,7 @@ export class Zello extends EventEmitter {
389
331
  * Additionally, please contact us to provide more information on what happened.
390
332
  */
391
333
  public submitProblemReport() {
392
- if (isAndroid) {
393
- ZelloAndroidSdkModule.submitProblemReport();
394
- } else {
395
- ZelloIOSSdkModule.submitProblemReport();
396
- }
334
+ NativeZelloSdk.submitProblemReport();
397
335
  }
398
336
 
399
337
  /**
@@ -402,11 +340,7 @@ export class Zello extends EventEmitter {
402
340
  * @param contact The contact to mute.
403
341
  */
404
342
  public muteContact(contact: ZelloContact) {
405
- if (isAndroid) {
406
- ZelloAndroidSdkModule.muteContact(contact.name, contact.type);
407
- } else {
408
- ZelloIOSSdkModule.muteContact(contact.name, contact.type);
409
- }
343
+ NativeZelloSdk.muteContact(contact.name, contact.type);
410
344
  }
411
345
 
412
346
  /**
@@ -415,11 +349,7 @@ export class Zello extends EventEmitter {
415
349
  * @param contact The contact to unmute.
416
350
  */
417
351
  public unmuteContact(contact: ZelloContact) {
418
- if (isAndroid) {
419
- ZelloAndroidSdkModule.unmuteContact(contact.name, contact.type);
420
- } else {
421
- ZelloIOSSdkModule.unmuteContact(contact.name, contact.type);
422
- }
352
+ NativeZelloSdk.unmuteContact(contact.name, contact.type);
423
353
  }
424
354
 
425
355
  /**
@@ -428,11 +358,7 @@ export class Zello extends EventEmitter {
428
358
  * This will trigger the {@link ZelloEvent.OUTGOING_EMERGENCY_STARTED} event.
429
359
  */
430
360
  public startEmergency() {
431
- if (isAndroid) {
432
- ZelloAndroidSdkModule.startEmergency();
433
- } else {
434
- ZelloIOSSdkModule.startEmergency();
435
- }
361
+ NativeZelloSdk.startEmergency();
436
362
  }
437
363
 
438
364
  /**
@@ -440,11 +366,20 @@ export class Zello extends EventEmitter {
440
366
  * This will trigger the {@link ZelloEvent.OUTGOING_EMERGENCY_STOPPED} event.
441
367
  */
442
368
  public stopEmergency() {
443
- if (isAndroid) {
444
- ZelloAndroidSdkModule.stopEmergency();
445
- } else {
446
- ZelloIOSSdkModule.stopEmergency();
447
- }
369
+ NativeZelloSdk.stopEmergency();
370
+ }
371
+
372
+ /**
373
+ * Stops an incoming emergency started by another user on the emergency channel.
374
+ *
375
+ * This requires the emergency channel's {@link ZelloChannelOptions.allowEmergencyEndOthers | allowEmergencyEndOthers} option
376
+ * to be true; otherwise this method has no effect.
377
+ *
378
+ * On success, this will trigger the {@link ZelloEvent.INCOMING_EMERGENCY_STOPPED} event for the emergency.
379
+ * @param incomingEmergency The incoming emergency to stop. Must be one of the entries currently in {@link incomingEmergencies}.
380
+ */
381
+ public stopIncomingEmergency(incomingEmergency: ZelloIncomingEmergency) {
382
+ NativeZelloSdk.stopIncomingEmergency(incomingEmergency.emergencyId);
448
383
  }
449
384
 
450
385
  /**
@@ -453,38 +388,22 @@ export class Zello extends EventEmitter {
453
388
  * @param size Optional; The number of history items to retrieve. Defaults to 50.
454
389
  * @return The history items for the given contact.
455
390
  */
456
- public getHistory(
391
+ public async getHistory(
457
392
  contact: ZelloContact,
458
393
  size?: number
459
394
  ): Promise<ZelloHistoryMessage[]> {
460
395
  const defaultHistorySize = 50;
461
- return new Promise((resolve) => {
462
- const callback = (history: any[] | undefined) => {
463
- if (!history) {
464
- resolve([]);
465
- return;
466
- }
467
- const messages = history
468
- .map((message) => bridgeHistoryMessageToSdkHistoryMessage(message))
469
- .filter((item) => item !== undefined) as ZelloHistoryMessage[];
470
- resolve(messages);
471
- };
472
- if (isAndroid) {
473
- ZelloAndroidSdkModule.getHistory(
474
- contact.name,
475
- contact.type,
476
- size ?? defaultHistorySize,
477
- callback
478
- );
479
- } else {
480
- ZelloIOSSdkModule.getHistory(
481
- contact.name,
482
- contact.type,
483
- size ?? defaultHistorySize,
484
- callback
485
- );
486
- }
487
- });
396
+ const history = (await NativeZelloSdk.getHistory(
397
+ contact.name,
398
+ contact.type,
399
+ size ?? defaultHistorySize
400
+ )) as unknown as any[] | undefined;
401
+ if (!history) {
402
+ return [];
403
+ }
404
+ return history
405
+ .map((message) => bridgeHistoryMessageToSdkHistoryMessage(message))
406
+ .filter((item) => item !== undefined) as ZelloHistoryMessage[];
488
407
  }
489
408
 
490
409
  /**
@@ -493,19 +412,11 @@ export class Zello extends EventEmitter {
493
412
  * @param message The history message to play.
494
413
  */
495
414
  public playHistoryMessage(message: ZelloHistoryVoiceMessage) {
496
- if (isAndroid) {
497
- ZelloAndroidSdkModule.playHistoryMessage(
498
- message.historyId,
499
- message.contact.name,
500
- message.contact.type
501
- );
502
- } else {
503
- ZelloIOSSdkModule.playHistoryMessage(
504
- message.historyId,
505
- message.contact.name,
506
- message.contact.type
507
- );
508
- }
415
+ NativeZelloSdk.playHistoryMessage(
416
+ message.historyId,
417
+ message.contact.name,
418
+ message.contact.type
419
+ );
509
420
  }
510
421
 
511
422
  /**
@@ -513,11 +424,7 @@ export class Zello extends EventEmitter {
513
424
  * This will trigger the {@link ZelloEvent.HISTORY_PLAYBACK_STOPPED} event.
514
425
  */
515
426
  public stopHistoryMessagePlayback() {
516
- if (isAndroid) {
517
- ZelloAndroidSdkModule.stopHistoryMessagePlayback();
518
- } else {
519
- ZelloIOSSdkModule.stopHistoryMessagePlayback();
520
- }
427
+ NativeZelloSdk.stopHistoryMessagePlayback();
521
428
  }
522
429
 
523
430
  /**
@@ -528,23 +435,11 @@ export class Zello extends EventEmitter {
528
435
  public getImageDataForHistoryImageMessage(
529
436
  message: ZelloHistoryImageMessage
530
437
  ): Promise<string | undefined> {
531
- return new Promise((resolve) => {
532
- if (isAndroid) {
533
- ZelloAndroidSdkModule.getImageDataForHistoryImageMessage(
534
- message.historyId,
535
- message.contact.name,
536
- message.contact.type,
537
- (data: string | undefined) => resolve(data)
538
- );
539
- } else {
540
- ZelloIOSSdkModule.getHistoryImageData(
541
- message.historyId,
542
- message.contact.name,
543
- message.contact.type,
544
- (data: string | undefined) => resolve(data)
545
- );
546
- }
547
- });
438
+ return NativeZelloSdk.getHistoryImageData(
439
+ message.historyId,
440
+ message.contact.name,
441
+ message.contact.type
442
+ ) as unknown as Promise<string | undefined>;
548
443
  }
549
444
 
550
445
  /**
@@ -556,11 +451,7 @@ export class Zello extends EventEmitter {
556
451
  * @param channel The dispatch channel to end the call for.
557
452
  */
558
453
  public endDispatchCall(channel: ZelloDispatchChannel) {
559
- if (isAndroid) {
560
- ZelloAndroidSdkModule.endDispatchCall(channel.name);
561
- } else {
562
- ZelloIOSSdkModule.endDispatchCall(channel.name);
563
- }
454
+ NativeZelloSdk.endDispatchCall(channel.name);
564
455
  }
565
456
 
566
457
  /**
@@ -573,17 +464,10 @@ export class Zello extends EventEmitter {
573
464
  if (!this.consoleSettings?.allowGroupConversations) {
574
465
  return;
575
466
  }
576
- if (isAndroid) {
577
- ZelloAndroidSdkModule.createGroupConversation(
578
- users.map((user) => user.name),
579
- displayName
580
- );
581
- } else {
582
- ZelloIOSSdkModule.createGroupConversation(
583
- users.map((user) => user.name),
584
- displayName
585
- );
586
- }
467
+ NativeZelloSdk.createGroupConversation(
468
+ users.map((user) => user.name),
469
+ displayName ?? ''
470
+ );
587
471
  }
588
472
 
589
473
  /**
@@ -599,17 +483,10 @@ export class Zello extends EventEmitter {
599
483
  if (!this.consoleSettings?.allowGroupConversations) {
600
484
  return;
601
485
  }
602
- if (isAndroid) {
603
- ZelloAndroidSdkModule.addUsersToGroupConversation(
604
- groupConversation.name,
605
- users.map((user) => user.name)
606
- );
607
- } else {
608
- ZelloIOSSdkModule.addUsersToGroupConversation(
609
- groupConversation.name,
610
- users.map((user) => user.name)
611
- );
612
- }
486
+ NativeZelloSdk.addUsersToGroupConversation(
487
+ groupConversation.name,
488
+ users.map((user) => user.name)
489
+ );
613
490
  }
614
491
 
615
492
  /**
@@ -621,11 +498,7 @@ export class Zello extends EventEmitter {
621
498
  if (!this.consoleSettings?.allowGroupConversations) {
622
499
  return;
623
500
  }
624
- if (isAndroid) {
625
- ZelloAndroidSdkModule.leaveGroupConversation(groupConversation.name);
626
- } else {
627
- ZelloIOSSdkModule.leaveGroupConversation(groupConversation.name);
628
- }
501
+ NativeZelloSdk.leaveGroupConversation(groupConversation.name);
629
502
  }
630
503
 
631
504
  /**
@@ -641,18 +514,11 @@ export class Zello extends EventEmitter {
641
514
  if (!this.consoleSettings?.allowGroupConversations) {
642
515
  return;
643
516
  }
644
- if (isAndroid) {
645
- ZelloAndroidSdkModule.renameGroupConversation(
646
- groupConversation.name,
647
- name
648
- );
649
- } else {
650
- ZelloIOSSdkModule.renameGroupConversation(groupConversation.name, name);
651
- }
517
+ NativeZelloSdk.renameGroupConversation(groupConversation.name, name);
652
518
  }
653
519
 
654
- private setupEventListener(eventEmitter: NativeEventEmitter) {
655
- this.eventListener = eventEmitter.addListener('zellosdk', (event) => {
520
+ private setupEventListener() {
521
+ this.eventListener = DeviceEventEmitter.addListener('zellosdk', (event) => {
656
522
  const eventName = event.eventName;
657
523
  switch (eventName) {
658
524
  case 'onConnectFailed': {
@@ -742,7 +608,8 @@ export class Zello extends EventEmitter {
742
608
  this.incomingVoiceMessage = new ZelloIncomingVoiceMessage(
743
609
  contact,
744
610
  bridgeChannelUserToSdkChannelUser(event.channelUser),
745
- parseInt(event.timestamp, 10)
611
+ parseInt(event.timestamp, 10),
612
+ event.isTranslation === true
746
613
  );
747
614
  this.emit(
748
615
  ZelloEvent.INCOMING_VOICE_MESSAGE_STARTED,
@@ -761,7 +628,8 @@ export class Zello extends EventEmitter {
761
628
  new ZelloIncomingVoiceMessage(
762
629
  contact,
763
630
  bridgeChannelUserToSdkChannelUser(event.channelUser),
764
- parseInt(event.timestamp, 10)
631
+ parseInt(event.timestamp, 10),
632
+ event.isTranslation === true
765
633
  )
766
634
  );
767
635
  break;
@@ -996,7 +864,7 @@ export class Zello extends EventEmitter {
996
864
  event.longitude,
997
865
  event.accuracy,
998
866
  event.address
999
- ).contact
867
+ )
1000
868
  );
1001
869
  break;
1002
870
  }
@@ -1154,6 +1022,17 @@ export class Zello extends EventEmitter {
1154
1022
  );
1155
1023
  break;
1156
1024
  }
1025
+ case 'onHistoryVoiceMessageTranscriptionAvailable': {
1026
+ const message = bridgeHistoryMessageToSdkHistoryMessage(event);
1027
+ if (!(message instanceof ZelloHistoryVoiceMessage)) {
1028
+ break;
1029
+ }
1030
+ this.emit(
1031
+ ZelloEvent.HISTORY_VOICE_MESSAGE_TRANSCRIPTION_AVAILABLE,
1032
+ message
1033
+ );
1034
+ break;
1035
+ }
1157
1036
  case 'onConsoleSettingsChanged': {
1158
1037
  this.consoleSettings =
1159
1038
  bridgeConsoleSettingsToSdkConsoleSettings(event);
@@ -1286,9 +1165,10 @@ export class Zello extends EventEmitter {
1286
1165
  }
1287
1166
 
1288
1167
  private static getSdk() {
1289
- if (isAndroid) {
1290
- return ZelloAndroidSdkModule;
1291
- }
1292
- return ZelloIOSSdkModule;
1168
+ // On Android the TurboModule owns the Zello delegate and is already created
1169
+ // by importing the spec; on iOS the ZelloIOSSdkModule RCTEventEmitter owns
1170
+ // it and is instantiated on access. Either way this only needs to be truthy
1171
+ // so the DeviceEventEmitter listener gets registered.
1172
+ return isAndroid ? NativeZelloSdk : ZelloIOSSdkModule;
1293
1173
  }
1294
1174
  }
@@ -0,0 +1,89 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+ import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
4
+
5
+ /**
6
+ * Codegen spec for the unified Zello TurboModule.
7
+ *
8
+ * This single spec replaces the legacy, platform-divergent `ZelloIOSSdkModule`
9
+ * and `ZelloAndroidSdkModule` bridge modules. Both platforms implement the same
10
+ * interface. Events are not part of this spec: they are emitted on the global
11
+ * `DeviceEventEmitter` `'zellosdk'` channel and carry an `eventName`
12
+ * discriminator in their payload (see `src/events`).
13
+ *
14
+ * Codegen notes:
15
+ * - `configure` takes a single object so the platform-specific configuration
16
+ * fields (`ios.isDebugBuild`, `ios.appGroup`, `android.enableOfflineMessagePushNotifications`,
17
+ * `android.enableForegroundService`) can live in one signature.
18
+ * - The two legacy callback methods (`getHistory`, `getHistoryImageData`) are
19
+ * modeled as Promises, which is the TurboModule-native async shape.
20
+ * - `UnsafeObject` is used where the payload is a heterogeneous SDK structure
21
+ * that is normalized in the JS layer (`src/sdk`).
22
+ */
23
+ export interface Spec extends TurboModule {
24
+ configure(config: UnsafeObject): void;
25
+
26
+ connect(network: string, username: string, password: string): void;
27
+ disconnect(): void;
28
+
29
+ setAccountStatus(status: string): void;
30
+
31
+ selectContact(name: string, contactType: string): void;
32
+
33
+ startVoiceMessage(name: string, contactType: string): void;
34
+ stopVoiceMessage(): void;
35
+
36
+ sendImage(name: string, contactType: string, data: Array<number>): void;
37
+ sendLocation(name: string, contactType: string): void;
38
+ sendText(name: string, contactType: string, text: string): void;
39
+ sendAlert(
40
+ name: string,
41
+ contactType: string,
42
+ text: string,
43
+ level: string
44
+ ): void;
45
+
46
+ connectChannel(name: string): void;
47
+ disconnectChannel(name: string): void;
48
+
49
+ connectGroupConversation(name: string): void;
50
+ disconnectGroupConversation(name: string): void;
51
+
52
+ submitProblemReport(): void;
53
+
54
+ muteContact(name: string, contactType: string): void;
55
+ unmuteContact(name: string, contactType: string): void;
56
+
57
+ startEmergency(): void;
58
+ stopEmergency(): void;
59
+ stopIncomingEmergency(emergencyId: string): void;
60
+
61
+ getHistory(
62
+ name: string,
63
+ contactType: string,
64
+ maxMessages: number
65
+ ): Promise<UnsafeObject>;
66
+ playHistoryMessage(
67
+ historyId: string,
68
+ contactName: string,
69
+ contactType: string
70
+ ): void;
71
+ stopHistoryMessagePlayback(): void;
72
+ getHistoryImageData(
73
+ historyId: string,
74
+ contactName: string,
75
+ contactType: string
76
+ ): Promise<UnsafeObject>;
77
+
78
+ endDispatchCall(channelName: string): void;
79
+
80
+ createGroupConversation(usernames: Array<string>, displayName: string): void;
81
+ addUsersToGroupConversation(
82
+ conversationName: string,
83
+ usernames: Array<string>
84
+ ): void;
85
+ leaveGroupConversation(conversationName: string): void;
86
+ renameGroupConversation(conversationName: string, newName: string): void;
87
+ }
88
+
89
+ export default TurboModuleRegistry.getEnforcing<Spec>('NativeZelloSdk');