omikit-plugin 4.1.5 → 4.1.6
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.
|
@@ -1154,88 +1154,57 @@ class OmikitPluginModule(reactContext: ReactApplicationContext?) :
|
|
|
1154
1154
|
@ReactMethod
|
|
1155
1155
|
fun getCurrentUser(promise: Promise) {
|
|
1156
1156
|
mainScope.launch {
|
|
1157
|
-
|
|
1158
|
-
withContext(Dispatchers.Default) {
|
|
1157
|
+
val callResult = withContext(Dispatchers.Default) {
|
|
1159
1158
|
try {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
Log.e("OmikitPlugin", "❌ getCurrentUser error: ${e.message}", e)
|
|
1159
|
+
OmiClient.getInstance(reactApplicationContext!!).getCurrentUser()
|
|
1160
|
+
} catch (_: Throwable) {
|
|
1161
|
+
null
|
|
1164
1162
|
}
|
|
1165
1163
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
map.putString("extension", call["extension"] as String?)
|
|
1170
|
-
map.putString("uuid", call["uuid"] as String?)
|
|
1171
|
-
map.putString("full_name", call["full_name"] as String?)
|
|
1172
|
-
map.putString("avatar_url", call["avatar_url"] as String?)
|
|
1173
|
-
|
|
1174
|
-
map.putString("fullName", call["full_name"] as String?)
|
|
1175
|
-
map.putString("avatarUrl", call["avatar_url"] as String?)
|
|
1164
|
+
resolveUserResult(callResult, promise)
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1176
1167
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1168
|
+
private fun resolveUserResult(callResult: Any?, promise: Promise) {
|
|
1169
|
+
if (callResult is Map<*, *>) {
|
|
1170
|
+
val map: WritableMap = WritableNativeMap()
|
|
1171
|
+
map.putString("extension", callResult["extension"] as String?)
|
|
1172
|
+
map.putString("uuid", callResult["uuid"] as String?)
|
|
1173
|
+
map.putString("full_name", callResult["full_name"] as String?)
|
|
1174
|
+
map.putString("avatar_url", callResult["avatar_url"] as String?)
|
|
1175
|
+
map.putString("fullName", callResult["full_name"] as String?)
|
|
1176
|
+
map.putString("avatarUrl", callResult["avatar_url"] as String?)
|
|
1177
|
+
promise.resolve(map)
|
|
1178
|
+
} else {
|
|
1179
|
+
promise.resolve(null)
|
|
1183
1180
|
}
|
|
1184
1181
|
}
|
|
1185
1182
|
|
|
1186
1183
|
@ReactMethod
|
|
1187
1184
|
fun getGuestUser(promise: Promise) {
|
|
1188
1185
|
mainScope.launch {
|
|
1189
|
-
|
|
1190
|
-
withContext(Dispatchers.Default) {
|
|
1186
|
+
val callResult = withContext(Dispatchers.Default) {
|
|
1191
1187
|
try {
|
|
1192
|
-
|
|
1188
|
+
OmiClient.getInstance(reactApplicationContext!!).getIncomingCallUser()
|
|
1193
1189
|
} catch (_: Throwable) {
|
|
1194
|
-
|
|
1190
|
+
null
|
|
1195
1191
|
}
|
|
1196
1192
|
}
|
|
1197
|
-
|
|
1198
|
-
val call = callResult as Map<*, *>
|
|
1199
|
-
val map: WritableMap = WritableNativeMap()
|
|
1200
|
-
map.putString("extension", call["extension"] as String?)
|
|
1201
|
-
map.putString("uuid", call["uuid"] as String?)
|
|
1202
|
-
map.putString("full_name", call["full_name"] as String?)
|
|
1203
|
-
map.putString("avatar_url", call["avatar_url"] as String?)
|
|
1204
|
-
|
|
1205
|
-
map.putString("fullName", call["full_name"] as String?)
|
|
1206
|
-
map.putString("avatarUrl", call["avatar_url"] as String?)
|
|
1207
|
-
|
|
1208
|
-
promise.resolve(map)
|
|
1209
|
-
} else {
|
|
1210
|
-
promise.resolve(null);
|
|
1211
|
-
}
|
|
1193
|
+
resolveUserResult(callResult, promise)
|
|
1212
1194
|
}
|
|
1213
1195
|
}
|
|
1214
1196
|
|
|
1215
1197
|
@ReactMethod
|
|
1216
1198
|
fun getUserInfo(phone: String, promise: Promise) {
|
|
1217
1199
|
mainScope.launch {
|
|
1218
|
-
|
|
1219
|
-
withContext(Dispatchers.Default) {
|
|
1200
|
+
val callResult = withContext(Dispatchers.Default) {
|
|
1220
1201
|
try {
|
|
1221
|
-
|
|
1202
|
+
OmiClient.getInstance(reactApplicationContext!!).getUserInfo(phone)
|
|
1222
1203
|
} catch (_: Throwable) {
|
|
1204
|
+
null
|
|
1223
1205
|
}
|
|
1224
1206
|
}
|
|
1225
|
-
|
|
1226
|
-
val call = callResult as Map<*, *>
|
|
1227
|
-
val map: WritableMap = WritableNativeMap()
|
|
1228
|
-
map.putString("extension", call["extension"] as String?)
|
|
1229
|
-
map.putString("uuid", call["uuid"] as String?)
|
|
1230
|
-
map.putString("full_name", call["full_name"] as String?)
|
|
1231
|
-
map.putString("avatar_url", call["avatar_url"] as String?)
|
|
1232
|
-
|
|
1233
|
-
map.putString("fullName", call["full_name"] as String?)
|
|
1234
|
-
map.putString("avatarUrl", call["avatar_url"] as String?)
|
|
1235
|
-
promise.resolve(map)
|
|
1236
|
-
} else {
|
|
1237
|
-
promise.resolve(null)
|
|
1238
|
-
}
|
|
1207
|
+
resolveUserResult(callResult, promise)
|
|
1239
1208
|
}
|
|
1240
1209
|
}
|
|
1241
1210
|
|