juggleim-rnsdk 0.1.4 → 0.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.
- package/android/.settings/org.eclipse.buildship.core.prefs +1 -1
- package/android/.settings/org.eclipse.jdt.core.prefs +4 -0
- package/android/build/.transforms/42b8ab7e96b9440b0e91d2ecba5f579c/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$1.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$10.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$11.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$12.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$13.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$14.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$15.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$16.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$17.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$18.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$19.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$2.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$20.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$21.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$22.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$23.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$3.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$4.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$5.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$6.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$7.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$8.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager$9.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/JuggleIMManager.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/RNTypeConverter$1.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/RNTypeConverter.dex +0 -0
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$10.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$11.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$12.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$13.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$14.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$15.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$16.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$17.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$18.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$19.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$2.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$20.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$21.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$22.class +0 -0
- package/android/build/{tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$22.class.uniqueId14 → intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$23.class} +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$3.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$4.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$5.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$6.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$7.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$8.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager$9.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/JuggleIMManager.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/RNTypeConverter$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/RNTypeConverter.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$10.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$11.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$12.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$13.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$14.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$15.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$16.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$17.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$18.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$19.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$20.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$21.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$22.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$23.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$5.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$6.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$7.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$8.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager$9.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/JuggleIMManager.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/RNTypeConverter$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/RNTypeConverter.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/src/main/java/com/juggleim/JuggleIMManager.java +106 -141
- package/android/src/main/java/com/juggleim/RNTypeConverter.java +79 -0
- package/ios/JModelFactory.h +53 -0
- package/ios/JModelFactory.m +783 -0
- package/ios/JuggleIMManager.m +24 -38
- package/juggleim-rnsdk.podspec +1 -1
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/android/build/.transforms/a3b636e0768beb7635f48b7f77613c33/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/juggleim/GenericCustomMessage.dex +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/juggleim/GenericCustomMessage.class +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$1.class.uniqueId23 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$10.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$11.class.uniqueId4 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$12.class.uniqueId20 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$13.class.uniqueId16 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$14.class.uniqueId7 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$15.class.uniqueId13 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$16.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$17.class.uniqueId22 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$18.class.uniqueId19 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$19.class.uniqueId17 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$2.class.uniqueId8 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$20.class.uniqueId12 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$21.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$3.class.uniqueId10 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$4.class.uniqueId18 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$5.class.uniqueId21 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$6.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$7.class.uniqueId11 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$8.class.uniqueId9 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager$9.class.uniqueId15 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMManager.class.uniqueId5 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/JuggleIMPackage.class.uniqueId6 +0 -0
- package/android/src/main/java/com/juggleim/GenericCustomMessage.java +0 -45
- package/ios/GenericCustomMessage.h +0 -24
- package/ios/GenericCustomMessage.m +0 -29
- /package/android/build/{intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/juggleim/GenericCustomMessage.class → tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GenericCustomMessage.class.uniqueId0} +0 -0
|
@@ -33,6 +33,7 @@ import com.juggle.im.model.messages.*;
|
|
|
33
33
|
import com.juggle.im.JIM;
|
|
34
34
|
import com.juggle.im.internal.logger.JLogConfig;
|
|
35
35
|
import com.juggle.im.internal.logger.JLogLevel;
|
|
36
|
+
import com.juggle.im.model.MessageContent.*;
|
|
36
37
|
|
|
37
38
|
import java.util.ArrayList;
|
|
38
39
|
import java.util.HashMap;
|
|
@@ -56,7 +57,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
56
57
|
private Map<String, IMessageManager.IMessageListener> messageListeners = new HashMap<>();
|
|
57
58
|
private Map<String, IMessageManager.IMessageReadReceiptListener> readReceiptListeners = new HashMap<>();
|
|
58
59
|
private Map<String, IConversationManager.IConversationListener> conversationListeners = new HashMap<>();
|
|
59
|
-
|
|
60
|
+
|
|
60
61
|
// 自定义消息类型注册表
|
|
61
62
|
private Map<String, String> customMessageTypes = new HashMap<>();
|
|
62
63
|
|
|
@@ -107,7 +108,6 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
107
108
|
logBuilder.setLogConsoleLevel(JLogLevel.JLogLevelVerbose);
|
|
108
109
|
builder.setJLogConfig(new JLogConfig(logBuilder));
|
|
109
110
|
JIM.getInstance().init(getCurrentActivity(), appKey, builder.build());
|
|
110
|
-
JIM.getInstance().getMessageManager().registerContentType(GenericCustomMessage.class);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
@@ -138,6 +138,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
138
138
|
/**
|
|
139
139
|
* // true 表示断开连接后还继续接收推送
|
|
140
140
|
* // false 表示断开连接之后不再接收推送
|
|
141
|
+
*
|
|
141
142
|
* @param pushable
|
|
142
143
|
*/
|
|
143
144
|
@ReactMethod
|
|
@@ -399,12 +400,13 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
399
400
|
@ReactMethod
|
|
400
401
|
public void addMessageDestroyListener(String key) {
|
|
401
402
|
JIM.getInstance().getMessageManager().addDestroyListener(key, new IMessageManager.IMessageDestroyListener() {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
403
|
+
/**
|
|
404
|
+
* 消息销毁时间更新回调(一般发生在阅后即焚之类的场景)
|
|
405
|
+
*
|
|
406
|
+
* @param messageId 消息 id
|
|
407
|
+
* @param conversation 所在会话
|
|
408
|
+
* @param destroyTime 更新后的销毁时间
|
|
409
|
+
*/
|
|
408
410
|
@Override
|
|
409
411
|
public void onMessageDestroyTimeUpdate(String messageId, Conversation conversation, long destroyTime) {
|
|
410
412
|
WritableMap params = new WritableNativeMap();
|
|
@@ -427,7 +429,9 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
427
429
|
map.putDouble("timestamp", message.getTimestamp());
|
|
428
430
|
map.putString("senderUserId", message.getSenderUserId());
|
|
429
431
|
map.putMap("conversation", convertConversationToMap(message.getConversation()));
|
|
430
|
-
|
|
432
|
+
WritableMap contentMap = convertMessageContentToMap(message.getContent());
|
|
433
|
+
contentMap.putString("contentType", message.getContentType());
|
|
434
|
+
map.putMap("content", contentMap);
|
|
431
435
|
|
|
432
436
|
// 添加消息方向
|
|
433
437
|
if (message.getDirection() != null) {
|
|
@@ -442,7 +446,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
442
446
|
// 添加是否已读
|
|
443
447
|
map.putBoolean("hasRead", message.isHasRead());
|
|
444
448
|
map.putBoolean("isEdit", message.isEdit());
|
|
445
|
-
map.putBoolean("isDeleted", message.
|
|
449
|
+
map.putBoolean("isDeleted", message.isDelete());
|
|
446
450
|
|
|
447
451
|
// 添加群消息阅读信息
|
|
448
452
|
if (message.getGroupMessageReadInfo() != null) {
|
|
@@ -485,53 +489,10 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
485
489
|
* 将消息内容转换为Map
|
|
486
490
|
*/
|
|
487
491
|
private WritableMap convertMessageContentToMap(MessageContent content) {
|
|
488
|
-
|
|
489
|
-
String
|
|
490
|
-
Log.d("JuggleIM", "
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
if (contentType.equals("jg:text")) {
|
|
494
|
-
map.putString("content", ((TextMessage) content).getContent());
|
|
495
|
-
} else if (contentType.equals("jg:img")) {
|
|
496
|
-
ImageMessage img = (ImageMessage) content;
|
|
497
|
-
map.putString("url", img.getUrl());
|
|
498
|
-
map.putString("localPath", img.getLocalPath());
|
|
499
|
-
map.putString("thumbnailLocalPath", img.getThumbnailLocalPath());
|
|
500
|
-
map.putString("thumbnailUrl", img.getThumbnailUrl());
|
|
501
|
-
map.putInt("width", img.getWidth());
|
|
502
|
-
map.putInt("height", img.getHeight());
|
|
503
|
-
} else if (contentType.equals("jg:file")) {
|
|
504
|
-
FileMessage file = (FileMessage) content;
|
|
505
|
-
map.putString("url", file.getUrl());
|
|
506
|
-
map.putString("type", file.getType());
|
|
507
|
-
map.putString("name", file.getName());
|
|
508
|
-
map.putDouble("size", file.getSize());
|
|
509
|
-
} else if (contentType.equals("jg:voice")) {
|
|
510
|
-
VoiceMessage voice = (VoiceMessage) content;
|
|
511
|
-
map.putString("url", voice.getUrl());
|
|
512
|
-
map.putString("localPath", voice.getLocalPath());
|
|
513
|
-
map.putInt("duration", voice.getDuration());
|
|
514
|
-
} else if (contentType.equals("jgrn:custom")) {
|
|
515
|
-
GenericCustomMessage genericCustomMessage = (GenericCustomMessage) content;
|
|
516
|
-
byte[] data = genericCustomMessage.encode();
|
|
517
|
-
if (data != null) {
|
|
518
|
-
try {
|
|
519
|
-
String jsonStr = new String(data, StandardCharsets.UTF_8);
|
|
520
|
-
JSONObject jsonObject = new JSONObject(jsonStr);
|
|
521
|
-
map = convertJSONToWritableMap(jsonObject);
|
|
522
|
-
} catch (JSONException e) {
|
|
523
|
-
Log.e("JuggleIM", "解析自定义消息失败: " + e.getMessage());
|
|
524
|
-
}
|
|
525
|
-
} else {
|
|
526
|
-
Log.e("JuggleIM", "No data for contentType: " + contentType);
|
|
527
|
-
}
|
|
528
|
-
} else {
|
|
529
|
-
Log.e("JuggleIM", "Unknown contentType: " + contentType);
|
|
530
|
-
return RNTypeConverter.toWritableMap(content);
|
|
531
|
-
}
|
|
532
|
-
Log.d("JuggleIM", "convertMessageContentToMap: " + map.getString("contentType"));
|
|
533
|
-
|
|
534
|
-
return map;
|
|
492
|
+
byte[] bytes = content.encode();
|
|
493
|
+
String str = new String(bytes, StandardCharsets.UTF_8);
|
|
494
|
+
Log.d("JuggleIM", "convertMessageContentToMap: " + str);
|
|
495
|
+
return RNTypeConverter.stringToWritableMap(str);
|
|
535
496
|
}
|
|
536
497
|
|
|
537
498
|
private MessageContent convertMapToMessageContent(ReadableMap map) {
|
|
@@ -565,7 +526,9 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
565
526
|
default:
|
|
566
527
|
// 检查是否是自定义消息
|
|
567
528
|
if (customMessageTypes.containsKey(contentType)) {
|
|
568
|
-
|
|
529
|
+
UnknownMessage msg = createUnknownMessage(map);
|
|
530
|
+
msg.setMessageType(contentType);
|
|
531
|
+
return msg;
|
|
569
532
|
}
|
|
570
533
|
Log.e("JuggleIM", "contentType: " + contentType);
|
|
571
534
|
return RNTypeConverter.fromReadableMap(map, MessageContent.class);
|
|
@@ -575,16 +538,13 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
575
538
|
/**
|
|
576
539
|
* 创建自定义消息对象
|
|
577
540
|
*/
|
|
578
|
-
private
|
|
541
|
+
private UnknownMessage createUnknownMessage(ReadableMap map) {
|
|
579
542
|
try {
|
|
580
|
-
// 将 ReadableMap 转换为 JSON
|
|
581
543
|
JSONObject jsonObject = convertReadableMapToJSON(map);
|
|
582
544
|
String jsonStr = jsonObject.toString();
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
customMsg.setData(jsonStr.getBytes(StandardCharsets.UTF_8));
|
|
587
|
-
|
|
545
|
+
UnknownMessage customMsg = new UnknownMessage();
|
|
546
|
+
customMsg.setFlags(MessageFlag.IS_SAVE.getValue() | MessageFlag.IS_COUNTABLE.getValue());
|
|
547
|
+
customMsg.setContent(jsonStr);
|
|
588
548
|
return customMsg;
|
|
589
549
|
} catch (JSONException e) {
|
|
590
550
|
Log.e("JuggleIM", "创建自定义消息失败: " + e.getMessage());
|
|
@@ -598,7 +558,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
598
558
|
private JSONObject convertReadableMapToJSON(ReadableMap map) throws JSONException {
|
|
599
559
|
JSONObject jsonObject = new JSONObject();
|
|
600
560
|
ReadableMapKeySetIterator iterator = map.keySetIterator();
|
|
601
|
-
|
|
561
|
+
|
|
602
562
|
while (iterator.hasNextKey()) {
|
|
603
563
|
String key = iterator.nextKey();
|
|
604
564
|
switch (map.getType(key)) {
|
|
@@ -622,7 +582,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
622
582
|
break;
|
|
623
583
|
}
|
|
624
584
|
}
|
|
625
|
-
|
|
585
|
+
|
|
626
586
|
return jsonObject;
|
|
627
587
|
}
|
|
628
588
|
|
|
@@ -631,7 +591,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
631
591
|
*/
|
|
632
592
|
private JSONArray convertReadableArrayToJSONArray(ReadableArray array) throws JSONException {
|
|
633
593
|
JSONArray jsonArray = new JSONArray();
|
|
634
|
-
|
|
594
|
+
|
|
635
595
|
for (int i = 0; i < array.size(); i++) {
|
|
636
596
|
switch (array.getType(i)) {
|
|
637
597
|
case Null:
|
|
@@ -654,7 +614,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
654
614
|
break;
|
|
655
615
|
}
|
|
656
616
|
}
|
|
657
|
-
|
|
617
|
+
|
|
658
618
|
return jsonArray;
|
|
659
619
|
}
|
|
660
620
|
|
|
@@ -663,7 +623,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
663
623
|
*/
|
|
664
624
|
private WritableMap convertJSONToWritableMap(JSONObject jsonObject) throws JSONException {
|
|
665
625
|
WritableMap map = new WritableNativeMap();
|
|
666
|
-
|
|
626
|
+
|
|
667
627
|
Iterator<String> iterator = jsonObject.keys();
|
|
668
628
|
while (iterator.hasNext()) {
|
|
669
629
|
String key = iterator.next();
|
|
@@ -684,7 +644,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
684
644
|
map.putNull(key);
|
|
685
645
|
}
|
|
686
646
|
}
|
|
687
|
-
|
|
647
|
+
|
|
688
648
|
return map;
|
|
689
649
|
}
|
|
690
650
|
|
|
@@ -693,10 +653,10 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
693
653
|
*/
|
|
694
654
|
private WritableArray convertJSONArrayToWritableArray(JSONArray jsonArray) throws JSONException {
|
|
695
655
|
WritableArray array = new WritableNativeArray();
|
|
696
|
-
|
|
656
|
+
|
|
697
657
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
698
658
|
Object value = jsonArray.get(i);
|
|
699
|
-
|
|
659
|
+
|
|
700
660
|
if (value instanceof JSONObject) {
|
|
701
661
|
array.pushMap(convertJSONToWritableMap((JSONObject) value));
|
|
702
662
|
} else if (value instanceof JSONArray) {
|
|
@@ -713,7 +673,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
713
673
|
array.pushNull();
|
|
714
674
|
}
|
|
715
675
|
}
|
|
716
|
-
|
|
676
|
+
|
|
717
677
|
return array;
|
|
718
678
|
}
|
|
719
679
|
|
|
@@ -776,7 +736,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
776
736
|
return map;
|
|
777
737
|
}
|
|
778
738
|
|
|
779
|
-
//conversation
|
|
739
|
+
// conversation
|
|
780
740
|
|
|
781
741
|
/**
|
|
782
742
|
* 获取会话信息列表
|
|
@@ -784,10 +744,11 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
784
744
|
@ReactMethod
|
|
785
745
|
public void getConversationInfoList(int count, double ts, int pullDirection, Promise promise) {
|
|
786
746
|
try {
|
|
787
|
-
JIMConst.PullDirection direction = pullDirection == 0 ?
|
|
788
|
-
|
|
747
|
+
JIMConst.PullDirection direction = pullDirection == 0 ? JIMConst.PullDirection.NEWER
|
|
748
|
+
: JIMConst.PullDirection.OLDER;
|
|
789
749
|
|
|
790
|
-
List<ConversationInfo> conversationInfos = com.juggle.im.JIM.getInstance().getConversationManager()
|
|
750
|
+
List<ConversationInfo> conversationInfos = com.juggle.im.JIM.getInstance().getConversationManager()
|
|
751
|
+
.getConversationInfoList(count, (long) ts, direction);
|
|
791
752
|
Log.d("JuggleIM", "conversationInfos: " + conversationInfos.size());
|
|
792
753
|
WritableArray result = new WritableNativeArray();
|
|
793
754
|
for (ConversationInfo info : conversationInfos) {
|
|
@@ -996,7 +957,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
996
957
|
WritableMap map = new WritableNativeMap();
|
|
997
958
|
WritableArray userMap = new WritableNativeArray();
|
|
998
959
|
map.putInt("type", mentionInfo.getType().getValue());
|
|
999
|
-
if (mentionInfo.getTargetUsers() != null) {
|
|
960
|
+
if (mentionInfo.getTargetUsers() != null) {
|
|
1000
961
|
for (UserInfo userInfo : mentionInfo.getTargetUsers()) {
|
|
1001
962
|
userMap.pushMap(convertUserInfoToMap(userInfo));
|
|
1002
963
|
}
|
|
@@ -1034,8 +995,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1034
995
|
event.putInt("errorCode", errorCode);
|
|
1035
996
|
sendEvent("onMessageSentError", event);
|
|
1036
997
|
}
|
|
1037
|
-
}
|
|
1038
|
-
);
|
|
998
|
+
});
|
|
1039
999
|
WritableMap result = convertMessageToMap(sendMsg);
|
|
1040
1000
|
result.putString("messageId", messageId);
|
|
1041
1001
|
promise.resolve(result);
|
|
@@ -1045,7 +1005,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1045
1005
|
* 根据clientMsgNo列表删除消息
|
|
1046
1006
|
*/
|
|
1047
1007
|
@ReactMethod
|
|
1048
|
-
public void deleteMessagesByClientMsgNoList(ReadableMap conversationMap, ReadableArray clientMsgNos,
|
|
1008
|
+
public void deleteMessagesByClientMsgNoList(ReadableMap conversationMap, ReadableArray clientMsgNos,
|
|
1009
|
+
Promise promise) {
|
|
1049
1010
|
Conversation conversation = convertMapToConversation(conversationMap);
|
|
1050
1011
|
List<Long> msgNoList = new ArrayList<>();
|
|
1051
1012
|
for (int i = 0; i < clientMsgNos.size(); i++) {
|
|
@@ -1082,8 +1043,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1082
1043
|
getOptions.setStartTime((long) options.getDouble("startTime"));
|
|
1083
1044
|
}
|
|
1084
1045
|
|
|
1085
|
-
JIMConst.PullDirection pullDirection = direction == 0 ?
|
|
1086
|
-
|
|
1046
|
+
JIMConst.PullDirection pullDirection = direction == 0 ? JIMConst.PullDirection.OLDER
|
|
1047
|
+
: JIMConst.PullDirection.NEWER;
|
|
1087
1048
|
|
|
1088
1049
|
JIM.getInstance().getMessageManager().getMessages(
|
|
1089
1050
|
conversation,
|
|
@@ -1103,8 +1064,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1103
1064
|
result.putInt("code", code);
|
|
1104
1065
|
promise.resolve(result);
|
|
1105
1066
|
}
|
|
1106
|
-
}
|
|
1107
|
-
);
|
|
1067
|
+
});
|
|
1108
1068
|
} catch (Exception e) {
|
|
1109
1069
|
promise.reject("GET_MESSAGES_ERROR", e.getMessage());
|
|
1110
1070
|
}
|
|
@@ -1137,8 +1097,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1137
1097
|
public void onError(int errorCode) {
|
|
1138
1098
|
promise.reject("RECALL_MESSAGE_ERROR", errorCode + "");
|
|
1139
1099
|
}
|
|
1140
|
-
}
|
|
1141
|
-
);
|
|
1100
|
+
});
|
|
1142
1101
|
} catch (Exception e) {
|
|
1143
1102
|
promise.reject("RECALL_MESSAGE_ERROR", e.getMessage());
|
|
1144
1103
|
}
|
|
@@ -1167,8 +1126,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1167
1126
|
public void onError(int errorCode) {
|
|
1168
1127
|
promise.reject("ADD_REACTION_ERROR", errorCode + "");
|
|
1169
1128
|
}
|
|
1170
|
-
}
|
|
1171
|
-
);
|
|
1129
|
+
});
|
|
1172
1130
|
} catch (Exception e) {
|
|
1173
1131
|
promise.reject("ADD_REACTION_ERROR", e.getMessage());
|
|
1174
1132
|
}
|
|
@@ -1197,8 +1155,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1197
1155
|
public void onError(int errorCode) {
|
|
1198
1156
|
promise.reject("REMOVE_REACTION_ERROR", errorCode + "");
|
|
1199
1157
|
}
|
|
1200
|
-
}
|
|
1201
|
-
);
|
|
1158
|
+
});
|
|
1202
1159
|
} catch (Exception e) {
|
|
1203
1160
|
promise.reject("REMOVE_REACTION_ERROR", e.getMessage());
|
|
1204
1161
|
}
|
|
@@ -1215,11 +1172,13 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1215
1172
|
|
|
1216
1173
|
ReadableMap contentMap = messageMap.getMap("content");
|
|
1217
1174
|
if (contentMap.hasKey("localPath")) {
|
|
1218
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1175
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1176
|
+
contentMap.getString("localPath"));
|
|
1219
1177
|
imageMessage.setLocalPath(path);
|
|
1220
1178
|
}
|
|
1221
1179
|
if (contentMap.hasKey("thumbnailLocalPath")) {
|
|
1222
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1180
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1181
|
+
contentMap.getString("localPath"));
|
|
1223
1182
|
imageMessage.setThumbnailLocalPath(path);
|
|
1224
1183
|
}
|
|
1225
1184
|
if (contentMap.hasKey("url")) {
|
|
@@ -1273,8 +1232,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1273
1232
|
params.putMap("message", convertMessageToMap(message));
|
|
1274
1233
|
sendEvent("onMediaMessageCancelled", params);
|
|
1275
1234
|
}
|
|
1276
|
-
}
|
|
1277
|
-
);
|
|
1235
|
+
});
|
|
1278
1236
|
|
|
1279
1237
|
WritableMap result = convertMessageToMap(message);
|
|
1280
1238
|
result.putString("messageId", messageId);
|
|
@@ -1295,7 +1253,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1295
1253
|
|
|
1296
1254
|
ReadableMap contentMap = messageMap.getMap("content");
|
|
1297
1255
|
if (contentMap.hasKey("localPath")) {
|
|
1298
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1256
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1257
|
+
contentMap.getString("localPath"));
|
|
1299
1258
|
fileMessage.setLocalPath(path);
|
|
1300
1259
|
}
|
|
1301
1260
|
if (contentMap.hasKey("url")) {
|
|
@@ -1348,8 +1307,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1348
1307
|
params.putMap("message", convertMessageToMap(message));
|
|
1349
1308
|
sendEvent("onMediaMessageCancelled", params);
|
|
1350
1309
|
}
|
|
1351
|
-
}
|
|
1352
|
-
);
|
|
1310
|
+
});
|
|
1353
1311
|
|
|
1354
1312
|
WritableMap result = convertMessageToMap(message);
|
|
1355
1313
|
result.putString("messageId", messageId);
|
|
@@ -1370,7 +1328,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1370
1328
|
|
|
1371
1329
|
ReadableMap contentMap = messageMap.getMap("content");
|
|
1372
1330
|
if (contentMap.hasKey("localPath")) {
|
|
1373
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1331
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1332
|
+
contentMap.getString("localPath"));
|
|
1374
1333
|
voiceMessage.setLocalPath(path);
|
|
1375
1334
|
}
|
|
1376
1335
|
if (contentMap.hasKey("url")) {
|
|
@@ -1413,8 +1372,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1413
1372
|
WritableMap result = convertMessageToMap(message);
|
|
1414
1373
|
sendEvent("onMediaMessageCancelled", result);
|
|
1415
1374
|
}
|
|
1416
|
-
}
|
|
1417
|
-
);
|
|
1375
|
+
});
|
|
1418
1376
|
|
|
1419
1377
|
WritableMap result = convertMessageToMap(message);
|
|
1420
1378
|
promise.resolve(result);
|
|
@@ -1492,7 +1450,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1492
1450
|
private MessageMentionInfo convertMapToMentionInfo(ReadableMap mentionInfoMap) {
|
|
1493
1451
|
MessageMentionInfo mentionInfo = new MessageMentionInfo();
|
|
1494
1452
|
if (mentionInfoMap.hasKey("type")) {
|
|
1495
|
-
MessageMentionInfo.MentionType type = MessageMentionInfo.MentionType
|
|
1453
|
+
MessageMentionInfo.MentionType type = MessageMentionInfo.MentionType
|
|
1454
|
+
.setValue(mentionInfoMap.getInt("type"));
|
|
1496
1455
|
mentionInfo.setType(type);
|
|
1497
1456
|
}
|
|
1498
1457
|
if (mentionInfoMap.hasKey("targetUsers")) {
|
|
@@ -1524,9 +1483,10 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1524
1483
|
|
|
1525
1484
|
/**
|
|
1526
1485
|
* 发送消息已读回执
|
|
1486
|
+
*
|
|
1527
1487
|
* @param conversationMap 会话对象
|
|
1528
|
-
* @param messageIds
|
|
1529
|
-
* @param promise
|
|
1488
|
+
* @param messageIds 消息ID列表
|
|
1489
|
+
* @param promise Promise对象
|
|
1530
1490
|
*/
|
|
1531
1491
|
@ReactMethod
|
|
1532
1492
|
public void sendReadReceipt(ReadableMap conversationMap, ReadableArray messageIds, Promise promise) {
|
|
@@ -1537,17 +1497,18 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1537
1497
|
msgIdList.add(messageIds.getString(i));
|
|
1538
1498
|
}
|
|
1539
1499
|
|
|
1540
|
-
JIM.getInstance().getMessageManager().sendReadReceipt(conversation, msgIdList,
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1500
|
+
JIM.getInstance().getMessageManager().sendReadReceipt(conversation, msgIdList,
|
|
1501
|
+
new IMessageManager.ISendReadReceiptCallback() {
|
|
1502
|
+
@Override
|
|
1503
|
+
public void onSuccess() {
|
|
1504
|
+
promise.resolve(true);
|
|
1505
|
+
}
|
|
1545
1506
|
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1507
|
+
@Override
|
|
1508
|
+
public void onError(int errorCode) {
|
|
1509
|
+
promise.reject("error", "Error code: " + errorCode);
|
|
1510
|
+
}
|
|
1511
|
+
});
|
|
1551
1512
|
} catch (Exception e) {
|
|
1552
1513
|
e.printStackTrace();
|
|
1553
1514
|
promise.reject(e);
|
|
@@ -1556,10 +1517,11 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1556
1517
|
|
|
1557
1518
|
/**
|
|
1558
1519
|
* 更新消息
|
|
1559
|
-
*
|
|
1560
|
-
* @param
|
|
1520
|
+
*
|
|
1521
|
+
* @param messageId 消息ID
|
|
1522
|
+
* @param contentMap 新的消息内容
|
|
1561
1523
|
* @param conversationMap 会话对象
|
|
1562
|
-
* @param promise
|
|
1524
|
+
* @param promise Promise对象
|
|
1563
1525
|
*/
|
|
1564
1526
|
@ReactMethod
|
|
1565
1527
|
public void updateMessage(String messageId, ReadableMap contentMap, ReadableMap conversationMap, Promise promise) {
|
|
@@ -1567,17 +1529,18 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1567
1529
|
MessageContent content = convertMapToMessageContent(contentMap);
|
|
1568
1530
|
Conversation conversation = convertMapToConversation(conversationMap);
|
|
1569
1531
|
|
|
1570
|
-
JIM.getInstance().getMessageManager().updateMessage(messageId, content, conversation,
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1532
|
+
JIM.getInstance().getMessageManager().updateMessage(messageId, content, conversation,
|
|
1533
|
+
new IMessageManager.IMessageCallback() {
|
|
1534
|
+
@Override
|
|
1535
|
+
public void onSuccess(Message message) {
|
|
1536
|
+
promise.resolve(convertMessageToMap(message));
|
|
1537
|
+
}
|
|
1575
1538
|
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1539
|
+
@Override
|
|
1540
|
+
public void onError(int errorCode) {
|
|
1541
|
+
promise.reject("error", "Error code: " + errorCode);
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1581
1544
|
} catch (Exception e) {
|
|
1582
1545
|
e.printStackTrace();
|
|
1583
1546
|
promise.reject(e);
|
|
@@ -1586,27 +1549,29 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1586
1549
|
|
|
1587
1550
|
/**
|
|
1588
1551
|
* 设置消息置顶
|
|
1589
|
-
*
|
|
1552
|
+
*
|
|
1553
|
+
* @param messageId 消息ID
|
|
1590
1554
|
* @param conversationMap 会话对象
|
|
1591
|
-
* @param isTop
|
|
1592
|
-
* @param promise
|
|
1555
|
+
* @param isTop 是否置顶
|
|
1556
|
+
* @param promise Promise对象
|
|
1593
1557
|
*/
|
|
1594
1558
|
@ReactMethod
|
|
1595
1559
|
public void setMessageTop(String messageId, ReadableMap conversationMap, boolean isTop, Promise promise) {
|
|
1596
1560
|
try {
|
|
1597
1561
|
Conversation conversation = convertMapToConversation(conversationMap);
|
|
1598
1562
|
|
|
1599
|
-
JIM.getInstance().getMessageManager().setTop(messageId, conversation, isTop,
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1563
|
+
JIM.getInstance().getMessageManager().setTop(messageId, conversation, isTop,
|
|
1564
|
+
new IMessageManager.ISimpleCallback() {
|
|
1565
|
+
@Override
|
|
1566
|
+
public void onSuccess() {
|
|
1567
|
+
promise.resolve(true);
|
|
1568
|
+
}
|
|
1604
1569
|
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1570
|
+
@Override
|
|
1571
|
+
public void onError(int errorCode) {
|
|
1572
|
+
promise.reject("error", "Error code: " + errorCode);
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1610
1575
|
} catch (Exception e) {
|
|
1611
1576
|
e.printStackTrace();
|
|
1612
1577
|
promise.reject(e);
|
|
@@ -4,6 +4,10 @@ import com.facebook.react.bridge.*;
|
|
|
4
4
|
|
|
5
5
|
import java.lang.reflect.Field;
|
|
6
6
|
import java.util.*;
|
|
7
|
+
import org.json.JSONArray;
|
|
8
|
+
import org.json.JSONException;
|
|
9
|
+
import org.json.JSONObject;
|
|
10
|
+
import java.util.Iterator;
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* 通用的 Java ↔ React Native 类型转换工具
|
|
@@ -171,4 +175,79 @@ public class RNTypeConverter {
|
|
|
171
175
|
return null;
|
|
172
176
|
}
|
|
173
177
|
}
|
|
178
|
+
|
|
179
|
+
public static WritableMap stringToWritableMap(String json) {
|
|
180
|
+
WritableMap map = new WritableNativeMap();
|
|
181
|
+
if (json == null || json.isEmpty()) return map;
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
JSONObject jsonObject = new JSONObject(json);
|
|
185
|
+
convertJsonObject(jsonObject, map);
|
|
186
|
+
} catch (JSONException e) {
|
|
187
|
+
e.printStackTrace();
|
|
188
|
+
}
|
|
189
|
+
return map;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private static void convertJsonObject(JSONObject jsonObject, WritableMap map)
|
|
193
|
+
throws JSONException {
|
|
194
|
+
|
|
195
|
+
Iterator<String> keys = jsonObject.keys();
|
|
196
|
+
while (keys.hasNext()) {
|
|
197
|
+
String key = keys.next();
|
|
198
|
+
Object value = jsonObject.get(key);
|
|
199
|
+
|
|
200
|
+
if (value == JSONObject.NULL) {
|
|
201
|
+
map.putNull(key);
|
|
202
|
+
} else if (value instanceof String) {
|
|
203
|
+
map.putString(key, (String) value);
|
|
204
|
+
} else if (value instanceof Integer) {
|
|
205
|
+
map.putInt(key, (Integer) value);
|
|
206
|
+
} else if (value instanceof Long) {
|
|
207
|
+
map.putDouble(key, ((Long) value).doubleValue());
|
|
208
|
+
} else if (value instanceof Double) {
|
|
209
|
+
map.putDouble(key, (Double) value);
|
|
210
|
+
} else if (value instanceof Boolean) {
|
|
211
|
+
map.putBoolean(key, (Boolean) value);
|
|
212
|
+
} else if (value instanceof JSONObject) {
|
|
213
|
+
WritableMap nested = new WritableNativeMap();
|
|
214
|
+
convertJsonObject((JSONObject) value, nested);
|
|
215
|
+
map.putMap(key, nested);
|
|
216
|
+
} else if (value instanceof JSONArray) {
|
|
217
|
+
WritableArray array = new WritableNativeArray();
|
|
218
|
+
convertJsonArray((JSONArray) value, array);
|
|
219
|
+
map.putArray(key, array);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private static void convertJsonArray(JSONArray jsonArray, WritableArray array)
|
|
225
|
+
throws JSONException {
|
|
226
|
+
|
|
227
|
+
for (int i = 0; i < jsonArray.length(); i++) {
|
|
228
|
+
Object value = jsonArray.get(i);
|
|
229
|
+
|
|
230
|
+
if (value == JSONObject.NULL) {
|
|
231
|
+
array.pushNull();
|
|
232
|
+
} else if (value instanceof String) {
|
|
233
|
+
array.pushString((String) value);
|
|
234
|
+
} else if (value instanceof Integer) {
|
|
235
|
+
array.pushInt((Integer) value);
|
|
236
|
+
} else if (value instanceof Long) {
|
|
237
|
+
array.pushDouble(((Long) value).doubleValue());
|
|
238
|
+
} else if (value instanceof Double) {
|
|
239
|
+
array.pushDouble((Double) value);
|
|
240
|
+
} else if (value instanceof Boolean) {
|
|
241
|
+
array.pushBoolean((Boolean) value);
|
|
242
|
+
} else if (value instanceof JSONObject) {
|
|
243
|
+
WritableMap nested = new WritableNativeMap();
|
|
244
|
+
convertJsonObject((JSONObject) value, nested);
|
|
245
|
+
array.pushMap(nested);
|
|
246
|
+
} else if (value instanceof JSONArray) {
|
|
247
|
+
WritableArray nestedArray = new WritableNativeArray();
|
|
248
|
+
convertJsonArray((JSONArray) value, nestedArray);
|
|
249
|
+
array.pushArray(nestedArray);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
174
253
|
}
|