@zelloptt/react-native-zello-sdk 0.4.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +9 -4
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModule.kt +103 -29
  4. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModuleHelper.kt +53 -8
  5. package/ios/Extensions/ZelloConsoleSettings+Extension.swift +6 -1
  6. package/ios/Extensions/ZelloContact+Extension.swift +51 -0
  7. package/ios/Extensions/ZelloIOSSdkModule+Extension.swift +49 -9
  8. package/ios/ZelloIOSSdkModule.swift +88 -27
  9. package/ios/ZelloIOSSdkModuleBridge.m +22 -11
  10. package/lib/commonjs/docs/assets/navigation.js +1 -1
  11. package/lib/commonjs/docs/assets/navigation.js.map +1 -1
  12. package/lib/commonjs/docs/assets/search.js +1 -1
  13. package/lib/commonjs/docs/assets/search.js.map +1 -1
  14. package/lib/commonjs/docs/classes/sdk.Zello.html +69 -45
  15. package/lib/commonjs/docs/classes/types.ZelloAlertMessage.html +7 -7
  16. package/lib/commonjs/docs/classes/types.ZelloChannel.html +8 -8
  17. package/lib/commonjs/docs/classes/types.ZelloChannelUser.html +5 -4
  18. package/lib/commonjs/docs/classes/types.ZelloDispatchCall.html +4 -4
  19. package/lib/commonjs/docs/classes/types.ZelloDispatchChannel.html +9 -9
  20. package/lib/commonjs/docs/classes/types.ZelloGroupConversation.html +24 -0
  21. package/lib/commonjs/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
  22. package/lib/commonjs/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
  23. package/lib/commonjs/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
  24. package/lib/commonjs/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
  25. package/lib/commonjs/docs/classes/types.ZelloHistoryVoiceMessage.html +8 -8
  26. package/lib/commonjs/docs/classes/types.ZelloImageMessage.html +8 -8
  27. package/lib/commonjs/docs/classes/types.ZelloIncomingEmergency.html +7 -7
  28. package/lib/commonjs/docs/classes/types.ZelloIncomingVoiceMessage.html +6 -6
  29. package/lib/commonjs/docs/classes/types.ZelloLocationMessage.html +10 -10
  30. package/lib/commonjs/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
  31. package/lib/commonjs/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
  32. package/lib/commonjs/docs/classes/types.ZelloRecentEntry.html +7 -7
  33. package/lib/commonjs/docs/classes/types.ZelloTextMessage.html +7 -7
  34. package/lib/commonjs/docs/classes/types.ZelloUser.html +10 -8
  35. package/lib/commonjs/docs/classes/types.ZelloUserSupportedFeatures.html +5 -0
  36. package/lib/commonjs/docs/enums/events.ZelloEvent.html +107 -82
  37. package/lib/commonjs/docs/enums/types.ZelloAccountStatus.html +4 -4
  38. package/lib/commonjs/docs/enums/types.ZelloChannelAlertLevel.html +4 -4
  39. package/lib/commonjs/docs/enums/types.ZelloChannelConnectionStatus.html +2 -2
  40. package/lib/commonjs/docs/enums/types.ZelloConnectionError.html +2 -2
  41. package/lib/commonjs/docs/enums/types.ZelloConnectionState.html +2 -2
  42. package/lib/commonjs/docs/enums/types.ZelloContactType.html +4 -2
  43. package/lib/commonjs/docs/enums/types.ZelloDispatchCallStatus.html +2 -2
  44. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageError.html +2 -2
  45. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageState.html +2 -2
  46. package/lib/commonjs/docs/enums/types.ZelloRecentEntryType.html +2 -2
  47. package/lib/commonjs/docs/enums/types.ZelloUserStatus.html +6 -6
  48. package/lib/commonjs/docs/index.html +7 -4
  49. package/lib/commonjs/docs/modules/events.html +1 -1
  50. package/lib/commonjs/docs/modules/index.html +4 -2
  51. package/lib/commonjs/docs/modules/sdk.html +1 -1
  52. package/lib/commonjs/docs/modules/types.html +4 -2
  53. package/lib/commonjs/docs/types/types.ZelloChannelOptions.html +4 -4
  54. package/lib/commonjs/docs/types/types.ZelloConfig.html +1 -1
  55. package/lib/commonjs/docs/types/types.ZelloConsoleSettings.html +8 -0
  56. package/lib/commonjs/docs/types/types.ZelloContact.html +1 -1
  57. package/lib/commonjs/docs/types/types.ZelloCredentials.html +1 -1
  58. package/lib/commonjs/docs/types/types.ZelloHistoryMessage.html +1 -1
  59. package/lib/commonjs/docs/types/types.ZelloMessage.html +1 -1
  60. package/lib/commonjs/events/index.js +6 -0
  61. package/lib/commonjs/events/index.js.map +1 -1
  62. package/lib/commonjs/sdk/index.js +195 -47
  63. package/lib/commonjs/sdk/index.js.map +1 -1
  64. package/lib/commonjs/types/index.js +56 -12
  65. package/lib/commonjs/types/index.js.map +1 -1
  66. package/lib/commonjs/utils/index.js +41 -10
  67. package/lib/commonjs/utils/index.js.map +1 -1
  68. package/lib/module/docs/assets/navigation.js +1 -1
  69. package/lib/module/docs/assets/navigation.js.map +1 -1
  70. package/lib/module/docs/assets/search.js +1 -1
  71. package/lib/module/docs/assets/search.js.map +1 -1
  72. package/lib/module/docs/classes/sdk.Zello.html +69 -45
  73. package/lib/module/docs/classes/types.ZelloAlertMessage.html +7 -7
  74. package/lib/module/docs/classes/types.ZelloChannel.html +8 -8
  75. package/lib/module/docs/classes/types.ZelloChannelUser.html +5 -4
  76. package/lib/module/docs/classes/types.ZelloDispatchCall.html +4 -4
  77. package/lib/module/docs/classes/types.ZelloDispatchChannel.html +9 -9
  78. package/lib/module/docs/classes/types.ZelloGroupConversation.html +24 -0
  79. package/lib/module/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
  80. package/lib/module/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
  81. package/lib/module/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
  82. package/lib/module/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
  83. package/lib/module/docs/classes/types.ZelloHistoryVoiceMessage.html +8 -8
  84. package/lib/module/docs/classes/types.ZelloImageMessage.html +8 -8
  85. package/lib/module/docs/classes/types.ZelloIncomingEmergency.html +7 -7
  86. package/lib/module/docs/classes/types.ZelloIncomingVoiceMessage.html +6 -6
  87. package/lib/module/docs/classes/types.ZelloLocationMessage.html +10 -10
  88. package/lib/module/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
  89. package/lib/module/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
  90. package/lib/module/docs/classes/types.ZelloRecentEntry.html +7 -7
  91. package/lib/module/docs/classes/types.ZelloTextMessage.html +7 -7
  92. package/lib/module/docs/classes/types.ZelloUser.html +10 -8
  93. package/lib/module/docs/classes/types.ZelloUserSupportedFeatures.html +5 -0
  94. package/lib/module/docs/enums/events.ZelloEvent.html +107 -82
  95. package/lib/module/docs/enums/types.ZelloAccountStatus.html +4 -4
  96. package/lib/module/docs/enums/types.ZelloChannelAlertLevel.html +4 -4
  97. package/lib/module/docs/enums/types.ZelloChannelConnectionStatus.html +2 -2
  98. package/lib/module/docs/enums/types.ZelloConnectionError.html +2 -2
  99. package/lib/module/docs/enums/types.ZelloConnectionState.html +2 -2
  100. package/lib/module/docs/enums/types.ZelloContactType.html +4 -2
  101. package/lib/module/docs/enums/types.ZelloDispatchCallStatus.html +2 -2
  102. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageError.html +2 -2
  103. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageState.html +2 -2
  104. package/lib/module/docs/enums/types.ZelloRecentEntryType.html +2 -2
  105. package/lib/module/docs/enums/types.ZelloUserStatus.html +6 -6
  106. package/lib/module/docs/index.html +7 -4
  107. package/lib/module/docs/modules/events.html +1 -1
  108. package/lib/module/docs/modules/index.html +4 -2
  109. package/lib/module/docs/modules/sdk.html +1 -1
  110. package/lib/module/docs/modules/types.html +4 -2
  111. package/lib/module/docs/types/types.ZelloChannelOptions.html +4 -4
  112. package/lib/module/docs/types/types.ZelloConfig.html +1 -1
  113. package/lib/module/docs/types/types.ZelloConsoleSettings.html +8 -0
  114. package/lib/module/docs/types/types.ZelloContact.html +1 -1
  115. package/lib/module/docs/types/types.ZelloCredentials.html +1 -1
  116. package/lib/module/docs/types/types.ZelloHistoryMessage.html +1 -1
  117. package/lib/module/docs/types/types.ZelloMessage.html +1 -1
  118. package/lib/module/events/index.js +6 -0
  119. package/lib/module/events/index.js.map +1 -1
  120. package/lib/module/sdk/index.js +197 -49
  121. package/lib/module/sdk/index.js.map +1 -1
  122. package/lib/module/types/index.js +57 -11
  123. package/lib/module/types/index.js.map +1 -1
  124. package/lib/module/utils/index.js +41 -11
  125. package/lib/module/utils/index.js.map +1 -1
  126. package/lib/typescript/commonjs/src/events/index.d.ts +38 -1
  127. package/lib/typescript/commonjs/src/events/index.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/src/sdk/index.d.ts +38 -4
  129. package/lib/typescript/commonjs/src/sdk/index.d.ts.map +1 -1
  130. package/lib/typescript/commonjs/src/types/index.d.ts +66 -10
  131. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/src/utils/index.d.ts +2 -1
  133. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  134. package/lib/typescript/module/src/events/index.d.ts +38 -1
  135. package/lib/typescript/module/src/events/index.d.ts.map +1 -1
  136. package/lib/typescript/module/src/sdk/index.d.ts +38 -4
  137. package/lib/typescript/module/src/sdk/index.d.ts.map +1 -1
  138. package/lib/typescript/module/src/types/index.d.ts +66 -10
  139. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  140. package/lib/typescript/module/src/utils/index.d.ts +2 -1
  141. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  142. package/package.json +2 -1
  143. package/react-native-zello-sdk.podspec +1 -1
  144. package/src/events/index.ts +37 -0
  145. package/src/sdk/index.ts +237 -50
  146. package/src/types/index.ts +90 -12
  147. package/src/utils/index.ts +65 -20
  148. package/lib/commonjs/docs/classes/types.ZelloConsoleSettings.html +0 -5
  149. package/lib/module/docs/classes/types.ZelloConsoleSettings.html +0 -5
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,7 +25,9 @@ npm install @zelloptt/react-native-zello-sdk
23
25
 
