@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
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Zello, Inc.
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# react-native-zello-sdk
|
|
2
|
+
|
|
3
|
+
Zello SDK for React Native
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-native-zello-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Contributing
|
|
12
|
+
|
|
13
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
MIT
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ZelloSdk_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
maven {
|
|
9
|
+
url = uri("https://zello-sdk.s3.amazonaws.com/android/latest")
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath "com.android.tools.build:gradle:8.5.1"
|
|
15
|
+
// noinspection DifferentKotlinGradleVersion
|
|
16
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
17
|
+
classpath("com.google.dagger:hilt-android-gradle-plugin:2.51")
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def reactNativeArchitectures() {
|
|
22
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
23
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def isNewArchitectureEnabled() {
|
|
27
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
apply plugin: "com.android.library"
|
|
31
|
+
apply plugin: "kotlin-android"
|
|
32
|
+
apply plugin: 'com.google.dagger.hilt.android'
|
|
33
|
+
apply plugin: 'kotlin-kapt'
|
|
34
|
+
|
|
35
|
+
hilt {
|
|
36
|
+
enableAggregatingTask = true
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (isNewArchitectureEnabled()) {
|
|
40
|
+
apply plugin: "com.facebook.react"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def getExtOrDefault(name) {
|
|
44
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ZelloSdk_" + name]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
def getExtOrIntegerDefault(name) {
|
|
48
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ZelloSdk_" + name]).toInteger()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
def supportsNamespace() {
|
|
52
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
53
|
+
def major = parsed[0].toInteger()
|
|
54
|
+
def minor = parsed[1].toInteger()
|
|
55
|
+
|
|
56
|
+
// Namespace support was added in 7.3.0
|
|
57
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
android {
|
|
61
|
+
if (supportsNamespace()) {
|
|
62
|
+
namespace "com.zellosdk"
|
|
63
|
+
|
|
64
|
+
sourceSets {
|
|
65
|
+
main {
|
|
66
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
72
|
+
|
|
73
|
+
defaultConfig {
|
|
74
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
75
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
buildTypes {
|
|
80
|
+
release {
|
|
81
|
+
minifyEnabled false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
lintOptions {
|
|
86
|
+
disable "GradleCompatible"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
compileOptions {
|
|
90
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
91
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
repositories {
|
|
96
|
+
mavenCentral()
|
|
97
|
+
google()
|
|
98
|
+
maven {
|
|
99
|
+
url = uri("https://zello-sdk.s3.amazonaws.com/android/latest")
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
104
|
+
|
|
105
|
+
dependencies {
|
|
106
|
+
// For < 0.71, this will be from the local maven repo
|
|
107
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
108
|
+
//noinspection GradleDynamicVersion
|
|
109
|
+
implementation "com.facebook.react:react-native:+"
|
|
110
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
111
|
+
|
|
112
|
+
// Required Dependencies to use the Zello SDK
|
|
113
|
+
implementation("com.zello:sdk:0.3.1")
|
|
114
|
+
implementation("com.zello:zello:0.3.1")
|
|
115
|
+
implementation("com.zello:core:0.3.1") {
|
|
116
|
+
exclude module: "unspecified"
|
|
117
|
+
}
|
|
118
|
+
implementation(platform("com.google.firebase:firebase-bom:33.1.2"))
|
|
119
|
+
implementation("com.google.firebase:firebase-messaging")
|
|
120
|
+
implementation("com.google.dagger:hilt-android:2.51")
|
|
121
|
+
kapt("com.google.dagger:hilt-android-compiler:2.51")
|
|
122
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.zellosdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
// A useless package that does nothing - it's here to satisfy auto linking.
|
|
9
|
+
class DummyPackage : ReactPackage {
|
|
10
|
+
|
|
11
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
12
|
+
return listOf()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
16
|
+
return emptyList()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
@file:Suppress("unused")
|
|
2
|
+
|
|
3
|
+
package com.zellosdk
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
6
|
+
import com.facebook.react.bridge.Callback
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.ReactContext
|
|
9
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
|
+
import com.facebook.react.bridge.ReactMethod
|
|
11
|
+
import com.facebook.react.bridge.ReadableArray
|
|
12
|
+
import com.facebook.react.bridge.WritableMap
|
|
13
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
14
|
+
import com.zello.sdk.Zello
|
|
15
|
+
import com.zello.sdk.ZelloAccountStatus
|
|
16
|
+
import com.zello.sdk.ZelloAlertMessage
|
|
17
|
+
import com.zello.sdk.ZelloConnectionError
|
|
18
|
+
import com.zello.sdk.ZelloContact
|
|
19
|
+
import com.zello.sdk.ZelloCredentials
|
|
20
|
+
import com.zello.sdk.ZelloHistoryImageMessage
|
|
21
|
+
import com.zello.sdk.ZelloHistoryVoiceMessage
|
|
22
|
+
import com.zello.sdk.ZelloImageMessage
|
|
23
|
+
import com.zello.sdk.ZelloIncomingEmergency
|
|
24
|
+
import com.zello.sdk.ZelloIncomingVoiceMessage
|
|
25
|
+
import com.zello.sdk.ZelloLocationMessage
|
|
26
|
+
import com.zello.sdk.ZelloOutgoingEmergency
|
|
27
|
+
import com.zello.sdk.ZelloOutgoingVoiceMessage
|
|
28
|
+
import com.zello.sdk.ZelloRecentEntry
|
|
29
|
+
import com.zello.sdk.ZelloTextMessage
|
|
30
|
+
import javax.inject.Inject
|
|
31
|
+
|
|
32
|
+
class ZelloAndroidSdkModule @Inject constructor(
|
|
33
|
+
reactContext: ReactApplicationContext,
|
|
34
|
+
private val zello: Zello
|
|
35
|
+
) : ReactContextBaseJavaModule(reactContext), Zello.Listener {
|
|
36
|
+
companion object {
|
|
37
|
+
private const val BRIDGE_EVENT_NAME = "zellosdk"
|
|
38
|
+
private const val EVENT_NAME = "eventName"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
init {
|
|
42
|
+
zello.listener = this
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun getName() = "ZelloAndroidSdkModule"
|
|
46
|
+
|
|
47
|
+
@ReactMethod fun configure(enableOfflineMessagePushNotifications: Boolean, enableForegroundService: Boolean) {
|
|
48
|
+
zello.configure(enableOfflineMessagePushNotifications, enableForegroundService)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@ReactMethod fun connect(network: String, username: String, password: String) {
|
|
52
|
+
zello.connect(ZelloCredentials(network, username, password))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod fun disconnect() {
|
|
56
|
+
zello.disconnect()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod fun setSelectedContact(name: String, isChannel: Boolean) {
|
|
60
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
61
|
+
zello.setSelectedContact(contact)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@ReactMethod fun setAccountStatus(status: String) {
|
|
65
|
+
val accountStatus = when (status) {
|
|
66
|
+
"available" -> ZelloAccountStatus.AVAILABLE
|
|
67
|
+
"busy" -> ZelloAccountStatus.BUSY
|
|
68
|
+
else -> return
|
|
69
|
+
}
|
|
70
|
+
zello.setAccountStatus(accountStatus)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@ReactMethod fun connectChannel(name: String) {
|
|
74
|
+
val channel = zello.getChannel(name) ?: return
|
|
75
|
+
zello.connectChannel(channel)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@ReactMethod fun disconnectChannel(name: String) {
|
|
79
|
+
val channel = zello.getChannel(name) ?: return
|
|
80
|
+
zello.disconnectChannel(channel)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@ReactMethod fun startVoiceMessage(name: String, isChannel: Boolean) {
|
|
84
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
85
|
+
zello.startVoiceMessage(contact)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@ReactMethod fun stopVoiceMessage() {
|
|
89
|
+
zello.stopVoiceMessage()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@ReactMethod
|
|
93
|
+
fun sendImage(name: String, isChannel: Boolean, data: ReadableArray) {
|
|
94
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
95
|
+
val byteArray = ByteArray(data.size())
|
|
96
|
+
for (i in 0 until data.size()) {
|
|
97
|
+
byteArray[i] = data.getInt(i).toByte()
|
|
98
|
+
}
|
|
99
|
+
zello.sendImage(byteArray, contact)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@ReactMethod
|
|
103
|
+
fun sendLocation(name: String, isChannel: Boolean) {
|
|
104
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
105
|
+
zello.sendLocation(contact)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@ReactMethod
|
|
109
|
+
fun sendText(name: String, isChannel: Boolean, text: String) {
|
|
110
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
111
|
+
zello.sendText(text, contact)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@ReactMethod
|
|
115
|
+
fun sendAlert(name: String, isChannel: Boolean, text: String, level: String?) {
|
|
116
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
117
|
+
val channelAlertLevel = when (level) {
|
|
118
|
+
"all" -> ZelloAlertMessage.ChannelLevel.ALL
|
|
119
|
+
"connected" -> ZelloAlertMessage.ChannelLevel.CONNECTED
|
|
120
|
+
else -> null
|
|
121
|
+
}
|
|
122
|
+
zello.sendAlert(contact, text, channelAlertLevel)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@ReactMethod
|
|
126
|
+
fun submitProblemReport() {
|
|
127
|
+
zello.submitProblemReport()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@ReactMethod
|
|
131
|
+
fun muteContact(name: String, isChannel: Boolean) {
|
|
132
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
133
|
+
zello.muteContact(contact)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@ReactMethod
|
|
137
|
+
fun unmuteContact(name: String, isChannel: Boolean) {
|
|
138
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
139
|
+
zello.unmuteContact(contact)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@ReactMethod
|
|
143
|
+
fun startEmergency() {
|
|
144
|
+
zello.startEmergency()
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@ReactMethod
|
|
148
|
+
fun stopEmergency() {
|
|
149
|
+
zello.stopEmergency()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@ReactMethod
|
|
153
|
+
fun getHistory(name: String, isChannel: Boolean, size: Int?, callback: Callback) {
|
|
154
|
+
val contact = (if (isChannel) zello.getChannel(name) else zello.getUser(name)) ?: return
|
|
155
|
+
val messages = if (size != null) zello.getHistory(contact, size) else zello.getHistory(contact)
|
|
156
|
+
callback.invoke(ZelloAndroidSdkModuleHelper.historyMessagesToWritableArray(messages))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@ReactMethod
|
|
160
|
+
fun playHistoryMessage(historyId: String, contactName: String, isChannel: Boolean) {
|
|
161
|
+
val contact = (if (isChannel) zello.getChannel(contactName) else zello.getUser(contactName)) ?: return
|
|
162
|
+
val message = zello.getHistoryMessage(historyId, contact) as? ZelloHistoryVoiceMessage ?: return
|
|
163
|
+
zello.playHistoryMessage(message)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@ReactMethod
|
|
167
|
+
fun stopHistoryMessagePlayback() {
|
|
168
|
+
zello.stopHistoryMessagePlayback()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@ReactMethod
|
|
172
|
+
fun getImageDataForHistoryImageMessage(historyId: String, contactName: String, isChannel: Boolean, callback: Callback) {
|
|
173
|
+
val contact = (if (isChannel) zello.getChannel(contactName) else zello.getUser(contactName)) ?: return
|
|
174
|
+
val message = zello.getHistoryMessage(historyId, contact) as? ZelloHistoryImageMessage ?: return
|
|
175
|
+
zello.loadBitmapForHistoryImageMessage(message) {
|
|
176
|
+
callback.invoke(ZelloAndroidSdkModuleHelper.bitmapToBase64String(it))
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
override fun onConnectFailed(zello: Zello, error: ZelloConnectionError) {
|
|
181
|
+
sendEvent(reactApplicationContext, "onConnectFailed", Arguments.createMap().apply {
|
|
182
|
+
putString("error", error.toString())
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
override fun onConnectStarted(zello: Zello) {
|
|
187
|
+
sendEvent(reactApplicationContext, "onConnectStarted", null)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
override fun onConnectSucceeded(zello: Zello) {
|
|
191
|
+
sendEvent(reactApplicationContext, "onConnectSucceeded", null)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
override fun onContactListUpdated(zello: Zello) {
|
|
195
|
+
val map = ZelloAndroidSdkModuleHelper.contactListToWritableMap(this.zello.users, this.zello.channels)
|
|
196
|
+
this.zello.emergencyChannel?.let {
|
|
197
|
+
map.putMap("emergencyChannel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(it))
|
|
198
|
+
}
|
|
199
|
+
sendEvent(reactApplicationContext, "onContactListUpdated", map)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
override fun onSelectedContactChanged(zello: Zello, contact: ZelloContact?) {
|
|
203
|
+
sendEvent(reactApplicationContext, "onSelectedContactChanged", contact?.let {
|
|
204
|
+
Arguments.createMap().apply {
|
|
205
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(it))
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
override fun onWillReconnect(zello: Zello) {
|
|
211
|
+
sendEvent(reactApplicationContext, "onWillReconnect", null)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
override fun onDisconnected(zello: Zello) {
|
|
215
|
+
sendEvent(reactApplicationContext, "onDisconnected", null)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
override fun onAccountStatusChanged(zello: Zello, status: ZelloAccountStatus?) {
|
|
219
|
+
sendEvent(reactApplicationContext, "onAccountStatusChanged", status?.let {
|
|
220
|
+
Arguments.createMap().apply {
|
|
221
|
+
putString("status", it.toString())
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
override fun onIncomingAlertMessage(zello: Zello, message: ZelloAlertMessage) {
|
|
227
|
+
sendEvent(reactApplicationContext, "onIncomingAlertMessage", Arguments.createMap().apply {
|
|
228
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
229
|
+
putString("channelUserName", message.channelUser?.name)
|
|
230
|
+
putString("timestamp", message.timestamp.toString())
|
|
231
|
+
putString("text", message.text)
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
override fun onOutgoingAlertMessageSent(zello: Zello, message: ZelloAlertMessage) {
|
|
236
|
+
sendEvent(reactApplicationContext, "onOutgoingAlertMessageSent", Arguments.createMap().apply {
|
|
237
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
238
|
+
putString("timestamp", message.timestamp.toString())
|
|
239
|
+
putString("text", message.text)
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
override fun onOutgoingAlertMessageSendFailed(zello: Zello, message: ZelloAlertMessage) {
|
|
244
|
+
sendEvent(reactApplicationContext, "onOutgoingAlertMessageSendFailed", Arguments.createMap().apply {
|
|
245
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
246
|
+
putString("timestamp", message.timestamp.toString())
|
|
247
|
+
putString("text", message.text)
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
override fun onIncomingImageMessage(message: ZelloImageMessage) {
|
|
252
|
+
sendEvent(reactApplicationContext, "onIncomingImageMessage", Arguments.createMap().apply {
|
|
253
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
254
|
+
putString("channelUserName", message.channelUser?.name)
|
|
255
|
+
putString("timestamp", message.timestamp.toString())
|
|
256
|
+
putString("thumbnail", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.thumbnail))
|
|
257
|
+
putString("image", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.image))
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
override fun onIncomingLocationMessage(zello: Zello, message: ZelloLocationMessage) {
|
|
262
|
+
sendEvent(reactApplicationContext, "onIncomingLocationMessage", Arguments.createMap().apply {
|
|
263
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
264
|
+
putString("channelUserName", message.channelUser?.name)
|
|
265
|
+
putString("timestamp", message.timestamp.toString())
|
|
266
|
+
putString("address", message.address)
|
|
267
|
+
putDouble("latitude", message.latitude)
|
|
268
|
+
putDouble("longitude", message.longitude)
|
|
269
|
+
putDouble("accuracy", message.accuracy)
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
override fun onOutgoingLocationMessageSent(zello: Zello, message: ZelloLocationMessage) {
|
|
274
|
+
sendEvent(reactApplicationContext, "onOutgoingLocationMessageSent", Arguments.createMap().apply {
|
|
275
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
276
|
+
putString("timestamp", message.timestamp.toString())
|
|
277
|
+
putString("address", message.address)
|
|
278
|
+
putDouble("latitude", message.latitude)
|
|
279
|
+
putDouble("longitude", message.longitude)
|
|
280
|
+
putDouble("accuracy", message.accuracy)
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
override fun onOutgoingLocationMessageSendFailed(zello: Zello, message: ZelloLocationMessage, isPermissionIssue: Boolean) {
|
|
285
|
+
sendEvent(reactApplicationContext, "onOutgoingLocationMessageSendFailed", Arguments.createMap().apply {
|
|
286
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
287
|
+
putString("timestamp", message.timestamp.toString())
|
|
288
|
+
putString("address", message.address)
|
|
289
|
+
putDouble("latitude", message.latitude)
|
|
290
|
+
putDouble("longitude", message.longitude)
|
|
291
|
+
putDouble("accuracy", message.accuracy)
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
override fun onOutgoingTextMessageSent(zello: Zello, message: ZelloTextMessage) {
|
|
296
|
+
sendEvent(reactApplicationContext, "onOutgoingTextMessageSent", Arguments.createMap().apply {
|
|
297
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
298
|
+
putString("timestamp", message.timestamp.toString())
|
|
299
|
+
putString("text", message.text)
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
override fun onOutgoingTextMessageSendFailed(zello: Zello, message: ZelloTextMessage) {
|
|
304
|
+
sendEvent(reactApplicationContext, "onOutgoingTextMessageSendFailed", Arguments.createMap().apply {
|
|
305
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
306
|
+
putString("timestamp", message.timestamp.toString())
|
|
307
|
+
putString("text", message.text)
|
|
308
|
+
})
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
override fun onIncomingTextMessage(message: ZelloTextMessage) {
|
|
312
|
+
sendEvent(reactApplicationContext, "onIncomingTextMessage", Arguments.createMap().apply {
|
|
313
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
314
|
+
putString("channelUserName", message.channelUser?.name)
|
|
315
|
+
putString("timestamp", message.timestamp.toString())
|
|
316
|
+
putString("text", message.text)
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
override fun onIncomingVoiceMessageStarted(zello: Zello, message: ZelloIncomingVoiceMessage) {
|
|
321
|
+
sendEvent(reactApplicationContext, "onIncomingVoiceMessageStarted", Arguments.createMap().apply {
|
|
322
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
323
|
+
putString("channelUserName", message.channelUser?.name)
|
|
324
|
+
putString("timestamp", message.timestamp.toString())
|
|
325
|
+
})
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
override fun onIncomingVoiceMessageStopped(zello: Zello, message: ZelloIncomingVoiceMessage) {
|
|
329
|
+
sendEvent(reactApplicationContext, "onIncomingVoiceMessageStopped", Arguments.createMap().apply {
|
|
330
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
331
|
+
putString("channelUserName", message.channelUser?.name)
|
|
332
|
+
putString("timestamp", message.timestamp.toString())
|
|
333
|
+
})
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
override fun onOutgoingImageMessageSent(zello: Zello, message: ZelloImageMessage) {
|
|
337
|
+
sendEvent(reactApplicationContext, "onOutgoingImageMessageSent", Arguments.createMap().apply {
|
|
338
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
339
|
+
putString("timestamp", message.timestamp.toString())
|
|
340
|
+
putString("thumbnail", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.thumbnail))
|
|
341
|
+
putString("image", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.image))
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
override fun onOutgoingImageMessageSendFailed(zello: Zello, message: ZelloImageMessage) {
|
|
346
|
+
sendEvent(reactApplicationContext, "onOutgoingImageMessageSendFailed", Arguments.createMap().apply {
|
|
347
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
348
|
+
putString("timestamp", message.timestamp.toString())
|
|
349
|
+
putString("thumbnail", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.thumbnail))
|
|
350
|
+
putString("image", ZelloAndroidSdkModuleHelper.bitmapToBase64String(message.image))
|
|
351
|
+
})
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
override fun onOutgoingVoiceMessageConnecting(zello: Zello, message: ZelloOutgoingVoiceMessage) {
|
|
355
|
+
sendEvent(reactApplicationContext, "onOutgoingVoiceMessageConnecting", Arguments.createMap().apply {
|
|
356
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
357
|
+
putString("timestamp", message.timestamp.toString())
|
|
358
|
+
putString("state", message.state.toString())
|
|
359
|
+
})
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
override fun onOutgoingVoiceMessageStarted(zello: Zello, message: ZelloOutgoingVoiceMessage) {
|
|
363
|
+
sendEvent(reactApplicationContext, "onOutgoingVoiceMessageStarted", Arguments.createMap().apply {
|
|
364
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
365
|
+
putString("timestamp", message.timestamp.toString())
|
|
366
|
+
putString("state", message.state.toString())
|
|
367
|
+
})
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
override fun onOutgoingVoiceMessageStopped(zello: Zello, message: ZelloOutgoingVoiceMessage, error: ZelloOutgoingVoiceMessage.Error?) {
|
|
371
|
+
sendEvent(reactApplicationContext, "onOutgoingVoiceMessageStopped", Arguments.createMap().apply {
|
|
372
|
+
putMap("contact", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = message.contact))
|
|
373
|
+
putString("timestamp", message.timestamp.toString())
|
|
374
|
+
putString("state", message.state.toString())
|
|
375
|
+
putMap("error", error?.let {
|
|
376
|
+
Arguments.createMap().apply {
|
|
377
|
+
putString("message", it.toString())
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
})
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
override fun onIncomingEmergencyStarted(zello: Zello, incomingEmergency: ZelloIncomingEmergency) {
|
|
384
|
+
sendEvent(reactApplicationContext, "onIncomingEmergencyStarted", Arguments.createMap().apply {
|
|
385
|
+
putMap("emergency", ZelloAndroidSdkModuleHelper.incomingEmergencyToWritableMap(incomingEmergency))
|
|
386
|
+
putArray("emergencies", ZelloAndroidSdkModuleHelper.incomingEmergenciesToWritableArray(this@ZelloAndroidSdkModule.zello.incomingEmergencies))
|
|
387
|
+
})
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
override fun onIncomingEmergencyStopped(zello: Zello, incomingEmergency: ZelloIncomingEmergency) {
|
|
391
|
+
sendEvent(reactApplicationContext, "onIncomingEmergencyStopped", Arguments.createMap().apply {
|
|
392
|
+
putMap("emergency", ZelloAndroidSdkModuleHelper.incomingEmergencyToWritableMap(incomingEmergency))
|
|
393
|
+
putArray("emergencies", ZelloAndroidSdkModuleHelper.incomingEmergenciesToWritableArray(this@ZelloAndroidSdkModule.zello.incomingEmergencies))
|
|
394
|
+
})
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
override fun onOutgoingEmergencyStarted(zello: Zello, outgoingEmergency: ZelloOutgoingEmergency) {
|
|
398
|
+
sendEvent(reactApplicationContext, "onOutgoingEmergencyStarted", Arguments.createMap().apply {
|
|
399
|
+
putMap("channel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = outgoingEmergency.channel))
|
|
400
|
+
putInt("startTimestamp", outgoingEmergency.startTimestamp.toInt())
|
|
401
|
+
})
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
override fun onOutgoingEmergencyStopped(zello: Zello, outgoingEmergency: ZelloOutgoingEmergency) {
|
|
405
|
+
sendEvent(reactApplicationContext, "onOutgoingEmergencyStopped", Arguments.createMap().apply {
|
|
406
|
+
putMap("channel", ZelloAndroidSdkModuleHelper.sdkContactToWritableMap(contact = outgoingEmergency.channel))
|
|
407
|
+
putInt("startTimestamp", outgoingEmergency.startTimestamp.toInt())
|
|
408
|
+
outgoingEmergency.endTimestamp?.let {
|
|
409
|
+
putInt("endTimestamp", it.toInt())
|
|
410
|
+
}
|
|
411
|
+
})
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
override fun onRecentsUpdated(zello: Zello, recents: List<ZelloRecentEntry>) {
|
|
415
|
+
sendEvent(reactApplicationContext, "onRecentsUpdated", Arguments.createMap().apply {
|
|
416
|
+
putArray("recents", ZelloAndroidSdkModuleHelper.recentsToWritableArray(recents))
|
|
417
|
+
})
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
override fun onHistoryPlaybackStarted(zello: Zello, message: ZelloHistoryVoiceMessage) {
|
|
421
|
+
sendEvent(reactApplicationContext, "onHistoryPlaybackStarted", ZelloAndroidSdkModuleHelper.historyVoiceMessageToWritableMap(message))
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
override fun onHistoryPlaybackStopped(zello: Zello, message: ZelloHistoryVoiceMessage) {
|
|
425
|
+
sendEvent(reactApplicationContext, "onHistoryPlaybackStopped", ZelloAndroidSdkModuleHelper.historyVoiceMessageToWritableMap(message))
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
override fun onHistoryUpdated(zello: Zello) {
|
|
429
|
+
sendEvent(reactApplicationContext, "onHistoryUpdated", null)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
private fun sendEvent(reactContext: ReactContext, name: String, params: WritableMap?) {
|
|
433
|
+
reactContext
|
|
434
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
435
|
+
.emit(BRIDGE_EVENT_NAME, params?.apply { putString(EVENT_NAME, name) } ?: Arguments.createMap().apply { putString(EVENT_NAME, name) })
|
|
436
|
+
}
|
|
437
|
+
}
|