@zelloptt/react-native-zello-sdk 0.3.3 → 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.
Files changed (150) hide show
  1. package/README.md +22 -4
  2. package/android/build.gradle +5 -3
  3. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModule.kt +117 -7
  4. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModuleHelper.kt +76 -8
  5. package/ios/Extensions/ZelloConsoleSettings+Extension.swift +14 -0
  6. package/ios/Extensions/ZelloContact+Extension.swift +56 -2
  7. package/ios/Extensions/ZelloDispatchCall+Extension.swift +13 -0
  8. package/ios/Extensions/ZelloIOSSdkModule+Extension.swift +81 -8
  9. package/ios/ZelloIOSSdkModule.swift +61 -5
  10. package/ios/ZelloIOSSdkModuleBridge.m +14 -1
  11. package/lib/commonjs/docs/assets/highlight.css +18 -4
  12. package/lib/commonjs/docs/assets/navigation.js +1 -1
  13. package/lib/commonjs/docs/assets/navigation.js.map +1 -1
  14. package/lib/commonjs/docs/assets/search.js +1 -1
  15. package/lib/commonjs/docs/assets/search.js.map +1 -1
  16. package/lib/commonjs/docs/classes/sdk.Zello.html +75 -43
  17. package/lib/commonjs/docs/classes/types.ZelloAlertMessage.html +7 -7
  18. package/lib/commonjs/docs/classes/types.ZelloChannel.html +8 -8
  19. package/lib/commonjs/docs/classes/types.ZelloChannelUser.html +5 -4
  20. package/lib/commonjs/docs/classes/types.ZelloDispatchCall.html +7 -0
  21. package/lib/commonjs/docs/classes/types.ZelloDispatchChannel.html +19 -0
  22. package/lib/commonjs/docs/classes/types.ZelloGroupConversation.html +24 -0
  23. package/lib/commonjs/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
  24. package/lib/commonjs/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
  25. package/lib/commonjs/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
  26. package/lib/commonjs/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
  27. package/lib/commonjs/docs/classes/types.ZelloHistoryVoiceMessage.html +8 -8
  28. package/lib/commonjs/docs/classes/types.ZelloImageMessage.html +8 -8
  29. package/lib/commonjs/docs/classes/types.ZelloIncomingEmergency.html +7 -7
  30. package/lib/commonjs/docs/classes/types.ZelloIncomingVoiceMessage.html +6 -6
  31. package/lib/commonjs/docs/classes/types.ZelloLocationMessage.html +10 -10
  32. package/lib/commonjs/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
  33. package/lib/commonjs/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
  34. package/lib/commonjs/docs/classes/types.ZelloRecentEntry.html +7 -7
  35. package/lib/commonjs/docs/classes/types.ZelloTextMessage.html +7 -7
  36. package/lib/commonjs/docs/classes/types.ZelloUser.html +10 -8
  37. package/lib/commonjs/docs/classes/types.ZelloUserSupportedFeatures.html +5 -0
  38. package/lib/commonjs/docs/enums/events.ZelloEvent.html +108 -67
  39. package/lib/commonjs/docs/enums/types.ZelloAccountStatus.html +3 -3
  40. package/lib/commonjs/docs/enums/types.ZelloChannelAlertLevel.html +3 -3
  41. package/lib/commonjs/docs/enums/types.ZelloChannelConnectionStatus.html +2 -2
  42. package/lib/commonjs/docs/enums/types.ZelloConnectionError.html +2 -2
  43. package/lib/commonjs/docs/enums/types.ZelloConnectionState.html +2 -2
  44. package/lib/commonjs/docs/enums/types.ZelloContactType.html +4 -2
  45. package/lib/commonjs/docs/enums/types.ZelloDispatchCallStatus.html +6 -0
  46. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageError.html +2 -2
  47. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageState.html +2 -2
  48. package/lib/commonjs/docs/enums/types.ZelloRecentEntryType.html +2 -2
  49. package/lib/commonjs/docs/enums/types.ZelloUserStatus.html +5 -5
  50. package/lib/commonjs/docs/index.html +16 -8
  51. package/lib/commonjs/docs/modules/events.html +1 -1
  52. package/lib/commonjs/docs/modules/index.html +9 -3
  53. package/lib/commonjs/docs/modules/sdk.html +1 -1
  54. package/lib/commonjs/docs/modules/types.html +7 -1
  55. package/lib/commonjs/docs/types/types.ZelloChannelOptions.html +4 -4
  56. package/lib/commonjs/docs/types/types.ZelloConfig.html +4 -3
  57. package/lib/commonjs/docs/types/types.ZelloConsoleSettings.html +8 -0
  58. package/lib/commonjs/docs/types/types.ZelloContact.html +1 -1
  59. package/lib/commonjs/docs/types/types.ZelloCredentials.html +2 -2
  60. package/lib/commonjs/docs/types/types.ZelloHistoryMessage.html +1 -1
  61. package/lib/commonjs/docs/types/types.ZelloMessage.html +1 -1
  62. package/lib/commonjs/events/index.js +11 -0
  63. package/lib/commonjs/events/index.js.map +1 -1
  64. package/lib/commonjs/sdk/index.js +237 -16
  65. package/lib/commonjs/sdk/index.js.map +1 -1
  66. package/lib/commonjs/types/index.js +110 -4
  67. package/lib/commonjs/types/index.js.map +1 -1
  68. package/lib/commonjs/utils/index.js +73 -9
  69. package/lib/commonjs/utils/index.js.map +1 -1
  70. package/lib/module/docs/assets/highlight.css +18 -4
  71. package/lib/module/docs/assets/navigation.js +1 -1
  72. package/lib/module/docs/assets/navigation.js.map +1 -1
  73. package/lib/module/docs/assets/search.js +1 -1
  74. package/lib/module/docs/assets/search.js.map +1 -1
  75. package/lib/module/docs/classes/sdk.Zello.html +75 -43
  76. package/lib/module/docs/classes/types.ZelloAlertMessage.html +7 -7
  77. package/lib/module/docs/classes/types.ZelloChannel.html +8 -8
  78. package/lib/module/docs/classes/types.ZelloChannelUser.html +5 -4
  79. package/lib/module/docs/classes/types.ZelloDispatchCall.html +7 -0
  80. package/lib/module/docs/classes/types.ZelloDispatchChannel.html +19 -0
  81. package/lib/module/docs/classes/types.ZelloGroupConversation.html +24 -0
  82. package/lib/module/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
  83. package/lib/module/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
  84. package/lib/module/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
  85. package/lib/module/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
  86. package/lib/module/docs/classes/types.ZelloHistoryVoiceMessage.html +8 -8
  87. package/lib/module/docs/classes/types.ZelloImageMessage.html +8 -8
  88. package/lib/module/docs/classes/types.ZelloIncomingEmergency.html +7 -7
  89. package/lib/module/docs/classes/types.ZelloIncomingVoiceMessage.html +6 -6
  90. package/lib/module/docs/classes/types.ZelloLocationMessage.html +10 -10
  91. package/lib/module/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
  92. package/lib/module/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
  93. package/lib/module/docs/classes/types.ZelloRecentEntry.html +7 -7
  94. package/lib/module/docs/classes/types.ZelloTextMessage.html +7 -7
  95. package/lib/module/docs/classes/types.ZelloUser.html +10 -8
  96. package/lib/module/docs/classes/types.ZelloUserSupportedFeatures.html +5 -0
  97. package/lib/module/docs/enums/events.ZelloEvent.html +108 -67
  98. package/lib/module/docs/enums/types.ZelloAccountStatus.html +3 -3
  99. package/lib/module/docs/enums/types.ZelloChannelAlertLevel.html +3 -3
  100. package/lib/module/docs/enums/types.ZelloChannelConnectionStatus.html +2 -2
  101. package/lib/module/docs/enums/types.ZelloConnectionError.html +2 -2
  102. package/lib/module/docs/enums/types.ZelloConnectionState.html +2 -2
  103. package/lib/module/docs/enums/types.ZelloContactType.html +4 -2
  104. package/lib/module/docs/enums/types.ZelloDispatchCallStatus.html +6 -0
  105. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageError.html +2 -2
  106. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageState.html +2 -2
  107. package/lib/module/docs/enums/types.ZelloRecentEntryType.html +2 -2
  108. package/lib/module/docs/enums/types.ZelloUserStatus.html +5 -5
  109. package/lib/module/docs/index.html +16 -8
  110. package/lib/module/docs/modules/events.html +1 -1
  111. package/lib/module/docs/modules/index.html +9 -3
  112. package/lib/module/docs/modules/sdk.html +1 -1
  113. package/lib/module/docs/modules/types.html +7 -1
  114. package/lib/module/docs/types/types.ZelloChannelOptions.html +4 -4
  115. package/lib/module/docs/types/types.ZelloConfig.html +4 -3
  116. package/lib/module/docs/types/types.ZelloConsoleSettings.html +8 -0
  117. package/lib/module/docs/types/types.ZelloContact.html +1 -1
  118. package/lib/module/docs/types/types.ZelloCredentials.html +2 -2
  119. package/lib/module/docs/types/types.ZelloHistoryMessage.html +1 -1
  120. package/lib/module/docs/types/types.ZelloMessage.html +1 -1
  121. package/lib/module/events/index.js +11 -0
  122. package/lib/module/events/index.js.map +1 -1
  123. package/lib/module/sdk/index.js +240 -17
  124. package/lib/module/sdk/index.js.map +1 -1
  125. package/lib/module/types/index.js +115 -3
  126. package/lib/module/types/index.js.map +1 -1
  127. package/lib/module/utils/index.js +71 -10
  128. package/lib/module/utils/index.js.map +1 -1
  129. package/lib/typescript/commonjs/src/events/index.d.ts +65 -2
  130. package/lib/typescript/commonjs/src/events/index.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/src/sdk/index.d.ts +53 -4
  132. package/lib/typescript/commonjs/src/sdk/index.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/src/types/index.d.ts +109 -6
  134. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/src/utils/index.d.ts +4 -1
  136. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  137. package/lib/typescript/module/src/events/index.d.ts +65 -2
  138. package/lib/typescript/module/src/events/index.d.ts.map +1 -1
  139. package/lib/typescript/module/src/sdk/index.d.ts +53 -4
  140. package/lib/typescript/module/src/sdk/index.d.ts.map +1 -1
  141. package/lib/typescript/module/src/types/index.d.ts +109 -6
  142. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  143. package/lib/typescript/module/src/utils/index.d.ts +4 -1
  144. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  145. package/package.json +1 -2
  146. package/react-native-zello-sdk.podspec +1 -1
  147. package/src/events/index.ts +64 -1
  148. package/src/sdk/index.ts +286 -19
  149. package/src/types/index.ts +152 -5
  150. package/src/utils/index.ts +124 -29