24
26
  ### iOS
25
27
 
26
- Before getting started, 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.
27
31
 
28
32
  #### Troubleshooting
29
33
 
@@ -40,11 +44,11 @@ If you receive the above error, you should move the `Build Phases` phase named `
40
44
 
41
45
  ### Android
42
46
 
43
- 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).
44
48
 
45
49
  #### Dependencies
46
50
 
47
- 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`:
48
52
 
49
53
  ```
50
54
  repositories {
@@ -113,6 +117,7 @@ class MainApplication : Application(), ReactApplication {
113
117
 
114
118
  override fun onCreate() {
115
119
  super.onCreate()
120
+ // Don't forget to start the SDK!
116
121
  zello.start()
117
122
  }
118
123
  }
@@ -102,7 +102,7 @@ repositories {
102
102
 
103
103
  def kotlin_version = getExtOrDefault("kotlinVersion")
104
104
 
105
- def zelloSdkVersion = "0.4.0"
105
+ def zelloSdkVersion = "1.0.0"
106
106
 
107
107
  dependencies {
108
108
  // For < 0.71, this will be from the local maven repo
@@ -14,6 +14,7 @@ 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
@@ -28,6 +29,7 @@ import com.zello.sdk.ZelloOutgoingEmergency
28
29
  import com.zello.sdk.ZelloOutgoingVoiceMessage
29
30
  import com.zello.sdk.ZelloRecentEntry
30
31
  import com.zello.sdk.ZelloConsoleSettings
32
+ import com.zello.sdk.ZelloGroupConversation
31
33
  import com.zello.sdk.ZelloState
32
34
  import com.zello.sdk.ZelloTextMessage
33
35
  import javax.inject.Inject
@@ -59,8 +61,8 @@ class ZelloAndroidSdkModule @Inject constructor(
59
61
  zello.disconnect()
60
62
  }
61
63
 
62
- @ReactMethod fun setSelectedContact(name: String, isChannel: Boolean) {
63
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
64
+ @ReactMethod fun setSelectedContact(name: String, type: String) {
65
+ val contact = contactFrom(name, type) ?: return
64
66
  zello.setSelectedContact(contact)
65
67
  }
66
68
 
@@ -83,8 +85,8 @@ class ZelloAndroidSdkModule @Inject constructor(
83
85
  zello.disconnectChannel(channel)
84
86
  }
85
87
 
86
- @ReactMethod fun startVoiceMessage(name: String, isChannel: Boolean) {
87
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
88
+ @ReactMethod fun startVoiceMessage(name: String, type: String) {
89
+ val contact = contactFrom(name, type) ?: return
88
90
  zello.startVoiceMessage(contact)
89
91
  }
90
92
 
@@ -93,8 +95,8 @@ class ZelloAndroidSdkModule @Inject constructor(
93
95
  }
94
96
 
95
97
  @ReactMethod
96
- fun sendImage(name: String, isChannel: Boolean, data: ReadableArray) {
97
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
98
+ fun sendImage(name: String, type: String, data: ReadableArray) {
99
+ val contact = contactFrom(name, type) ?: return
98
100
  val byteArray = ByteArray(data.size())
99
101
  for (i in 0 until data.size()) {
100
102
  byteArray[i] = data.getInt(i).toByte()
@@ -103,20 +105,20 @@ class ZelloAndroidSdkModule @Inject constructor(
103
105
  }
104
106
 
105
107
  @ReactMethod
106
- fun sendLocation(name: String, isChannel: Boolean) {
107
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
108
+ fun sendLocation(name: String, type: String) {
109
+ val contact = contactFrom(name, type) ?: return
108
110
  zello.sendLocation(contact)
109
111
  }
110
112
 
111
113
  @ReactMethod
112
- fun sendText(name: String, isChannel: Boolean, text: String) {
113
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
114
+ fun sendText(name: String, type: String, text: String) {
115
+ val contact = contactFrom(name, type) ?: return
114
116
  zello.sendText(text, contact)
115
117
  }
116
118
 
117
119
  @ReactMethod
118
- fun sendAlert(name: String, isChannel: Boolean, text: String, level: String?) {
119
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
120
+ fun sendAlert(name: String, type: String, text: String, level: String?) {
121
+ val contact = contactFrom(name, type) ?: return
120
122
  val channelAlertLevel = when (level) {
121
123
  "all" -> ZelloAlertMessage.ChannelLevel.ALL
122
124
  "connected" -> ZelloAlertMessage.ChannelLevel.CONNECTED
@@ -131,14 +133,14 @@ class ZelloAndroidSdkModule @Inject constructor(
131
133
  }
132
134
 
133
135
  @ReactMethod
134
- fun muteContact(name: String, isChannel: Boolean) {
135
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
136
+ fun muteContact(name: String, type: String) {
137
+ val contact = contactFrom(name, type) ?: return
136
138
  zello.muteContact(contact)
137
139
  }
138
140
 
139
141
  @ReactMethod
140
- fun unmuteContact(name: String, isChannel: Boolean) {
141
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
142
+ fun unmuteContact(name: String, type: String) {
143
+ val contact = contactFrom(name, type) ?: return
142
144
  zello.unmuteContact(contact)
143
145
  }
144
146
 
@@ -153,15 +155,15 @@ class ZelloAndroidSdkModule @Inject constructor(
153
155
  }
154
156
 
155
157
  @ReactMethod
156
- fun getHistory(name: String, isChannel: Boolean, size: Int?, callback: Callback) {
157
- val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
158
+ fun getHistory(name: String, type: String, size: Int?, callback: Callback) {
159
+ val contact = contactFrom(name, type) ?: return
158
160
  val messages = if (size != null) zello.getHistory(contact, size) else zello.getHistory(contact)
159
161
  callback.invoke(ZelloAndroidSdkModuleHelper.historyMessagesToWritableArray(messages))
160
162
  }
161
163
 
162
164
  @ReactMethod
163
- fun playHistoryMessage(historyId: String, contactName: String, isChannel: Boolean) {
164
- val contact = (if (isChannel) zello.getChannel(contactName) else zello.getUser(contactName)) ?: return
165
+ fun playHistoryMessage(historyId: String, contactName: String, type: String) {
166
+ val contact = contactFrom(name, type) ?: return
165
167
  val message = zello.getHistoryMessage(historyId, contact) as? ZelloHistoryVoiceMessage ?: return
166
168
  zello.playHistoryMessage(message)
167
169
  }
@@ -172,8 +174,8 @@ class ZelloAndroidSdkModule @Inject constructor(
172
174
  }
173
175
 
174
176
  @ReactMethod
175
- fun getImageDataForHistoryImageMessage(historyId: String, contactName: String, isChannel: Boolean, callback: Callback) {
176
- val contact = (if (isChannel) zello.getChannel(contactName) else zello.getUser(contactName)) ?: return
177
+ fun getImageDataForHistoryImageMessage(historyId: String, contactName: String, type: String, callback: Callback) {
178
+ val contact = contactFrom(name, type) ?: return
177
179
  val message = zello.getHistoryMessage(historyId, contact) as? ZelloHistoryImageMessage ?: return
178
180
  zello.loadBitmapForHistoryImageMessage(message) {
179
181
  callback.invoke(ZelloAndroidSdkModuleHelper.bitmapToBase64String(it))
@@ -187,6 +189,31 @@ class ZelloAndroidSdkModule @Inject constructor(
187
189
  zello.endDispatchCall(call, dispatchChannel)
188
190
  }
189
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
+
190
217
  override fun onStateChanged(sdk: Zello, state: ZelloState) {
191
218
  }
192
219
 
@@ -205,7 +232,7 @@ class ZelloAndroidSdkModule @Inject constructor(
205
232
  }
206
233
 
207
234
  override fun onContactListUpdated(zello: Zello) {
208
- val map = ZelloAndroidSdkModuleHelper.contactListToWritableMap(this.zello.users, this.zello.channels)
235
+ val map = ZelloAndroidSdkModuleHelper.contactListToWritableMap(this.zello.users, this.zello.channels, this.zello.groupConversations)
209
236
  this.zello.emergencyChannel?.let {
210
237
  map.putMap("emergencyChannel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(it))
211
238
  }
@@ -239,7 +266,7 @@ class ZelloAndroidSdkModule @Inject constructor(
239
266
  override fun onIncomingAlertMessage(zello: Zello, message: ZelloAlertMessage) {
240
267
  sendEvent(reactApplicationContext, "onIncomingAlertMessage", Arguments.createMap().apply {
241
268
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
242
- putString("channelUserName", message.channelUser?.name)
269
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
243
270
  putString("timestamp", message.timestamp.toString())
244
271
  putString("text", message.text)
245
272
  })
@@ -264,7 +291,7 @@ class ZelloAndroidSdkModule @Inject constructor(
264
291
  override fun onIncomingImageMessage(message: ZelloImageMessage) {
265
292
  sendEvent(reactApplicationContext, "onIncomingImageMessage", Arguments.createMap().apply {
266
293
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
267
- putString("channelUserName", message.channelUser?.name)
294
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
268
295
  putString("timestamp", message.timestamp.toString())
269
296
  putString("thumbnail", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.thumbnail))
270
297
  putString("image", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.image))
@@ -274,7 +301,7 @@ class ZelloAndroidSdkModule @Inject constructor(
274
301
  override fun onIncomingLocationMessage(zello: Zello, message: ZelloLocationMessage) {
275
302
  sendEvent(reactApplicationContext, "onIncomingLocationMessage", Arguments.createMap().apply {
276
303
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
277
- putString("channelUserName", message.channelUser?.name)
304
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
278
305
  putString("timestamp", message.timestamp.toString())
279
306
  putString("address", message.address)
280
307
  putDouble("latitude", message.latitude)
@@ -324,7 +351,7 @@ class ZelloAndroidSdkModule @Inject constructor(
324
351
  override fun onIncomingTextMessage(message: ZelloTextMessage) {
325
352
  sendEvent(reactApplicationContext, "onIncomingTextMessage", Arguments.createMap().apply {
326
353
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
327
- putString("channelUserName", message.channelUser?.name)
354
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
328
355
  putString("timestamp", message.timestamp.toString())
329
356
  putString("text", message.text)
330
357
  })
@@ -333,7 +360,7 @@ class ZelloAndroidSdkModule @Inject constructor(
333
360
  override fun onIncomingVoiceMessageStarted(zello: Zello, message: ZelloIncomingVoiceMessage) {
334
361
  sendEvent(reactApplicationContext, "onIncomingVoiceMessageStarted", Arguments.createMap().apply {
335
362
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
336
- putString("channelUserName", message.channelUser?.name)
363
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
337
364
  putString("timestamp", message.timestamp.toString())
338
365
  })
339
366
  }
@@ -341,7 +368,7 @@ class ZelloAndroidSdkModule @Inject constructor(
341
368
  override fun onIncomingVoiceMessageStopped(zello: Zello, message: ZelloIncomingVoiceMessage) {
342
369
  sendEvent(reactApplicationContext, "onIncomingVoiceMessageStopped", Arguments.createMap().apply {
343
370
  putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
344
- putString("channelUserName", message.channelUser?.name)
371
+ putMap("channelUser", ZelloAndroidSdkModuleHelper.channelUserToWritableMap(message.channelUser))
345
372
  putString("timestamp", message.timestamp.toString())
346
373
  })
347
374
  }
@@ -474,6 +501,53 @@ class ZelloAndroidSdkModule @Inject constructor(
474
501
  })
475
502
  }
476
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
+
542
+ private fun contactFrom(name: String, type: String): ZelloContact? {
543
+ return when (type) {
544
+ "channel", "dispatchChannel" -> zello.getChannel(name)
545
+ "groupConversation" -> zello.getGroupConversation(name)
546
+ "user" -> zello.getUser(name)
547
+ else -> null
548
+ }
549
+ }
550
+
477
551
  private fun sendEvent(reactContext: ReactContext, name: String, params: WritableMap?) {
478
552
  reactContext
479
553
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
@@ -10,6 +10,7 @@ import com.zello.sdk.ZelloChannel
10
10
  import com.zello.sdk.ZelloConsoleSettings
11
11
  import com.zello.sdk.ZelloContact
12
12
  import com.zello.sdk.ZelloDispatchChannel
13
+ import com.zello.sdk.ZelloGroupConversation
13
14
  import com.zello.sdk.ZelloHistoryAlertMessage
14
15
  import com.zello.sdk.ZelloHistoryImageMessage
15
16
  import com.zello.sdk.ZelloHistoryLocationMessage
@@ -22,7 +23,7 @@ import com.zello.sdk.ZelloUser
22
23
  import java.io.ByteArrayOutputStream
23
24
 
24
25
  object ZelloAndroidSdkModuleHelper {
25
- fun contactListToWritableMap(users: List<ZelloUser>, channels: List<ZelloChannel>): WritableMap {
26
+ fun contactListToWritableMap(users: List<ZelloUser>, channels: List<ZelloChannel>, groupConversation: List<ZelloGroupConversation>): WritableMap {
26
27
  return Arguments.createMap().apply {
27
28
  putArray("users", WritableNativeArray().apply {
28
29
  users.forEach { user ->
@@ -34,6 +35,11 @@ object ZelloAndroidSdkModuleHelper {
34
35
  pushMap(sdkContactToWritableMap(channel))
35
36
  }
36
37
  })
38
+ putArray("groupConversations", WritableNativeArray().apply {
39
+ groupConversation.forEach { conversation ->
40
+ pushMap(sdkContactToWritableMap(conversation))
41
+ }
42
+ })
37
43
  }
38
44
  }
39
45
 
@@ -48,6 +54,9 @@ object ZelloAndroidSdkModuleHelper {
48
54
  putString("customStatusText", contact.customStatusText)
49
55
  putString("profilePictureUrl", contact.profilePictureUrl)
50
56
  putString("profilePictureThumbnailUrl", contact.profilePictureThumbnailUrl)
57
+ putMap("supportedFeatures", WritableNativeMap().apply {
58
+ putBoolean("groupConversations", contact.supportedFeatures.groupConversations)
59
+ })
51
60
  }
52
61
 
53
62
  is ZelloChannel -> WritableNativeMap().apply {
@@ -71,6 +80,19 @@ object ZelloAndroidSdkModuleHelper {
71
80
  contact.currentCall?.let { call ->
72
81
  putMap("currentCall", callToWritableMap(call))
73
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
+ })
74
96
  }
75
97
  }
76
98
 
@@ -89,7 +111,7 @@ object ZelloAndroidSdkModuleHelper {
89
111
  fun incomingEmergencyToWritableMap(incomingEmergency: ZelloIncomingEmergency): WritableMap {
90
112
  return Arguments.createMap().apply {
91
113
  putMap("channel", sdkContactToWritableMap(contact = incomingEmergency.channel))
92
- putString("channelUserName", incomingEmergency.channelUser.name)
114
+ putMap("channelUser", channelUserToWritableMap(incomingEmergency.channelUser))
93
115
  putString("emergencyId", incomingEmergency.emergencyId)
94
116
  putString("startTimestamp", incomingEmergency.startTimestamp.toString())
95
117
  incomingEmergency.endTimestamp?.let {
@@ -114,7 +136,7 @@ object ZelloAndroidSdkModuleHelper {
114
136
  recents.forEach {
115
137
  pushMap(WritableNativeMap().apply {
116
138
  putMap("contact", sdkContactToWritableMap(it.contact))
117
- putString("channelUserName", it.channelUser?.name)
139
+ putMap("channelUser", channelUserToWritableMap(it.channelUser))
118
140
  putString("type", it.type.toString())
119
141
  putString("timestamp", it.timestamp.toString())
120
142
  putBoolean("incoming", it.incoming)
@@ -146,7 +168,7 @@ object ZelloAndroidSdkModuleHelper {
146
168
  return Arguments.createMap().apply {
147
169
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
148
170
  putString("type", "voice")
149
- putString("channelUserName", message.channelUser?.name)
171
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
150
172
  putString("timestamp", message.timestamp.toString())
151
173
  putString("historyId", message.historyId)
152
174
  putBoolean("incoming", message.incoming)
@@ -158,7 +180,7 @@ object ZelloAndroidSdkModuleHelper {
158
180
  return Arguments.createMap().apply {
159
181
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
160
182
  putString("type", "image")
161
- putString("channelUserName", message.channelUser?.name)
183
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
162
184
  putString("timestamp", message.timestamp.toString())
163
185
  putString("historyId", message.historyId)
164
186
  putBoolean("incoming", message.incoming)
@@ -169,7 +191,7 @@ object ZelloAndroidSdkModuleHelper {
169
191
  return Arguments.createMap().apply {
170
192
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
171
193
  putString("type", "text")
172
- putString("channelUserName", message.channelUser?.name)
194
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
173
195
  putString("timestamp", message.timestamp.toString())
174
196
  putString("historyId", message.historyId)
175
197
  putBoolean("incoming", message.incoming)
@@ -181,7 +203,7 @@ object ZelloAndroidSdkModuleHelper {
181
203
  return Arguments.createMap().apply {
182
204
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
183
205
  putString("type", "alert")
184
- putString("channelUserName", message.channelUser?.name)
206
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
185
207
  putString("timestamp", message.timestamp.toString())
186
208
  putString("historyId", message.historyId)
187
209
  putBoolean("incoming", message.incoming)
@@ -193,7 +215,7 @@ object ZelloAndroidSdkModuleHelper {
193
215
  return Arguments.createMap().apply {
194
216
  putMap("contact", sdkContactToWritableMap(contact = message.contact))
195
217
  putString("type", "location")
196
- putString("channelUserName", message.channelUser?.name)
218
+ putMap("channelUser", channelUserToWritableMap(message.channelUser))
197
219
  putString("timestamp", message.timestamp.toString())
198
220
  putString("historyId", message.historyId)
199
221
  putBoolean("incoming", message.incoming)
@@ -207,6 +229,11 @@ object ZelloAndroidSdkModuleHelper {
207
229
  fun consoleSettingsToWritableMap(settings: ZelloConsoleSettings): WritableMap {
208
230
  return Arguments.createMap().apply {
209
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)
210
237
  }
211
238
  }
212
239
 
@@ -218,4 +245,22 @@ object ZelloAndroidSdkModuleHelper {
218
245
  putString("timestamp", call.timestamp.toString())
219
246
  }
220
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
+ }
221
266
  }
@@ -3,7 +3,12 @@ import ZelloSDK
3
3
  extension ZelloConsoleSettings {
4
4
  var jsonDictionary: [AnyHashable: Any] {
5
5
  return [
6
- "allowNonDispatchersToEndCalls": allowsNonDispatchersToEndCalls
6
+ "allowNonDispatchersToEndCalls": allowsNonDispatchersToEndCalls,
7
+ "allowImageMessages": allowsImageMessages,
8
+ "allowLocationMessages": allowsLocationMessages,
9
+ "allowTextMessages": allowsTextMessages,
10
+ "allowAlertMessages": allowsAlertMessages,
11
+ "allowGroupConversations": allowsGroupConversations
7
12
  ]
8
13
  }
9
14
  }
@@ -6,6 +6,8 @@ extension ZelloContact {
6
6
  return user.jsonDictionary
7
7
  } else if let channel = self.asZelloChannel() {
8
8
  return channel.jsonDictionary
9
+ } else if let groupConversation = self.asZelloGroupConversation() {
10
+ return groupConversation.jsonDictionary
9
11
  }
10
12
  return [:]
11
13
  }
@@ -52,6 +54,55 @@ extension ZelloUser {
52
54
  if let url = profilePictureThumbnailURL?.absoluteString {
53
55
  body["profilePictureThumbnailUrl"] = url
54
56
  }
57
+ body["supportedFeatures"] = [
58
+ "groupConversations": supportedFeatures.groupConversations
59
+ ]
60
+ return body
61
+ }
62
+ }
63
+
64
+ extension ZelloGroupConversation {
65
+ var jsonDictionary: [AnyHashable: Any] {
66
+ let body: [AnyHashable: Any] = [
67
+ "name": name,
68
+ "isChannel": true,
69
+ "isMuted": isMuted,
70
+ "isConnected": status == .connected,
71
+ "isConnecting": status == .connecting,
72
+ "usersOnline": onlineUsers.count,
73
+ "options": [
74
+ "noDisconnect": false,
75
+ "hidePowerButton": false,
76
+ "listenOnly": false,
77
+ "allowAlerts": true,
78
+ "allowTextMessages": true,
79
+ "allowLocations": true
80
+ ],
81
+ "isGroupConversation": true,
82
+ "displayName": displayName,
83
+ "users": users.map { user in user.jsonDictionary },
84
+ "onlineUsers": onlineUsers.map { user in user.jsonDictionary }
85
+ ]
86
+ return body
87
+ }
88
+ }
89
+
90
+ extension ZelloGroupConversationUser {
91
+ var jsonDictionary: [AnyHashable: Any] {
92
+ let body: [AnyHashable: Any] = [
93
+ "name": name,
94
+ "displayName": displayName
95
+ ]
96
+ return body
97
+ }
98
+ }
99
+
100
+ extension ZelloChannel.User {
101
+ var jsonDictionary: [AnyHashable: Any] {
102
+ let body: [AnyHashable: Any] = [
103
+ "name": name,
104
+ "displayName": displayName
105
+ ]
55
106
  return body
56
107
  }
57
108
  }
@@ -18,11 +18,19 @@ extension ZelloIOSSdkModule: Zello.Delegate {
18
18
  }
19
19
 
20
20
  func zelloDidUpdateContactList(_ zello: Zello) {
21
- let users = zello.users.map { ZelloContact.user($0).jsonDictionary }
22
- let channels = zello.channels.map { ZelloContact.channel($0).jsonDictionary }
21
+ let users = zello.users.map { user in
22
+ user.jsonDictionary
23
+ }
24
+ let channels = zello.channels.map { channel in
25
+ channel.jsonDictionary
26
+ }
27
+ let groupConversations = zello.groupConversations.map { conversation in
28
+ conversation.jsonDictionary
29
+ }
23
30
  var body: [AnyHashable: Any] = [
24
31
  "users": users,
25
- "channels": channels
32
+ "channels": channels,
33
+ "groupConversations": groupConversations
26
34
  ]
27
35
  if let emergencyChannel = zello.emergencyChannel {
28
36
  body["emergencyChannel"] = emergencyChannel.jsonDictionary
@@ -80,7 +88,7 @@ extension ZelloIOSSdkModule: Zello.Delegate {
80
88
  "timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp
81
89
  ]
82
90
  if let channelUser = incomingVoiceMessage.channelUser {
83
- body["channelUserName"] = channelUser.name
91
+ body["channelUser"] = channelUser.jsonDictionary
84
92
  }
85
93
  sendSdkEvent(withName: "onIncomingVoiceMessageStarted", body: body)
86
94
  }
@@ -91,7 +99,7 @@ extension ZelloIOSSdkModule: Zello.Delegate {
91
99
  "timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp
92
100
  ]
93
101
  if let channelUser = incomingVoiceMessage.channelUser {
94
- body["channelUserName"] = channelUser.name
102
+ body["channelUser"] = channelUser.jsonDictionary
95
103
  }
96
104
  sendSdkEvent(withName: "onIncomingVoiceMessageStopped", body: body)
97
105
  }
@@ -103,7 +111,7 @@ extension ZelloIOSSdkModule: Zello.Delegate {
103
111
  "timestamp": textMessage.timestamp.bridgeTimestamp
104
112
  ]
105
113
  if let channelUser = textMessage.channelUser {
106
- body["channelUserName"] = channelUser.name
114
+ body["channelUser"] = channelUser.jsonDictionary
107
115
  }
108
116
  sendSdkEvent(withName: "onIncomingTextMessage", body: body)
109
117
  }
@@ -133,7 +141,7 @@ extension ZelloIOSSdkModule: Zello.Delegate {
133
141
  ]
134
142
 
135
143
  if let channelUser = imageMessage.channelUser {
136
- body["channelUserName"] = channelUser.name
144
+ body["channelUser"] = channelUser.jsonDictionary
137
145
  }
138
146
 
139
147
  body["image"] = imageMessage.image.base64String
@@ -171,7 +179,7 @@ extension ZelloIOSSdkModule: Zello.Delegate {
171
179
  "accuracy": locationMessage.location.horizontalAccuracy,
172
180
  ]
173
181
  if let channelUser = locationMessage.channelUser {
174
- body["channelUserName"] = channelUser.name
182
+ body["channelUser"] = channelUser.jsonDictionary
175
183
  }
176
184
  if let address = locationMessage.address {
177
185
  body["address"] = address
@@ -186,7 +194,7 @@ extension ZelloIOSSdkModule: Zello.Delegate {
186
194
  "timestamp": alertMessage.timestamp.bridgeTimestamp
187
195
  ]
188
196
  if let channelUser = alertMessage.channelUser {
189
- body["channelUserName"] = channelUser.name
197
+ body["channelUser"] = channelUser.jsonDictionary
190
198
  }
191
199
  sendSdkEvent(withName: "onIncomingAlertMessage", body: body)
192
200
  }
@@ -318,4 +326,36 @@ extension ZelloIOSSdkModule: Zello.Delegate {
318
326
  func zello(_ zello: Zello, didUpdate consoleSettings: ZelloConsoleSettings) {
319
327
  sendSdkEvent(withName: "onConsoleSettingsChanged", body: consoleSettings.jsonDictionary)
320
328
  }
329
+
330
+ func zello(_ zello: Zello, didJoin conversation: ZelloGroupConversation) {
331
+ sendSdkEvent(withName: "onGroupConversationInvite", body: ["conversation": conversation.jsonDictionary])
332
+ }
333
+
334
+ func zello(_ zello: Zello, didLeave conversation: ZelloGroupConversation) {
335
+ sendSdkEvent(withName: "onGroupConversationLeft", body: ["conversation": conversation.jsonDictionary])
336
+ }
337
+
338
+ func zello(_ zello: Zello, didCreate conversation: ZelloGroupConversation) {
339
+ sendSdkEvent(withName: "onGroupConversationCreated", body: ["conversation": conversation.jsonDictionary])
340
+ }
341
+
342
+ func zello(_ zello: Zello, didRename conversation: ZelloGroupConversation) {
343
+ sendSdkEvent(withName: "onGroupConversationRenamed", body: ["conversation": conversation.jsonDictionary])
344
+ }
345
+
346
+ func zello(_ zello: Zello, didAdd users: [ZelloGroupConversationUser], to conversation: ZelloGroupConversation) {
347
+ let body: [AnyHashable: Any] = [
348
+ "conversation": conversation.jsonDictionary,
349
+ "users": users.map { user in user.jsonDictionary }
350
+ ]
351
+ sendSdkEvent(withName: "onGroupConversationUsersAdded", body: body)
352
+ }
353
+
354
+ func zello(_ zello: Zello, didRemove users: [ZelloGroupConversationUser], from conversation: ZelloGroupConversation) {
355
+ let body: [AnyHashable: Any] = [
356
+ "conversation": conversation.jsonDictionary,
357
+ "users": users.map { user in user.jsonDictionary }
358
+ ]
359
+ sendSdkEvent(withName: "onGroupConversationUsersLeft", body: body)
360
+ }
321
361
  }