@zelloptt/react-native-zello-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +21 -0
- package/android/build.gradle +122 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/zellosdk/DummyPackage.kt +18 -0
- package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModule.kt +437 -0
- package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModuleHelper.kt +198 -0
- package/ios/Extensions/Date+Extension.swift +5 -0
- package/ios/Extensions/UIImage+Extension.swift +9 -0
- package/ios/Extensions/ZelloContact+Extension.swift +52 -0
- package/ios/Extensions/ZelloHistoryAlertMessage+Extension.swift +18 -0
- package/ios/Extensions/ZelloHistoryImageMessage+Extension.swift +17 -0
- package/ios/Extensions/ZelloHistoryLocationMessage+Extension.swift +23 -0
- package/ios/Extensions/ZelloHistoryTextMessage+Extension.swift +18 -0
- package/ios/Extensions/ZelloHistoryVoiceMessage+Extension.swift +18 -0
- package/ios/Extensions/ZelloIOSSdkModule+Extension.swift +285 -0
- package/ios/Extensions/ZelloIncomingEmergency+Extension.swift +16 -0
- package/ios/Extensions/ZelloOutgoingEmergency+Extension.swift +14 -0
- package/ios/Extensions/ZelloRecentEntry+Extension.swift +16 -0
- package/ios/ZelloIOSSdkModule.swift +209 -0
- package/ios/ZelloIOSSdkModuleBridge.h +5 -0
- package/ios/ZelloIOSSdkModuleBridge.m +44 -0
- package/lib/commonjs/events/index.js +43 -0
- package/lib/commonjs/events/index.js.map +1 -0
- package/lib/commonjs/index.js +47 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/sdk/index.js +833 -0
- package/lib/commonjs/sdk/index.js.map +1 -0
- package/lib/commonjs/types/index.js +518 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/algorithms/index.js +79 -0
- package/lib/commonjs/utils/algorithms/index.js.map +1 -0
- package/lib/commonjs/utils/index.js +60 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/events/index.js +39 -0
- package/lib/module/events/index.js.map +1 -0
- package/lib/module/index.js +10 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/sdk/index.js +829 -0
- package/lib/module/sdk/index.js.map +1 -0
- package/lib/module/types/index.js +547 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/algorithms/index.js +72 -0
- package/lib/module/utils/algorithms/index.js.map +1 -0
- package/lib/module/utils/index.js +52 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/events/index.d.ts +192 -0
- package/lib/typescript/commonjs/src/events/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/sdk/index.d.ts +221 -0
- package/lib/typescript/commonjs/src/sdk/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/index.d.ts +560 -0
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/algorithms/index.d.ts +21 -0
- package/lib/typescript/commonjs/src/utils/algorithms/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/index.d.ts +8 -0
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/events/index.d.ts +192 -0
- package/lib/typescript/module/src/events/index.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +6 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/sdk/index.d.ts +221 -0
- package/lib/typescript/module/src/sdk/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types/index.d.ts +560 -0
- package/lib/typescript/module/src/types/index.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/algorithms/index.d.ts +21 -0
- package/lib/typescript/module/src/utils/algorithms/index.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/index.d.ts +8 -0
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -0
- package/package.json +195 -0
- package/react-native-zello-sdk.podspec +43 -0
- package/src/events/index.ts +191 -0
- package/src/index.ts +8 -0
- package/src/sdk/index.ts +1038 -0
- package/src/types/index.ts +818 -0
- package/src/utils/algorithms/index.ts +88 -0
- package/src/utils/index.ts +145 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
package com.zellosdk
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap
|
|
4
|
+
import android.util.Base64
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
6
|
+
import com.facebook.react.bridge.WritableMap
|
|
7
|
+
import com.facebook.react.bridge.WritableNativeArray
|
|
8
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
9
|
+
import com.zello.sdk.ZelloChannel
|
|
10
|
+
import com.zello.sdk.ZelloContact
|
|
11
|
+
import com.zello.sdk.ZelloHistoryAlertMessage
|
|
12
|
+
import com.zello.sdk.ZelloHistoryImageMessage
|
|
13
|
+
import com.zello.sdk.ZelloHistoryLocationMessage
|
|
14
|
+
import com.zello.sdk.ZelloHistoryMessage
|
|
15
|
+
import com.zello.sdk.ZelloHistoryTextMessage
|
|
16
|
+
import com.zello.sdk.ZelloHistoryVoiceMessage
|
|
17
|
+
import com.zello.sdk.ZelloIncomingEmergency
|
|
18
|
+
import com.zello.sdk.ZelloRecentEntry
|
|
19
|
+
import com.zello.sdk.ZelloUser
|
|
20
|
+
import java.io.ByteArrayOutputStream
|
|
21
|
+
|
|
22
|
+
object ZelloAndroidSdkModuleHelper {
|
|
23
|
+
fun contactListToWritableMap(users: List<ZelloUser>, channels: List<ZelloChannel>): WritableMap {
|
|
24
|
+
return Arguments.createMap().apply {
|
|
25
|
+
putArray("users", WritableNativeArray().apply {
|
|
26
|
+
users.forEach { user ->
|
|
27
|
+
pushMap(sdkContactToWritableMap(user))
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
putArray("channels", WritableNativeArray().apply {
|
|
31
|
+
channels.forEach { channel ->
|
|
32
|
+
pushMap(sdkContactToWritableMap(channel))
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fun sdkContactToWritableMap(contact: ZelloContact): WritableMap {
|
|
39
|
+
return when (contact) {
|
|
40
|
+
is ZelloUser -> WritableNativeMap().apply {
|
|
41
|
+
putString("name", contact.name)
|
|
42
|
+
putBoolean("isChannel", false)
|
|
43
|
+
putBoolean("isMuted", contact.isMuted)
|
|
44
|
+
putString("displayName", contact.displayName)
|
|
45
|
+
putString("status", contact.status.toString())
|
|
46
|
+
putString("customStatusText", contact.customStatusText)
|
|
47
|
+
putString("profilePictureUrl", contact.profilePictureUrl)
|
|
48
|
+
putString("profilePictureThumbnailUrl", contact.profilePictureThumbnailUrl)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
is ZelloChannel -> WritableNativeMap().apply {
|
|
52
|
+
putString("name", contact.name)
|
|
53
|
+
putBoolean("isChannel", true)
|
|
54
|
+
putBoolean("isMuted", contact.isMuted)
|
|
55
|
+
putBoolean("isConnected", contact.status == ZelloChannel.ConnectionStatus.CONNECTED)
|
|
56
|
+
putBoolean("isConnecting", contact.status == ZelloChannel.ConnectionStatus.CONNECTING)
|
|
57
|
+
putInt("usersOnline", contact.usersOnline)
|
|
58
|
+
putMap("options", WritableNativeMap().apply {
|
|
59
|
+
val options = contact.options
|
|
60
|
+
putBoolean("noDisconnect", options.noDisconnect)
|
|
61
|
+
putBoolean("hidePowerButton", options.hidePowerButton)
|
|
62
|
+
putBoolean("listenOnly", options.listenOnly)
|
|
63
|
+
putBoolean("allowAlerts", options.allowAlerts)
|
|
64
|
+
putBoolean("allowTextMessages", options.allowTextMessages)
|
|
65
|
+
putBoolean("allowLocations", options.allowLocations)
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
else -> WritableNativeMap()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
fun incomingEmergenciesToWritableArray(incomingEmergencies: List<ZelloIncomingEmergency>): WritableNativeArray {
|
|
74
|
+
return WritableNativeArray().apply {
|
|
75
|
+
incomingEmergencies.forEach {
|
|
76
|
+
pushMap(incomingEmergencyToWritableMap(it))
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
fun incomingEmergencyToWritableMap(incomingEmergency: ZelloIncomingEmergency): WritableMap {
|
|
82
|
+
return Arguments.createMap().apply {
|
|
83
|
+
putMap("channel", sdkContactToWritableMap(contact = incomingEmergency.channel))
|
|
84
|
+
putString("channelUserName", incomingEmergency.channelUser.name)
|
|
85
|
+
putString("emergencyId", incomingEmergency.emergencyId)
|
|
86
|
+
putString("startTimestamp", incomingEmergency.startTimestamp.toString())
|
|
87
|
+
incomingEmergency.endTimestamp?.let {
|
|
88
|
+
putString("endTimestamp", it.toString())
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fun bitmapToBase64String(bitmap: Bitmap?): String? {
|
|
94
|
+
if (bitmap == null) {
|
|
95
|
+
return null
|
|
96
|
+
}
|
|
97
|
+
val byteArrayOutputStream = ByteArrayOutputStream()
|
|
98
|
+
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
|
|
99
|
+
val byteArray = byteArrayOutputStream.toByteArray()
|
|
100
|
+
val base64String: String = Base64.encodeToString(byteArray, Base64.DEFAULT)
|
|
101
|
+
return "data:image/jpeg;base64,$base64String"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fun recentsToWritableArray(recents: List<ZelloRecentEntry>): WritableNativeArray {
|
|
105
|
+
return WritableNativeArray().apply {
|
|
106
|
+
recents.forEach {
|
|
107
|
+
pushMap(WritableNativeMap().apply {
|
|
108
|
+
putMap("contact", sdkContactToWritableMap(it.contact))
|
|
109
|
+
putString("channelUserName", it.channelUser?.name)
|
|
110
|
+
putString("type", it.type.toString())
|
|
111
|
+
putString("timestamp", it.timestamp.toString())
|
|
112
|
+
putBoolean("incoming", it.incoming)
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fun historyMessagesToWritableArray(messages: List<ZelloHistoryMessage>): WritableNativeArray {
|
|
119
|
+
return WritableNativeArray().apply {
|
|
120
|
+
messages.forEach {
|
|
121
|
+
pushMap(historyMessageToWritableMap(it))
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
fun historyMessageToWritableMap(message: ZelloHistoryMessage): WritableMap {
|
|
127
|
+
return when (message) {
|
|
128
|
+
is ZelloHistoryVoiceMessage -> historyVoiceMessageToWritableMap(message)
|
|
129
|
+
is ZelloHistoryImageMessage -> historyImageMessageToWritableMap(message)
|
|
130
|
+
is ZelloHistoryTextMessage -> historyTextMessageToWritableMap(message)
|
|
131
|
+
is ZelloHistoryAlertMessage -> historyAlertMessageToWritableMap(message)
|
|
132
|
+
is ZelloHistoryLocationMessage -> historyLocationMessageToWritableMap(message)
|
|
133
|
+
else -> WritableNativeMap()
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
fun historyVoiceMessageToWritableMap(message: ZelloHistoryVoiceMessage): WritableMap {
|
|
138
|
+
return Arguments.createMap().apply {
|
|
139
|
+
putMap("contact", sdkContactToWritableMap(contact = message.contact))
|
|
140
|
+
putString("type", "voice")
|
|
141
|
+
putString("channelUserName", message.channelUser?.name)
|
|
142
|
+
putString("timestamp", message.timestamp.toString())
|
|
143
|
+
putString("historyId", message.historyId)
|
|
144
|
+
putBoolean("incoming", message.incoming)
|
|
145
|
+
putInt("durationMs", message.durationMs.toInt())
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fun historyImageMessageToWritableMap(message: ZelloHistoryImageMessage): WritableMap {
|
|
150
|
+
return Arguments.createMap().apply {
|
|
151
|
+
putMap("contact", sdkContactToWritableMap(contact = message.contact))
|
|
152
|
+
putString("type", "image")
|
|
153
|
+
putString("channelUserName", message.channelUser?.name)
|
|
154
|
+
putString("timestamp", message.timestamp.toString())
|
|
155
|
+
putString("historyId", message.historyId)
|
|
156
|
+
putBoolean("incoming", message.incoming)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
fun historyTextMessageToWritableMap(message: ZelloHistoryTextMessage): WritableMap {
|
|
161
|
+
return Arguments.createMap().apply {
|
|
162
|
+
putMap("contact", sdkContactToWritableMap(contact = message.contact))
|
|
163
|
+
putString("type", "text")
|
|
164
|
+
putString("channelUserName", message.channelUser?.name)
|
|
165
|
+
putString("timestamp", message.timestamp.toString())
|
|
166
|
+
putString("historyId", message.historyId)
|
|
167
|
+
putBoolean("incoming", message.incoming)
|
|
168
|
+
putString("text", message.text)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
fun historyAlertMessageToWritableMap(message: ZelloHistoryAlertMessage): WritableMap {
|
|
173
|
+
return Arguments.createMap().apply {
|
|
174
|
+
putMap("contact", sdkContactToWritableMap(contact = message.contact))
|
|
175
|
+
putString("type", "alert")
|
|
176
|
+
putString("channelUserName", message.channelUser?.name)
|
|
177
|
+
putString("timestamp", message.timestamp.toString())
|
|
178
|
+
putString("historyId", message.historyId)
|
|
179
|
+
putBoolean("incoming", message.incoming)
|
|
180
|
+
putString("text", message.text)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
fun historyLocationMessageToWritableMap(message: ZelloHistoryLocationMessage): WritableMap {
|
|
185
|
+
return Arguments.createMap().apply {
|
|
186
|
+
putMap("contact", sdkContactToWritableMap(contact = message.contact))
|
|
187
|
+
putString("type", "location")
|
|
188
|
+
putString("channelUserName", message.channelUser?.name)
|
|
189
|
+
putString("timestamp", message.timestamp.toString())
|
|
190
|
+
putString("historyId", message.historyId)
|
|
191
|
+
putBoolean("incoming", message.incoming)
|
|
192
|
+
putDouble("latitude", message.latitude)
|
|
193
|
+
putDouble("longitude", message.longitude)
|
|
194
|
+
putDouble("accuracy", message.accuracy)
|
|
195
|
+
putString("address", message.address)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloContact {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
if let user = self.asZelloUser() {
|
|
6
|
+
return user.jsonDictionary
|
|
7
|
+
} else if let channel = self.asZelloChannel() {
|
|
8
|
+
return channel.jsonDictionary
|
|
9
|
+
}
|
|
10
|
+
return [:]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
extension ZelloChannel {
|
|
15
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
16
|
+
return [
|
|
17
|
+
"name": name,
|
|
18
|
+
"isChannel": true,
|
|
19
|
+
"isMuted": isMuted,
|
|
20
|
+
"isConnected": status == .connected,
|
|
21
|
+
"isConnecting": status == .connecting,
|
|
22
|
+
"usersOnline": usersOnline,
|
|
23
|
+
"options": [
|
|
24
|
+
"noDisconnect": channelOptions.noDisconnect,
|
|
25
|
+
"hidePowerButton": channelOptions.hidePowerButton,
|
|
26
|
+
"listenOnly": channelOptions.listenOnly,
|
|
27
|
+
"allowAlerts": channelOptions.allowAlerts,
|
|
28
|
+
"allowTextMessages": channelOptions.allowTextMessages,
|
|
29
|
+
"allowLocations": channelOptions.allowLocations
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
extension ZelloUser {
|
|
36
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
37
|
+
var body: [AnyHashable: Any] = [
|
|
38
|
+
"name": name,
|
|
39
|
+
"isChannel": false,
|
|
40
|
+
"isMuted": isMuted,
|
|
41
|
+
"displayName": displayName,
|
|
42
|
+
"status": status.rawValue.lowercased()
|
|
43
|
+
]
|
|
44
|
+
if let url = profilePictureURL?.absoluteString {
|
|
45
|
+
body["profilePictureUrl"] = url
|
|
46
|
+
}
|
|
47
|
+
if let url = profilePictureThumbnailURL?.absoluteString {
|
|
48
|
+
body["profilePictureThumbnailUrl"] = url
|
|
49
|
+
}
|
|
50
|
+
return body
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloHistoryAlertMessage {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
var body: [AnyHashable: Any] = [
|
|
6
|
+
"contact": contact.jsonDictionary,
|
|
7
|
+
"type": "alert",
|
|
8
|
+
"historyId": historyId,
|
|
9
|
+
"timestamp": timestamp.bridgeTimestamp,
|
|
10
|
+
"incoming": incoming,
|
|
11
|
+
"text": text
|
|
12
|
+
]
|
|
13
|
+
if let channelUserName = channelUser?.name {
|
|
14
|
+
body["channelUserName"] = channelUserName
|
|
15
|
+
}
|
|
16
|
+
return body
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloHistoryImageMessage {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
var body: [AnyHashable: Any] = [
|
|
6
|
+
"contact": contact.jsonDictionary,
|
|
7
|
+
"type": "image",
|
|
8
|
+
"historyId": historyId,
|
|
9
|
+
"timestamp": timestamp.bridgeTimestamp,
|
|
10
|
+
"incoming": incoming
|
|
11
|
+
]
|
|
12
|
+
if let channelUserName = channelUser?.name {
|
|
13
|
+
body["channelUserName"] = channelUserName
|
|
14
|
+
}
|
|
15
|
+
return body
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloHistoryLocationMessage {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
var body: [AnyHashable: Any] = [
|
|
6
|
+
"contact": contact.jsonDictionary,
|
|
7
|
+
"type": "location",
|
|
8
|
+
"historyId": historyId,
|
|
9
|
+
"timestamp": timestamp.bridgeTimestamp,
|
|
10
|
+
"incoming": incoming,
|
|
11
|
+
"latitude": location.coordinate.latitude,
|
|
12
|
+
"longitude": location.coordinate.longitude,
|
|
13
|
+
"accuracy": location.horizontalAccuracy
|
|
14
|
+
]
|
|
15
|
+
if let address = address {
|
|
16
|
+
body["address"] = address
|
|
17
|
+
}
|
|
18
|
+
if let channelUserName = channelUser?.name {
|
|
19
|
+
body["channelUserName"] = channelUserName
|
|
20
|
+
}
|
|
21
|
+
return body
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloHistoryTextMessage {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
var body: [AnyHashable: Any] = [
|
|
6
|
+
"contact": contact.jsonDictionary,
|
|
7
|
+
"type": "text",
|
|
8
|
+
"historyId": historyId,
|
|
9
|
+
"timestamp": timestamp.bridgeTimestamp,
|
|
10
|
+
"incoming": incoming,
|
|
11
|
+
"text": text
|
|
12
|
+
]
|
|
13
|
+
if let channelUserName = channelUser?.name {
|
|
14
|
+
body["channelUserName"] = channelUserName
|
|
15
|
+
}
|
|
16
|
+
return body
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloHistoryVoiceMessage {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
var body: [AnyHashable: Any] = [
|
|
6
|
+
"contact": contact.jsonDictionary,
|
|
7
|
+
"type": "voice",
|
|
8
|
+
"historyId": historyId,
|
|
9
|
+
"timestamp": timestamp.bridgeTimestamp,
|
|
10
|
+
"incoming": incoming,
|
|
11
|
+
"durationMs": duration * 1000
|
|
12
|
+
]
|
|
13
|
+
if let channelUserName = channelUser?.name {
|
|
14
|
+
body["channelUserName"] = channelUserName
|
|
15
|
+
}
|
|
16
|
+
return body
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloIOSSdkModule: Zello.Delegate {
|
|
4
|
+
func zelloDidStartConnecting(_ zello: Zello) {
|
|
5
|
+
sendSdkEvent(withName: "onConnectStarted", body: nil)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
func zelloDidFinishConnecting(_ zello: Zello) {
|
|
9
|
+
sendSdkEvent(withName: "onConnectSucceeded", body: nil)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
func zelloDidDisconnect(_ zello: Zello) {
|
|
13
|
+
sendSdkEvent(withName: "onDisconnected", body: nil)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func zelloWillReconnect(_ zello: Zello) {
|
|
17
|
+
sendSdkEvent(withName: "onWillReconnect", body: nil)
|
|
18
|
+
}
|
|
19
|
+
|
|
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 }
|
|
23
|
+
var body: [AnyHashable: Any] = [
|
|
24
|
+
"users": users,
|
|
25
|
+
"channels": channels
|
|
26
|
+
]
|
|
27
|
+
if let emergencyChannel = zello.emergencyChannel {
|
|
28
|
+
body["emergencyChannel"] = emergencyChannel.jsonDictionary
|
|
29
|
+
}
|
|
30
|
+
sendSdkEvent(withName: "onContactListUpdated", body: body)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func zello(_ zello: Zello, accountStatusChangedTo newStatus: ZelloAccountStatus?) {
|
|
34
|
+
if let newStatus = newStatus?.rawValue.lowercased() {
|
|
35
|
+
sendSdkEvent(withName: "onAccountStatusChanged", body: ["status": newStatus])
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func zello(_ zello: Zello, didFailToConnect error: Zello.ConnectionError) {
|
|
40
|
+
sendSdkEvent(withName: "onConnectFailed", body: ["error": error.rawValue])
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func zello(_ zello: Zello, didUpdateSelectedContact contact: ZelloContact) {
|
|
44
|
+
sendSdkEvent(withName: "onSelectedContactChanged", body: ["contact": contact.jsonDictionary])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func zello(_ zello: Zello, didStartConnecting outgoingVoiceMessage: ZelloOutgoingVoiceMessage) {
|
|
48
|
+
sendSdkEvent(withName: "onOutgoingVoiceMessageConnecting",
|
|
49
|
+
body: [
|
|
50
|
+
"contact": outgoingVoiceMessage.contact.jsonDictionary,
|
|
51
|
+
"state": outgoingVoiceMessage.state,
|
|
52
|
+
"timestamp": outgoingVoiceMessage.timestamp.bridgeTimestamp
|
|
53
|
+
])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
func zello(_ zello: Zello, didStartSending outgoingVoiceMessage: ZelloOutgoingVoiceMessage) {
|
|
57
|
+
sendSdkEvent(withName: "onOutgoingVoiceMessageStarted",
|
|
58
|
+
body: [
|
|
59
|
+
"contact": outgoingVoiceMessage.contact.jsonDictionary,
|
|
60
|
+
"state": outgoingVoiceMessage.state,
|
|
61
|
+
"timestamp": outgoingVoiceMessage.timestamp.bridgeTimestamp
|
|
62
|
+
])
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func zello(_ zello: Zello, didFinishSending outgoingVoiceMessage: ZelloOutgoingVoiceMessage, error: ZelloOutgoingVoiceMessage.Error?) {
|
|
66
|
+
var body: [AnyHashable: Any] = [
|
|
67
|
+
"contact": outgoingVoiceMessage.contact.jsonDictionary,
|
|
68
|
+
"state": outgoingVoiceMessage.state,
|
|
69
|
+
"timestamp": outgoingVoiceMessage.timestamp.bridgeTimestamp
|
|
70
|
+
]
|
|
71
|
+
if let error {
|
|
72
|
+
body["error"] = error.rawValue
|
|
73
|
+
}
|
|
74
|
+
sendSdkEvent(withName: "onOutgoingVoiceMessageStopped", body: body)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func zello(_ zello: Zello, didStartReceiving incomingVoiceMessage: ZelloIncomingVoiceMessage) {
|
|
78
|
+
var body: [AnyHashable: Any] = [
|
|
79
|
+
"contact": incomingVoiceMessage.contact.jsonDictionary,
|
|
80
|
+
"timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp
|
|
81
|
+
]
|
|
82
|
+
if let channelUser = incomingVoiceMessage.channelUser {
|
|
83
|
+
body["channelUserName"] = channelUser.name
|
|
84
|
+
}
|
|
85
|
+
sendSdkEvent(withName: "onIncomingVoiceMessageStarted", body: body)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
func zello(_ zello: Zello, didFinishReceiving incomingVoiceMessage: ZelloIncomingVoiceMessage) {
|
|
89
|
+
var body: [AnyHashable: Any] = [
|
|
90
|
+
"contact": incomingVoiceMessage.contact.jsonDictionary,
|
|
91
|
+
"timestamp": incomingVoiceMessage.timestamp.bridgeTimestamp
|
|
92
|
+
]
|
|
93
|
+
if let channelUser = incomingVoiceMessage.channelUser {
|
|
94
|
+
body["channelUserName"] = channelUser.name
|
|
95
|
+
}
|
|
96
|
+
sendSdkEvent(withName: "onIncomingVoiceMessageStopped", body: body)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
func zello(_ zello: Zello, didReceive textMessage: ZelloTextMessage) {
|
|
100
|
+
var body: [AnyHashable: Any] = [
|
|
101
|
+
"contact": textMessage.contact.jsonDictionary,
|
|
102
|
+
"text": textMessage.text,
|
|
103
|
+
"timestamp": textMessage.timestamp.bridgeTimestamp
|
|
104
|
+
]
|
|
105
|
+
if let channelUser = textMessage.channelUser {
|
|
106
|
+
body["channelUserName"] = channelUser.name
|
|
107
|
+
}
|
|
108
|
+
sendSdkEvent(withName: "onIncomingTextMessage", body: body)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
func zello(_ zello: Zello, didSend textMessage: ZelloTextMessage) {
|
|
112
|
+
let body: [AnyHashable: Any] = [
|
|
113
|
+
"contact": textMessage.contact.jsonDictionary,
|
|
114
|
+
"text": textMessage.text,
|
|
115
|
+
"timestamp": textMessage.timestamp.bridgeTimestamp
|
|
116
|
+
]
|
|
117
|
+
sendSdkEvent(withName: "onOutgoingTextMessageSent", body: body)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
func zello(_ zello: Zello, didFailToSend textMessage: ZelloTextMessage) {
|
|
121
|
+
let body: [AnyHashable: Any] = [
|
|
122
|
+
"contact": textMessage.contact.jsonDictionary,
|
|
123
|
+
"text": textMessage.text,
|
|
124
|
+
"timestamp": textMessage.timestamp.bridgeTimestamp
|
|
125
|
+
]
|
|
126
|
+
sendSdkEvent(withName: "onOutgoingTextMessageSendFailed", body: body)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
func zello(_ zello: Zello, didReceive imageMessage: ZelloImageMessage) {
|
|
130
|
+
var body: [AnyHashable: Any] = [
|
|
131
|
+
"contact": imageMessage.contact.jsonDictionary,
|
|
132
|
+
"timestamp": imageMessage.timestamp.bridgeTimestamp
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
if let channelUser = imageMessage.channelUser {
|
|
136
|
+
body["channelUserName"] = channelUser.name
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
body["image"] = imageMessage.image.base64String
|
|
140
|
+
body["thumbnail"] = imageMessage.thumbnail.base64String
|
|
141
|
+
|
|
142
|
+
sendSdkEvent(withName: "onIncomingImageMessage", body: body)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
func zello(_ zello: Zello, didSend imageMessage: ZelloImageMessage) {
|
|
146
|
+
var body: [AnyHashable: Any] = [
|
|
147
|
+
"contact": imageMessage.contact.jsonDictionary,
|
|
148
|
+
"timestamp": imageMessage.timestamp.bridgeTimestamp
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
body["image"] = imageMessage.image.base64String
|
|
152
|
+
body["thumbnail"] = imageMessage.thumbnail.base64String
|
|
153
|
+
|
|
154
|
+
sendSdkEvent(withName: "onOutgoingImageMessageSent", body: body)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
func zello(_ zello: Zello, didFailToSend imageMessage: ZelloImageMessage) {
|
|
158
|
+
let body: [AnyHashable: Any] = [
|
|
159
|
+
"contact": imageMessage.contact.jsonDictionary,
|
|
160
|
+
"timestamp": imageMessage.timestamp.bridgeTimestamp
|
|
161
|
+
]
|
|
162
|
+
sendSdkEvent(withName: "onOutgoingImageMessageSendFailed", body: body)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
func zello(_ zello: Zello, didReceive locationMessage: ZelloLocationMessage) {
|
|
166
|
+
var body: [AnyHashable: Any] = [
|
|
167
|
+
"contact": locationMessage.contact.jsonDictionary,
|
|
168
|
+
"timestamp": locationMessage.timestamp.bridgeTimestamp,
|
|
169
|
+
"latitude": locationMessage.location.coordinate.latitude,
|
|
170
|
+
"longitude": locationMessage.location.coordinate.longitude,
|
|
171
|
+
"accuracy": locationMessage.location.horizontalAccuracy,
|
|
172
|
+
]
|
|
173
|
+
if let channelUser = locationMessage.channelUser {
|
|
174
|
+
body["channelUserName"] = channelUser.name
|
|
175
|
+
}
|
|
176
|
+
if let address = locationMessage.address {
|
|
177
|
+
body["address"] = address
|
|
178
|
+
}
|
|
179
|
+
sendSdkEvent(withName: "onIncomingLocationMessage", body: body)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
func zello(_ zello: Zello, didReceive alertMessage: ZelloAlertMessage) {
|
|
183
|
+
var body: [AnyHashable: Any] = [
|
|
184
|
+
"contact": alertMessage.contact.jsonDictionary,
|
|
185
|
+
"text": alertMessage.text,
|
|
186
|
+
"timestamp": alertMessage.timestamp.bridgeTimestamp
|
|
187
|
+
]
|
|
188
|
+
if let channelUser = alertMessage.channelUser {
|
|
189
|
+
body["channelUserName"] = channelUser.name
|
|
190
|
+
}
|
|
191
|
+
sendSdkEvent(withName: "onIncomingAlertMessage", body: body)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
func zello(_ zello: Zello, didSend locationMessage: ZelloLocationMessage) {
|
|
195
|
+
var body: [AnyHashable: Any] = [
|
|
196
|
+
"contact": locationMessage.contact.jsonDictionary,
|
|
197
|
+
"timestamp": locationMessage.timestamp.bridgeTimestamp,
|
|
198
|
+
"latitude": locationMessage.location.coordinate.latitude,
|
|
199
|
+
"longitude": locationMessage.location.coordinate.longitude,
|
|
200
|
+
"accuracy": locationMessage.location.horizontalAccuracy,
|
|
201
|
+
]
|
|
202
|
+
if let address = locationMessage.address {
|
|
203
|
+
body["address"] = address
|
|
204
|
+
}
|
|
205
|
+
sendSdkEvent(withName: "onOutgoingLocationMessageSent", body: body)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
func zello(_ zello: Zello, didFailToSend locationMessage: ZelloLocationMessage) {
|
|
209
|
+
let body: [AnyHashable: Any] = [
|
|
210
|
+
"contact": locationMessage.contact.jsonDictionary,
|
|
211
|
+
"timestamp": locationMessage.timestamp.bridgeTimestamp,
|
|
212
|
+
"latitude": locationMessage.location.coordinate.latitude,
|
|
213
|
+
"longitude": locationMessage.location.coordinate.longitude,
|
|
214
|
+
"accuracy": locationMessage.location.horizontalAccuracy,
|
|
215
|
+
]
|
|
216
|
+
sendSdkEvent(withName: "onOutgoingLocationMessageSendFailed", body: body)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
func zello(_ zello: Zello, didSend alertMessage: ZelloAlertMessage) {
|
|
220
|
+
let body: [AnyHashable: Any] = [
|
|
221
|
+
"contact": alertMessage.contact.jsonDictionary,
|
|
222
|
+
"text": alertMessage.text,
|
|
223
|
+
"timestamp": alertMessage.timestamp.bridgeTimestamp
|
|
224
|
+
]
|
|
225
|
+
sendSdkEvent(withName: "onOutgoingAlertMessageSent", body: body)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
func zello(_ zello: Zello, didFailToSend alertMessage: ZelloAlertMessage) {
|
|
229
|
+
let body: [AnyHashable: Any] = [
|
|
230
|
+
"contact": alertMessage.contact.jsonDictionary,
|
|
231
|
+
"text": alertMessage.text,
|
|
232
|
+
"timestamp": alertMessage.timestamp.bridgeTimestamp
|
|
233
|
+
]
|
|
234
|
+
sendSdkEvent(withName: "onOutgoingAlertMessageSendFailed", body: body)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
func zello(_ zello: Zello, didStart outgoingEmergency: ZelloOutgoingEmergency) {
|
|
238
|
+
sendSdkEvent(withName: "onOutgoingEmergencyStarted", body: outgoingEmergency.jsonDictionary)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
func zello(_ zello: Zello, didStop outgoingEmergency: ZelloOutgoingEmergency) {
|
|
242
|
+
sendSdkEvent(withName: "onOutgoingEmergencyStopped", body: outgoingEmergency.jsonDictionary)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
func zello(_ zello: Zello, didStart incomingEmergency: ZelloIncomingEmergency) {
|
|
246
|
+
let body: [AnyHashable: Any] = [
|
|
247
|
+
"emergency": incomingEmergency.jsonDictionary,
|
|
248
|
+
"emergencies": zello.incomingEmergencies.map { emergency in
|
|
249
|
+
emergency.jsonDictionary
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
sendSdkEvent(withName: "onIncomingEmergencyStarted", body: body)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
func zello(_ zello: Zello, didStop incomingEmergency: ZelloIncomingEmergency) {
|
|
256
|
+
let body: [AnyHashable: Any] = [
|
|
257
|
+
"emergency": incomingEmergency.jsonDictionary,
|
|
258
|
+
"emergencies": zello.incomingEmergencies.map { emergency in
|
|
259
|
+
emergency.jsonDictionary
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
sendSdkEvent(withName: "onIncomingEmergencyStopped", body: body)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
func zello(_ zello: Zello, didUpdate recentEntries: [ZelloRecentEntry]) {
|
|
266
|
+
let body: [AnyHashable: Any] = [
|
|
267
|
+
"recents": recentEntries.map { recent in
|
|
268
|
+
recent.jsonDictionary
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
sendSdkEvent(withName: "onRecentsUpdated", body: body)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
func zelloDidUpdateHistory(_ zello: Zello) {
|
|
275
|
+
sendSdkEvent(withName: "onHistoryUpdated", body: nil)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
func zello(_ zello: Zello, didStartHistoryPlayback message: ZelloHistoryVoiceMessage) {
|
|
279
|
+
sendSdkEvent(withName: "onHistoryPlaybackStarted", body: message.jsonDictionary)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
func zello(_ zello: Zello, didStopHistoryPlayback message: ZelloHistoryVoiceMessage) {
|
|
283
|
+
sendSdkEvent(withName: "onHistoryPlaybackStopped", body: message.jsonDictionary)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloIncomingEmergency {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
var body: [AnyHashable: Any] = [
|
|
6
|
+
"channel": channel.jsonDictionary,
|
|
7
|
+
"channelUserName": channelUser.name,
|
|
8
|
+
"emergencyId": id,
|
|
9
|
+
"startTimestamp": startTimestamp.bridgeTimestamp
|
|
10
|
+
]
|
|
11
|
+
if let endTimestamp {
|
|
12
|
+
body["endTimestamp"] = endTimestamp.bridgeTimestamp
|
|
13
|
+
}
|
|
14
|
+
return body
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ZelloSDK
|
|
2
|
+
|
|
3
|
+
extension ZelloOutgoingEmergency {
|
|
4
|
+
var jsonDictionary: [AnyHashable: Any] {
|
|
5
|
+
var body: [AnyHashable: Any] = [
|
|
6
|
+
"channel": channel.jsonDictionary,
|
|
7
|
+
"startTimestamp": startTimestamp.bridgeTimestamp
|
|
8
|
+
]
|
|
9
|
+
if let endTimestamp {
|
|
10
|
+
body["endTimestamp"] = endTimestamp.bridgeTimestamp
|
|
11
|
+
}
|
|
12
|
+
return body
|
|
13
|
+
}
|
|
14
|
+
}
|