package/README.md CHANGED
@@ -8,11 +8,13 @@ This repository contains both the React Native Bridge, as well as an example app
8
8
 
9
9
  To see an example of the React Native SDK, check out [the example folder](https://github.com/zelloptt/react-native-zello-sdk/tree/master/example).
10
10
 
11
- The following instructions are for the SDK, not for the example app.
11
+ The following instructions are for the installation of the SDK into your application - **not** for the example app.
12
12
 
13
13
  ## Prerequisites
14
14
  A React Native application and environment.
15
15
 
16
+ A thorough understanding of Zello. The best place to get started is our [documentation](https://sdk.zello.com/).
17
+
16
18
 
17
19
  ## Installation
18
20
 
@@ -23,15 +25,30 @@ npm install @zelloptt/react-native-zello-sdk
23
25
 
24
26
  ### iOS
25
27
 
26
- Please reference the iOS Installation Guide.
28
+ Before getting started, please reference the [iOS Installation Guide](https://sdk.zello.com/installation-guides/ios-installation-guide).
29
+
30
+ The main amendment to the guide is that there is no need to add the `ZelloSDK` as a pod directly to your project.
31
+
32
+ #### Troubleshooting
33
+
34
+ While setting up your Notification Service Extension, you may receive an error:
35
+
36
+ ```
37
+ Cycle inside YourApp; building could produce unreliable results.
38
+ Cycle details:
39
+ → Target ‘YourApp’
40
+ ○ That command depends on command in Target ‘YourApp’: script phase “[CP-User] [RNFB] Core Configuration”
41
+ ```
42
+
43
+ If you receive the above error, you should move the `Build Phases` phase named `Embed Foundation Extensions` to higher up in the order.
27
44
 
28
45
  ### Android
29
46
 
30
- Before getting started, please reference the Android Installation Guide.
47
+ Before getting started, please reference the [Android Installation Guide](https://sdk.zello.com/installation-guides/android-installation-guide).
31
48
 
32
49
  #### Dependencies
33
50
 
34
- Add the repositories to your app's `build.gradle`:
51
+ You may or may not need to add the repositories to your app's `build.gradle`:
35
52
 
36
53
  ```
37
54
  repositories {
@@ -100,6 +117,7 @@ class MainApplication : Application(), ReactApplication {
100
117
 
101
118
  override fun onCreate() {
102
119
  super.onCreate()
120
+ // Don't forget to start the SDK!
103
121
  zello.start()
104
122
  }
105
123
  }
@@ -102,6 +102,8 @@ repositories {
102
102
 
103
103
  def kotlin_version = getExtOrDefault("kotlinVersion")
104
104
 
105
+ def zelloSdkVersion = "1.0.0"
106
+
105
107
  dependencies {
106
108
  // For < 0.71, this will be from the local maven repo
107
109
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
@@ -110,9 +112,9 @@ dependencies {
110
112
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
111
113
 
112
114
  // Required Dependencies to use the Zello SDK
113
- api("com.zello:sdk:0.3.1")
114
- api("com.zello:zello:0.3.1")
115
- api("com.zello:core:0.3.1") {
115
+ api("com.zello:sdk:$zelloSdkVersion")
116
+ api("com.zello:zello:$zelloSdkVersion")
117
+ api("com.zello:core:$zelloSdkVersion") {
116
118
  exclude module: "unspecified"
117
119
  }
118
120
  implementation(platform("com.google.firebase:firebase-bom:33.1.2"))
@@ -14,9 +14,11 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
14
14
  import com.zello.sdk.Zello
15
15
  import com.zello.sdk.ZelloAccountStatus
16
16
  import com.zello.sdk.ZelloAlertMessage
17
+ import com.zello.sdk.ZelloChannel
17
18
  import com.zello.sdk.ZelloConnectionError
18
19
  import com.zello.sdk.ZelloContact
19
20
  import com.zello.sdk.ZelloCredentials
21
+ import com.zello.sdk.ZelloDispatchChannel
20
22
  import com.zello.sdk.ZelloHistoryImageMessage
21
23
  import com.zello.sdk.ZelloHistoryVoiceMessage
22
24
  import com.zello.sdk.ZelloImageMessage
@@ -26,6 +28,9 @@ import com.zello.sdk.ZelloLocationMessage
26
28
  import com.zello.sdk.ZelloOutgoingEmergency
27
29
  import com.zello.sdk.ZelloOutgoingVoiceMessage
28
30
  import com.zello.sdk.ZelloRecentEntry
31
+ import com.zello.sdk.ZelloConsoleSettings
32
+ import com.zello.sdk.ZelloGroupConversation
33
+ import com.zello.sdk.ZelloState
29
34
  import com.zello.sdk.ZelloTextMessage
30
35
  import javax.inject.Inject
31
36
 
@@ -177,6 +182,41 @@ class ZelloAndroidSdkModule @Inject constructor(
177
182
  }
178
183
  }
179
184
 
185
+ @ReactMethod
186
+ fun endDispatchCall(channelName: String) {
187
+ val dispatchChannel = zello.getChannel(channelName) as? ZelloDispatchChannel ?: return
188
+ val call = dispatchChannel.currentCall ?: return
189
+ zello.endDispatchCall(call, dispatchChannel)
190
+ }
191
+
192
+ @ReactMethod
193
+ fun createGroupConversation(usernames: ReadableArray, displayName: String?) {
194
+ val users = usernames.toArrayList().mapNotNull { zello.getUser(it as String) }
195
+ zello.createGroupConversation(users, displayName)
196
+ }
197
+
198
+ @ReactMethod
199
+ fun addUsersToGroupConversation(conversationName: String, usernames: ReadableArray) {
200
+ val conversation = zello.getGroupConversation(conversationName) ?: return
201
+ val users = usernames.toArrayList().mapNotNull { zello.getUser(it as String) }
202
+ zello.addUsersToGroupConversation(conversation, users)
203
+ }
204
+
205
+ @ReactMethod
206
+ fun leaveGroupConversation(conversationName: String) {
207
+ val conversation = zello.getGroupConversation(conversationName) ?: return
208
+ zello.leaveGroupConversation(conversation)
209
+ }
210
+
211
+ @ReactMethod
212
+ fun renameGroupConversation(conversationName: String, newName: String) {
213
+ val conversation = zello.getGroupConversation(conversationName) ?: return
214
+ zello.renameGroupConversation(conversation, newName)
215
+ }
216
+
217
+ override fun onStateChanged(sdk: Zello, state: ZelloState) {
218
+ }
219
+
180
220
  override fun onConnectFailed(zello: Zello, error: ZelloConnectionError) {
181
221
  sendEvent(reactApplicationContext, "onConnectFailed", Arguments.createMap().apply {
182
222
  putString("error", error.toString())
@@ -192,7 +232,7 @@ class ZelloAndroidSdkModule @Inject constructor(
192
232
  }
193
233
 
194
234
  override fun onContactListUpdated(zello: Zello) {
195
- val map = ZelloAndroidSdkModuleHelper.contactListToWritableMap(this.zello.users, this.zello.channels)
235
+ val map = ZelloAndroidSdkModuleHelper.contactListToWritableMap(this.zello.users, this.zello.channels, this.zello.groupConversations)
196
236
  this.zello.emergencyChannel?.let {
197
237
  map.putMap("emergencyChannel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(it))
198
238
  }
@@ -226,7 +266,7 @@ class ZelloAndroidSdkModule @Inject constructor(
226
266
  override fun onIncomingAlertMessage(zello: Zello, message: ZelloAlertMessage) {
227
267
  sendEvent(reactApplicationContext, "onIncomingAlertMessage", Arguments.createMap().apply {
228
268
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
229
- putString("channelUserName", message.channelUser?.name)
269
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
230
270
  putString("timestamp", message.timestamp.toString())
231
271
  putString("text", message.text)
232
272
  })
@@ -251,7 +291,7 @@ class ZelloAndroidSdkModule @Inject constructor(
251
291
  override fun onIncomingImageMessage(message: ZelloImageMessage) {
252
292
  sendEvent(reactApplicationContext, "onIncomingImageMessage", Arguments.createMap().apply {
253
293
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
254
- putString("channelUserName", message.channelUser?.name)
294
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
255
295
  putString("timestamp", message.timestamp.toString())
256
296
  putString("thumbnail", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.thumbnail))
257
297
  putString("image", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.image))
@@ -261,7 +301,7 @@ class ZelloAndroidSdkModule @Inject constructor(
261
301
  override fun onIncomingLocationMessage(zello: Zello, message: ZelloLocationMessage) {
262
302
  sendEvent(reactApplicationContext, "onIncomingLocationMessage", Arguments.createMap().apply {
263
303
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
264
- putString("channelUserName", message.channelUser?.name)
304
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
265
305
  putString("timestamp", message.timestamp.toString())
266
306
  putString("address", message.address)
267
307
  putDouble("latitude", message.latitude)
@@ -311,7 +351,7 @@ class ZelloAndroidSdkModule @Inject constructor(
311
351
  override fun onIncomingTextMessage(message: ZelloTextMessage) {
312
352
  sendEvent(reactApplicationContext, "onIncomingTextMessage", Arguments.createMap().apply {
313
353
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
314
- putString("channelUserName", message.channelUser?.name)
354
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
315
355
  putString("timestamp", message.timestamp.toString())
316
356
  putString("text", message.text)
317
357
  })
@@ -320,7 +360,7 @@ class ZelloAndroidSdkModule @Inject constructor(
320
360
  override fun onIncomingVoiceMessageStarted(zello: Zello, message: ZelloIncomingVoiceMessage) {
321
361
  sendEvent(reactApplicationContext, "onIncomingVoiceMessageStarted", Arguments.createMap().apply {
322
362
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
323
- putString("channelUserName", message.channelUser?.name)
363
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
324
364
  putString("timestamp", message.timestamp.toString())
325
365
  })
326
366
  }
@@ -328,7 +368,7 @@ class ZelloAndroidSdkModule @Inject constructor(
328
368
  override fun onIncomingVoiceMessageStopped(zello: Zello, message: ZelloIncomingVoiceMessage) {
329
369
  sendEvent(reactApplicationContext, "onIncomingVoiceMessageStopped", Arguments.createMap().apply {
330
370
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
331
- putString("channelUserName", message.channelUser?.name)
371
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
332
372
  putString("timestamp", message.timestamp.toString())
333
373
  })
334
374
  }
@@ -429,6 +469,76 @@ class ZelloAndroidSdkModule @Inject constructor(
429
469
  sendEvent(reactApplicationContext, "onHistoryUpdated", null)
430
470
  }
431
471
 
472
+ override fun onConsoleSettingsChanged(zello: Zello, settings: ZelloConsoleSettings) {
473
+ sendEvent(reactApplicationContext, "onConsoleSettingsChanged", ZelloAndroidSdkModuleHelper.consoleSettingsToWritableMap(settings))
474
+ }
475
+
476
+ override fun onDispatchCallPending(zello: Zello, channel: ZelloDispatchChannel, call: ZelloDispatchChannel.Call) {
477
+ sendEvent(reactApplicationContext, "onDispatchCallPending", Arguments.createMap().apply {
478
+ putMap("call", ZelloAndroidSdkModuleHelper.callToWritableMap(call))
479
+ putMap("channel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(channel))
480
+ })
481
+ }
482
+
483
+ override fun onDispatchCallActive(zello: Zello, channel: ZelloDispatchChannel, call: ZelloDispatchChannel.Call) {
484
+ sendEvent(reactApplicationContext, "onDispatchCallActive", Arguments.createMap().apply {
485
+ putMap("call", ZelloAndroidSdkModuleHelper.callToWritableMap(call))
486
+ putMap("channel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(channel))
487
+ })
488
+ }
489
+
490
+ override fun onDispatchCallTransferred(zello: Zello, channel: ZelloDispatchChannel, call: ZelloDispatchChannel.Call) {
491
+ sendEvent(reactApplicationContext, "onDispatchCallTransferred", Arguments.createMap().apply {
492
+ putMap("call", ZelloAndroidSdkModuleHelper.callToWritableMap(call))
493
+ putMap("channel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(channel))
494
+ })
495
+ }
496
+
497
+ override fun onDispatchCallEnded(zello: Zello, channel: ZelloDispatchChannel, call: ZelloDispatchChannel.Call) {
498
+ sendEvent(reactApplicationContext, "onDispatchCallEnded", Arguments.createMap().apply {
499
+ putMap("call", ZelloAndroidSdkModuleHelper.callToWritableMap(call))
500
+ putMap("channel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(channel))
501
+ })
502
+ }
503
+
504
+ override fun onGroupConversationLeft(sdk: Zello, conversation: ZelloGroupConversation) {
505
+ sendEvent(reactApplicationContext, "onGroupConversationLeft", Arguments.createMap().apply {
506
+ putMap("conversation", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(conversation))
507
+ })
508
+ }
509
+
510
+ override fun onGroupConversationInvite(sdk: Zello, conversation: ZelloGroupConversation) {
511
+ sendEvent(reactApplicationContext, "onGroupConversationInvite", Arguments.createMap().apply {
512
+ putMap("conversation", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(conversation))
513
+ })
514
+ }
515
+
516
+ override fun onGroupConversationCreated(sdk: Zello, conversation: ZelloGroupConversation) {
517
+ sendEvent(reactApplicationContext, "onGroupConversationCreated", Arguments.createMap().apply {
518
+ putMap("conversation", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(conversation))
519
+ })
520
+ }
521
+
522
+ override fun onGroupConversationRenamed(sdk: Zello, conversation: ZelloGroupConversation) {
523
+ sendEvent(reactApplicationContext, "onGroupConversationRenamed", Arguments.createMap().apply {
524
+ putMap("conversation", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(conversation))
525
+ })
526
+ }
527
+
528
+ override fun onGroupConversationUsersAdded(sdk: Zello, conversation: ZelloGroupConversation, users: List<ZelloChannel.User>) {
529
+ sendEvent(reactApplicationContext, "onGroupConversationUsersAdded", Arguments.createMap().apply {
530
+ putMap("conversation", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(conversation))
531
+ putArray("users", ZelloAndroidSdkModuleHelper.channelUsersToWritableArray(users))
532
+ })
533
+ }
534
+
535
+ override fun onGroupConversationUsersLeft(sdk: Zello, conversation: ZelloGroupConversation, users: List<ZelloChannel.User>) {
536
+ sendEvent(reactApplicationContext, "onGroupConversationUsersLeft", Arguments.createMap().apply {
537
+ putMap("conversation", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(conversation))
538
+ putArray("users", ZelloAndroidSdkModuleHelper.channelUsersToWritableArray(users))
539
+ })
540
+ }
541
+
432
542
  private fun sendEvent(reactContext: ReactContext, name: String, params: WritableMap?) {
433
543
  reactContext
434
544
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
@@ -7,7 +7,10 @@ import com.facebook.react.bridge.WritableMap
7
7
  import com.facebook.react.bridge.WritableNativeArray
8
8
  import com.facebook.react.bridge.WritableNativeMap
9
9
  import com.zello.sdk.ZelloChannel
10
+ import com.zello.sdk.ZelloConsoleSettings
10
11
  import com.zello.sdk.ZelloContact
12
+ import com.zello.sdk.ZelloDispatchChannel
13
+ import com.zello.sdk.ZelloGroupConversation
11
14
  import com.zello.sdk.ZelloHistoryAlertMessage
12
15
  import com.zello.sdk.ZelloHistoryImageMessage
13
16
  import com.zello.sdk.ZelloHistoryLocationMessage
@@ -20,7 +23,7 @@ import com.zello.sdk.ZelloUser
20
23
  import java.io.ByteArrayOutputStream
21
24
 
22
25
  object ZelloAndroidSdkModuleHelper {
23
- fun contactListToWritableMap(users: List<ZelloUser>, channels: List<ZelloChannel>): WritableMap {
26
+ fun contactListToWritableMap(users: List<ZelloUser>, channels: List<ZelloChannel>, groupConversation: List<ZelloGroupConversation>): WritableMap {
24
27
  return Arguments.createMap().apply {
25
28
  putArray("users", WritableNativeArray().apply {
26
29
  users.forEach { user ->
@@ -32,6 +35,11 @@ object ZelloAndroidSdkModuleHelper {
32
35
  pushMap(sdkContactToWritableMap(channel))
33
36
  }
34
37
  })
38
+ putArray("groupConversations", WritableNativeArray().apply {
39
+ groupConversation.forEach { conversation ->
40
+ pushMap(sdkContactToWritableMap(conversation))
41
+ }
42
+ })
35
43
  }
36
44
  }
37
45
 
@@ -46,6 +54,9 @@ object ZelloAndroidSdkModuleHelper {
46
54
  putString("customStatusText", contact.customStatusText)
47
55
  putString("profilePictureUrl", contact.profilePictureUrl)
48
56
  putString("profilePictureThumbnailUrl", contact.profilePictureThumbnailUrl)
57
+ putMap("supportedFeatures", WritableNativeMap().apply {
58
+ putBoolean("groupConversations", contact.supportedFeatures.groupConversations)
59
+ })
49
60
  }
50
61
 
51
62
  is ZelloChannel -> WritableNativeMap().apply {
@@ -64,6 +75,25 @@ object ZelloAndroidSdkModuleHelper {
64
75
  putBoolean("allowTextMessages", options.allowTextMessages)
65
76
  putBoolean("allowLocations", options.allowLocations)
66
77
  })
78
+ if (contact is ZelloDispatchChannel) {
79
+ putBoolean("isDispatchChannel", true)
80
+ contact.currentCall?.let { call ->
81
+ putMap("currentCall", callToWritableMap(call))
82
+ }
83
+ } else if (contact is ZelloGroupConversation) {
84
+ putBoolean("isGroupConversation", true)
85
+ putString("displayName", contact.displayName)
86
+ putArray("users", WritableNativeArray().apply {
87
+ contact.users.forEach { user ->
88
+ pushMap(channelUserToWritableMap(user))
89
+ }
90
+ })
91
+ putArray("onlineUsers", WritableNativeArray().apply {
92
+ contact.onlineUsers.forEach { user ->
93
+ pushMap(channelUserToWritableMap(user))
94
+ }
95
+ })
96
+ }
67
97
  }
68
98
 
69
99
  else -> WritableNativeMap()
@@ -81,7 +111,7 @@ object ZelloAndroidSdkModuleHelper {
81
111
  fun incomingEmergencyToWritableMap(incomingEmergency: ZelloIncomingEmergency): WritableMap {
82
112
  return Arguments.createMap().apply {
83
113
  putMap("channel", sdkContactToWritableMap(contact = incomingEmergency.channel))
84
- putString("channelUserName", incomingEmergency.channelUser.name)
114
+ putMap("channelUser", channelUserToWritableMap(incomingEmergency.channelUser))
85
115
  putString("emergencyId", incomingEmergency.emergencyId)
86
116
  putString("startTimestamp", incomingEmergency.startTimestamp.toString())
87
117
  incomingEmergency.endTimestamp?.let {
@@ -106,7 +136,7 @@ object ZelloAndroidSdkModuleHelper {
106
136
  recents.forEach {
107
137
  pushMap(WritableNativeMap().apply {
108
138
  putMap("contact", sdkContactToWritableMap(it.contact))
109
- putString("channelUserName", it.channelUser?.name)
139
+ putMap("channelUser", channelUserToWritableMap(it.channelUser))
110
140
  putString("type", it.type.toString())
111
141
  putString("timestamp", it.timestamp.toString())
112
142
  putBoolean("incoming", it.incoming)
@@ -138,7 +168,7 @@ object ZelloAndroidSdkModuleHelper {
138
168
  return Arguments.createMap().apply {
139
169
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
140
170
  putString("type", "voice")
141
- putString("channelUserName", message.channelUser?.name)
171
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
142
172
  putString("timestamp", message.timestamp.toString())
143
173
  putString("historyId", message.historyId)
144
174
  putBoolean("incoming", message.incoming)
@@ -150,7 +180,7 @@ object ZelloAndroidSdkModuleHelper {
150
180
  return Arguments.createMap().apply {
151
181
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
152
182
  putString("type", "image")
153
- putString("channelUserName", message.channelUser?.name)
183
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
154
184
  putString("timestamp", message.timestamp.toString())
155
185
  putString("historyId", message.historyId)
156
186
  putBoolean("incoming", message.incoming)
@@ -161,7 +191,7 @@ object ZelloAndroidSdkModuleHelper {
161
191
  return Arguments.createMap().apply {
162
192
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
163
193
  putString("type", "text")
164
- putString("channelUserName", message.channelUser?.name)
194
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
165
195
  putString("timestamp", message.timestamp.toString())
166
196
  putString("historyId", message.historyId)
167
197
  putBoolean("incoming", message.incoming)
@@ -173,7 +203,7 @@ object ZelloAndroidSdkModuleHelper {
173
203
  return Arguments.createMap().apply {
174
204
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
175
205
  putString("type", "alert")
176
- putString("channelUserName", message.channelUser?.name)
206
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
177
207
  putString("timestamp", message.timestamp.toString())
178
208
  putString("historyId", message.historyId)
179
209
  putBoolean("incoming", message.incoming)
@@ -185,7 +215,7 @@ object ZelloAndroidSdkModuleHelper {
185
215
  return Arguments.createMap().apply {
186
216
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
187
217
  putString("type", "location")
188
- putString("channelUserName", message.channelUser?.name)
218
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
189
219
  putString("timestamp", message.timestamp.toString())
190
220
  putString("historyId", message.historyId)
191
221
  putBoolean("incoming", message.incoming)
@@ -195,4 +225,42 @@ object ZelloAndroidSdkModuleHelper {
195
225
  putString("address", message.address)
196
226
  }
197
227
  }
228
+
229
+ fun consoleSettingsToWritableMap(settings: ZelloConsoleSettings): WritableMap {
230
+ return Arguments.createMap().apply {
231
+ putBoolean("allowNonDispatchersToEndCalls", settings.allowNonDispatchersToEndCalls)
232
+ putBoolean("allowTextMessages", settings.allowTextMessages)
233
+ putBoolean("allowImageMessages", settings.allowImageMessages)
234
+ putBoolean("allowLocationMessages", settings.allowLocationMessages)
235
+ putBoolean("allowAlertMessages", settings.allowAlertMessages)
236
+ putBoolean("allowGroupConversations", settings.allowGroupConversations)
237
+ }
238
+ }
239
+
240
+ fun callToWritableMap(call: ZelloDispatchChannel.Call): WritableMap {
241
+ return Arguments.createMap().apply {
242
+ putInt("id", call.id.toInt())
243
+ putString("status", call.status.toString())
244
+ putString("dispatcher", call.dispatcher)
245
+ putString("timestamp", call.timestamp.toString())
246
+ }
247
+ }
248
+
249
+ fun channelUserToWritableMap(channelUser: ZelloChannel.User?): WritableMap? {
250
+ if (channelUser == null) {
251
+ return null
252
+ }
253
+ return Arguments.createMap().apply {
254
+ putString("name", channelUser.name)
255
+ putString("displayName", channelUser.displayName)
256
+ }
257
+ }
258
+
259
+ fun channelUsersToWritableArray(channelUsers: List<ZelloChannel.User>): WritableNativeArray {
260
+ return WritableNativeArray().apply {
261
+ channelUsers.forEach {
262
+ pushMap(channelUserToWritableMap(it))
263
+ }
264
+ }
265
+ }
198
266
  }
@@ -0,0 +1,14 @@
1
+ import ZelloSDK
2
+
3
+ extension ZelloConsoleSettings {
4
+ var jsonDictionary: [AnyHashable: Any] {
5
+ return [
6
+ "allowNonDispatchersToEndCalls": allowsNonDispatchersToEndCalls,
7
+ "allowImageMessages": allowsImageMessages,
8
+ "allowLocationMessages": allowsLocationMessages,
9
+ "allowTextMessages": allowsTextMessages,
10
+ "allowAlertMessages": allowsAlertMessages,
11
+ "allowGroupConversations": allowsGroupConversations
12
+ ]
13
+ }
14
+ }
@@ -13,7 +13,7 @@ extension ZelloContact {
13
13
 
14
14
  extension ZelloChannel {
15
15
  var jsonDictionary: [AnyHashable: Any] {
16
- return [
16
+ var body: [AnyHashable: Any] = [
17
17
  "name": name,
18
18
  "isChannel": true,
19
19
  "isMuted": isMuted,
@@ -27,8 +27,13 @@ extension ZelloChannel {
27
27
  "allowAlerts": channelOptions.allowAlerts,
28
28
  "allowTextMessages": channelOptions.allowTextMessages,
29
29
  "allowLocations": channelOptions.allowLocations
30
- ]
30
+ ],
31
+ "isDispatchChannel": dispatchInfo != nil
31
32
  ]
33
+ if let currentCall = dispatchInfo?.currentCall {
34
+ body["currentCall"] = currentCall.jsonDictionary
35
+ }
36
+ return body
32
37
  }
33
38
  }
34
39
 
@@ -47,6 +52,55 @@ extension ZelloUser {
47
52
  if let url = profilePictureThumbnailURL?.absoluteString {
48
53
  body["profilePictureThumbnailUrl"] = url
49
54
  }
55
+ body["supportedFeatures"] = [
56
+ "groupConversations": supportedFeatures.groupConversations
57
+ ]
58
+ return body
59
+ }
60
+ }
61
+
62
+ extension ZelloGroupConversation {
63
+ var jsonDictionary: [AnyHashable: Any] {
64
+ let body: [AnyHashable: Any] = [
65
+ "name": name,
66
+ "isChannel": true,
67
+ "isMuted": isMuted,
68
+ "isConnected": status == .connected,
69
+ "isConnecting": status == .connecting,
70
+ "usersOnline": onlineUsers.count,
71
+ "options": [
72
+ "noDisconnect": false,
73
+ "hidePowerButton": false,
74
+ "listenOnly": false,
75
+ "allowAlerts": true,
76
+ "allowTextMessages": true,
77
+ "allowLocations": true
78
+ ],
79
+ "isGroupConversation": true,
80
+ "displayName": displayName,
81
+ "users": users.map { user in user.jsonDictionary },
82
+ "onlineUsers": onlineUsers.map { user in user.jsonDictionary }
83
+ ]
84
+ return body
85
+ }
86
+ }
87
+
88
+ extension ZelloGroupConversationUser {
89
+ var jsonDictionary: [AnyHashable: Any] {
90
+ let body: [AnyHashable: Any] = [
91
+ "name": name,
92
+ "displayName": displayName
93
+ ]
94
+ return body
95
+ }
96
+ }
97
+
98
+ extension ZelloChannel.User {
99
+ var jsonDictionary: [AnyHashable: Any] {
100
+ let body: [AnyHashable: Any] = [
101
+ "name": name,
102
+ "displayName": displayName
103
+ ]
50
104
  return body
51
105
  }
52
106
  }
@@ -0,0 +1,13 @@
1
+ import ZelloSDK
2
+
3
+ extension ZelloDispatchCall {
4
+ var jsonDictionary: [AnyHashable: Any] {
5
+ var body: [AnyHashable: Any] = [
6
+ "status": status.rawValue,
7
+ ]
8
+ if let dispatcher = dispatcher {
9
+ body["dispatcher"] = dispatcher
10
+ }
11
+ return body
12
+ }
13
+ }