juggleim-rnsdk 0.1.3 → 0.1.5
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/README.md +1 -1
- 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 +124 -127
- 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 +52 -36
- package/package.json +1 -1
- package/src/index.d.ts +26 -1
- package/src/index.js +23 -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) {
|
|
@@ -441,6 +445,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
441
445
|
|
|
442
446
|
// 添加是否已读
|
|
443
447
|
map.putBoolean("hasRead", message.isHasRead());
|
|
448
|
+
map.putBoolean("isEdit", message.isEdit());
|
|
449
|
+
map.putBoolean("isDeleted", message.isDelete());
|
|
444
450
|
|
|
445
451
|
// 添加群消息阅读信息
|
|
446
452
|
if (message.getGroupMessageReadInfo() != null) {
|
|
@@ -483,53 +489,10 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
483
489
|
* 将消息内容转换为Map
|
|
484
490
|
*/
|
|
485
491
|
private WritableMap convertMessageContentToMap(MessageContent content) {
|
|
486
|
-
|
|
487
|
-
String
|
|
488
|
-
Log.d("JuggleIM", "
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
if (contentType.equals("jg:text")) {
|
|
492
|
-
map.putString("content", ((TextMessage) content).getContent());
|
|
493
|
-
} else if (contentType.equals("jg:img")) {
|
|
494
|
-
ImageMessage img = (ImageMessage) content;
|
|
495
|
-
map.putString("url", img.getUrl());
|
|
496
|
-
map.putString("localPath", img.getLocalPath());
|
|
497
|
-
map.putString("thumbnailLocalPath", img.getThumbnailLocalPath());
|
|
498
|
-
map.putString("thumbnailUrl", img.getThumbnailUrl());
|
|
499
|
-
map.putInt("width", img.getWidth());
|
|
500
|
-
map.putInt("height", img.getHeight());
|
|
501
|
-
} else if (contentType.equals("jg:file")) {
|
|
502
|
-
FileMessage file = (FileMessage) content;
|
|
503
|
-
map.putString("url", file.getUrl());
|
|
504
|
-
map.putString("type", file.getType());
|
|
505
|
-
map.putString("name", file.getName());
|
|
506
|
-
map.putDouble("size", file.getSize());
|
|
507
|
-
} else if (contentType.equals("jg:voice")) {
|
|
508
|
-
VoiceMessage voice = (VoiceMessage) content;
|
|
509
|
-
map.putString("url", voice.getUrl());
|
|
510
|
-
map.putString("localPath", voice.getLocalPath());
|
|
511
|
-
map.putInt("duration", voice.getDuration());
|
|
512
|
-
} else if (contentType.equals("jgrn:custom")) {
|
|
513
|
-
GenericCustomMessage genericCustomMessage = (GenericCustomMessage) content;
|
|
514
|
-
byte[] data = genericCustomMessage.encode();
|
|
515
|
-
if (data != null) {
|
|
516
|
-
try {
|
|
517
|
-
String jsonStr = new String(data, StandardCharsets.UTF_8);
|
|
518
|
-
JSONObject jsonObject = new JSONObject(jsonStr);
|
|
519
|
-
map = convertJSONToWritableMap(jsonObject);
|
|
520
|
-
} catch (JSONException e) {
|
|
521
|
-
Log.e("JuggleIM", "解析自定义消息失败: " + e.getMessage());
|
|
522
|
-
}
|
|
523
|
-
} else {
|
|
524
|
-
Log.e("JuggleIM", "No data for contentType: " + contentType);
|
|
525
|
-
}
|
|
526
|
-
} else {
|
|
527
|
-
Log.e("JuggleIM", "Unknown contentType: " + contentType);
|
|
528
|
-
return RNTypeConverter.toWritableMap(content);
|
|
529
|
-
}
|
|
530
|
-
Log.d("JuggleIM", "convertMessageContentToMap: " + map.getString("contentType"));
|
|
531
|
-
|
|
532
|
-
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);
|
|
533
496
|
}
|
|
534
497
|
|
|
535
498
|
private MessageContent convertMapToMessageContent(ReadableMap map) {
|
|
@@ -563,7 +526,9 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
563
526
|
default:
|
|
564
527
|
// 检查是否是自定义消息
|
|
565
528
|
if (customMessageTypes.containsKey(contentType)) {
|
|
566
|
-
|
|
529
|
+
UnknownMessage msg = createUnknownMessage(map);
|
|
530
|
+
msg.setMessageType(contentType);
|
|
531
|
+
return msg;
|
|
567
532
|
}
|
|
568
533
|
Log.e("JuggleIM", "contentType: " + contentType);
|
|
569
534
|
return RNTypeConverter.fromReadableMap(map, MessageContent.class);
|
|
@@ -573,16 +538,13 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
573
538
|
/**
|
|
574
539
|
* 创建自定义消息对象
|
|
575
540
|
*/
|
|
576
|
-
private
|
|
541
|
+
private UnknownMessage createUnknownMessage(ReadableMap map) {
|
|
577
542
|
try {
|
|
578
|
-
// 将 ReadableMap 转换为 JSON
|
|
579
543
|
JSONObject jsonObject = convertReadableMapToJSON(map);
|
|
580
544
|
String jsonStr = jsonObject.toString();
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
customMsg.setData(jsonStr.getBytes(StandardCharsets.UTF_8));
|
|
585
|
-
|
|
545
|
+
UnknownMessage customMsg = new UnknownMessage();
|
|
546
|
+
customMsg.setFlags(MessageFlag.IS_SAVE.getValue() | MessageFlag.IS_COUNTABLE.getValue());
|
|
547
|
+
customMsg.setContent(jsonStr);
|
|
586
548
|
return customMsg;
|
|
587
549
|
} catch (JSONException e) {
|
|
588
550
|
Log.e("JuggleIM", "创建自定义消息失败: " + e.getMessage());
|
|
@@ -596,7 +558,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
596
558
|
private JSONObject convertReadableMapToJSON(ReadableMap map) throws JSONException {
|
|
597
559
|
JSONObject jsonObject = new JSONObject();
|
|
598
560
|
ReadableMapKeySetIterator iterator = map.keySetIterator();
|
|
599
|
-
|
|
561
|
+
|
|
600
562
|
while (iterator.hasNextKey()) {
|
|
601
563
|
String key = iterator.nextKey();
|
|
602
564
|
switch (map.getType(key)) {
|
|
@@ -620,7 +582,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
620
582
|
break;
|
|
621
583
|
}
|
|
622
584
|
}
|
|
623
|
-
|
|
585
|
+
|
|
624
586
|
return jsonObject;
|
|
625
587
|
}
|
|
626
588
|
|
|
@@ -629,7 +591,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
629
591
|
*/
|
|
630
592
|
private JSONArray convertReadableArrayToJSONArray(ReadableArray array) throws JSONException {
|
|
631
593
|
JSONArray jsonArray = new JSONArray();
|
|
632
|
-
|
|
594
|
+
|
|
633
595
|
for (int i = 0; i < array.size(); i++) {
|
|
634
596
|
switch (array.getType(i)) {
|
|
635
597
|
case Null:
|
|
@@ -652,7 +614,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
652
614
|
break;
|
|
653
615
|
}
|
|
654
616
|
}
|
|
655
|
-
|
|
617
|
+
|
|
656
618
|
return jsonArray;
|
|
657
619
|
}
|
|
658
620
|
|
|
@@ -661,7 +623,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
661
623
|
*/
|
|
662
624
|
private WritableMap convertJSONToWritableMap(JSONObject jsonObject) throws JSONException {
|
|
663
625
|
WritableMap map = new WritableNativeMap();
|
|
664
|
-
|
|
626
|
+
|
|
665
627
|
Iterator<String> iterator = jsonObject.keys();
|
|
666
628
|
while (iterator.hasNext()) {
|
|
667
629
|
String key = iterator.next();
|
|
@@ -682,7 +644,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
682
644
|
map.putNull(key);
|
|
683
645
|
}
|
|
684
646
|
}
|
|
685
|
-
|
|
647
|
+
|
|
686
648
|
return map;
|
|
687
649
|
}
|
|
688
650
|
|
|
@@ -691,10 +653,10 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
691
653
|
*/
|
|
692
654
|
private WritableArray convertJSONArrayToWritableArray(JSONArray jsonArray) throws JSONException {
|
|
693
655
|
WritableArray array = new WritableNativeArray();
|
|
694
|
-
|
|
656
|
+
|
|
695
657
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
696
658
|
Object value = jsonArray.get(i);
|
|
697
|
-
|
|
659
|
+
|
|
698
660
|
if (value instanceof JSONObject) {
|
|
699
661
|
array.pushMap(convertJSONToWritableMap((JSONObject) value));
|
|
700
662
|
} else if (value instanceof JSONArray) {
|
|
@@ -711,7 +673,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
711
673
|
array.pushNull();
|
|
712
674
|
}
|
|
713
675
|
}
|
|
714
|
-
|
|
676
|
+
|
|
715
677
|
return array;
|
|
716
678
|
}
|
|
717
679
|
|
|
@@ -774,7 +736,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
774
736
|
return map;
|
|
775
737
|
}
|
|
776
738
|
|
|
777
|
-
//conversation
|
|
739
|
+
// conversation
|
|
778
740
|
|
|
779
741
|
/**
|
|
780
742
|
* 获取会话信息列表
|
|
@@ -782,10 +744,11 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
782
744
|
@ReactMethod
|
|
783
745
|
public void getConversationInfoList(int count, double ts, int pullDirection, Promise promise) {
|
|
784
746
|
try {
|
|
785
|
-
JIMConst.PullDirection direction = pullDirection == 0 ?
|
|
786
|
-
|
|
747
|
+
JIMConst.PullDirection direction = pullDirection == 0 ? JIMConst.PullDirection.NEWER
|
|
748
|
+
: JIMConst.PullDirection.OLDER;
|
|
787
749
|
|
|
788
|
-
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);
|
|
789
752
|
Log.d("JuggleIM", "conversationInfos: " + conversationInfos.size());
|
|
790
753
|
WritableArray result = new WritableNativeArray();
|
|
791
754
|
for (ConversationInfo info : conversationInfos) {
|
|
@@ -994,7 +957,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
994
957
|
WritableMap map = new WritableNativeMap();
|
|
995
958
|
WritableArray userMap = new WritableNativeArray();
|
|
996
959
|
map.putInt("type", mentionInfo.getType().getValue());
|
|
997
|
-
if (mentionInfo.getTargetUsers() != null) {
|
|
960
|
+
if (mentionInfo.getTargetUsers() != null) {
|
|
998
961
|
for (UserInfo userInfo : mentionInfo.getTargetUsers()) {
|
|
999
962
|
userMap.pushMap(convertUserInfoToMap(userInfo));
|
|
1000
963
|
}
|
|
@@ -1032,8 +995,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1032
995
|
event.putInt("errorCode", errorCode);
|
|
1033
996
|
sendEvent("onMessageSentError", event);
|
|
1034
997
|
}
|
|
1035
|
-
}
|
|
1036
|
-
);
|
|
998
|
+
});
|
|
1037
999
|
WritableMap result = convertMessageToMap(sendMsg);
|
|
1038
1000
|
result.putString("messageId", messageId);
|
|
1039
1001
|
promise.resolve(result);
|
|
@@ -1043,7 +1005,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1043
1005
|
* 根据clientMsgNo列表删除消息
|
|
1044
1006
|
*/
|
|
1045
1007
|
@ReactMethod
|
|
1046
|
-
public void deleteMessagesByClientMsgNoList(ReadableMap conversationMap, ReadableArray clientMsgNos,
|
|
1008
|
+
public void deleteMessagesByClientMsgNoList(ReadableMap conversationMap, ReadableArray clientMsgNos,
|
|
1009
|
+
Promise promise) {
|
|
1047
1010
|
Conversation conversation = convertMapToConversation(conversationMap);
|
|
1048
1011
|
List<Long> msgNoList = new ArrayList<>();
|
|
1049
1012
|
for (int i = 0; i < clientMsgNos.size(); i++) {
|
|
@@ -1080,8 +1043,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1080
1043
|
getOptions.setStartTime((long) options.getDouble("startTime"));
|
|
1081
1044
|
}
|
|
1082
1045
|
|
|
1083
|
-
JIMConst.PullDirection pullDirection = direction == 0 ?
|
|
1084
|
-
|
|
1046
|
+
JIMConst.PullDirection pullDirection = direction == 0 ? JIMConst.PullDirection.OLDER
|
|
1047
|
+
: JIMConst.PullDirection.NEWER;
|
|
1085
1048
|
|
|
1086
1049
|
JIM.getInstance().getMessageManager().getMessages(
|
|
1087
1050
|
conversation,
|
|
@@ -1101,8 +1064,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1101
1064
|
result.putInt("code", code);
|
|
1102
1065
|
promise.resolve(result);
|
|
1103
1066
|
}
|
|
1104
|
-
}
|
|
1105
|
-
);
|
|
1067
|
+
});
|
|
1106
1068
|
} catch (Exception e) {
|
|
1107
1069
|
promise.reject("GET_MESSAGES_ERROR", e.getMessage());
|
|
1108
1070
|
}
|
|
@@ -1135,8 +1097,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1135
1097
|
public void onError(int errorCode) {
|
|
1136
1098
|
promise.reject("RECALL_MESSAGE_ERROR", errorCode + "");
|
|
1137
1099
|
}
|
|
1138
|
-
}
|
|
1139
|
-
);
|
|
1100
|
+
});
|
|
1140
1101
|
} catch (Exception e) {
|
|
1141
1102
|
promise.reject("RECALL_MESSAGE_ERROR", e.getMessage());
|
|
1142
1103
|
}
|
|
@@ -1165,8 +1126,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1165
1126
|
public void onError(int errorCode) {
|
|
1166
1127
|
promise.reject("ADD_REACTION_ERROR", errorCode + "");
|
|
1167
1128
|
}
|
|
1168
|
-
}
|
|
1169
|
-
);
|
|
1129
|
+
});
|
|
1170
1130
|
} catch (Exception e) {
|
|
1171
1131
|
promise.reject("ADD_REACTION_ERROR", e.getMessage());
|
|
1172
1132
|
}
|
|
@@ -1195,8 +1155,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1195
1155
|
public void onError(int errorCode) {
|
|
1196
1156
|
promise.reject("REMOVE_REACTION_ERROR", errorCode + "");
|
|
1197
1157
|
}
|
|
1198
|
-
}
|
|
1199
|
-
);
|
|
1158
|
+
});
|
|
1200
1159
|
} catch (Exception e) {
|
|
1201
1160
|
promise.reject("REMOVE_REACTION_ERROR", e.getMessage());
|
|
1202
1161
|
}
|
|
@@ -1213,11 +1172,13 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1213
1172
|
|
|
1214
1173
|
ReadableMap contentMap = messageMap.getMap("content");
|
|
1215
1174
|
if (contentMap.hasKey("localPath")) {
|
|
1216
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1175
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1176
|
+
contentMap.getString("localPath"));
|
|
1217
1177
|
imageMessage.setLocalPath(path);
|
|
1218
1178
|
}
|
|
1219
1179
|
if (contentMap.hasKey("thumbnailLocalPath")) {
|
|
1220
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1180
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1181
|
+
contentMap.getString("localPath"));
|
|
1221
1182
|
imageMessage.setThumbnailLocalPath(path);
|
|
1222
1183
|
}
|
|
1223
1184
|
if (contentMap.hasKey("url")) {
|
|
@@ -1271,8 +1232,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1271
1232
|
params.putMap("message", convertMessageToMap(message));
|
|
1272
1233
|
sendEvent("onMediaMessageCancelled", params);
|
|
1273
1234
|
}
|
|
1274
|
-
}
|
|
1275
|
-
);
|
|
1235
|
+
});
|
|
1276
1236
|
|
|
1277
1237
|
WritableMap result = convertMessageToMap(message);
|
|
1278
1238
|
result.putString("messageId", messageId);
|
|
@@ -1293,7 +1253,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1293
1253
|
|
|
1294
1254
|
ReadableMap contentMap = messageMap.getMap("content");
|
|
1295
1255
|
if (contentMap.hasKey("localPath")) {
|
|
1296
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1256
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1257
|
+
contentMap.getString("localPath"));
|
|
1297
1258
|
fileMessage.setLocalPath(path);
|
|
1298
1259
|
}
|
|
1299
1260
|
if (contentMap.hasKey("url")) {
|
|
@@ -1346,8 +1307,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1346
1307
|
params.putMap("message", convertMessageToMap(message));
|
|
1347
1308
|
sendEvent("onMediaMessageCancelled", params);
|
|
1348
1309
|
}
|
|
1349
|
-
}
|
|
1350
|
-
);
|
|
1310
|
+
});
|
|
1351
1311
|
|
|
1352
1312
|
WritableMap result = convertMessageToMap(message);
|
|
1353
1313
|
result.putString("messageId", messageId);
|
|
@@ -1368,7 +1328,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1368
1328
|
|
|
1369
1329
|
ReadableMap contentMap = messageMap.getMap("content");
|
|
1370
1330
|
if (contentMap.hasKey("localPath")) {
|
|
1371
|
-
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1331
|
+
String path = FileUtils.convertContentUriToFile(getReactApplicationContext(),
|
|
1332
|
+
contentMap.getString("localPath"));
|
|
1372
1333
|
voiceMessage.setLocalPath(path);
|
|
1373
1334
|
}
|
|
1374
1335
|
if (contentMap.hasKey("url")) {
|
|
@@ -1411,8 +1372,7 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1411
1372
|
WritableMap result = convertMessageToMap(message);
|
|
1412
1373
|
sendEvent("onMediaMessageCancelled", result);
|
|
1413
1374
|
}
|
|
1414
|
-
}
|
|
1415
|
-
);
|
|
1375
|
+
});
|
|
1416
1376
|
|
|
1417
1377
|
WritableMap result = convertMessageToMap(message);
|
|
1418
1378
|
promise.resolve(result);
|
|
@@ -1490,7 +1450,8 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1490
1450
|
private MessageMentionInfo convertMapToMentionInfo(ReadableMap mentionInfoMap) {
|
|
1491
1451
|
MessageMentionInfo mentionInfo = new MessageMentionInfo();
|
|
1492
1452
|
if (mentionInfoMap.hasKey("type")) {
|
|
1493
|
-
MessageMentionInfo.MentionType type = MessageMentionInfo.MentionType
|
|
1453
|
+
MessageMentionInfo.MentionType type = MessageMentionInfo.MentionType
|
|
1454
|
+
.setValue(mentionInfoMap.getInt("type"));
|
|
1494
1455
|
mentionInfo.setType(type);
|
|
1495
1456
|
}
|
|
1496
1457
|
if (mentionInfoMap.hasKey("targetUsers")) {
|
|
@@ -1522,9 +1483,10 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1522
1483
|
|
|
1523
1484
|
/**
|
|
1524
1485
|
* 发送消息已读回执
|
|
1486
|
+
*
|
|
1525
1487
|
* @param conversationMap 会话对象
|
|
1526
|
-
* @param messageIds
|
|
1527
|
-
* @param promise
|
|
1488
|
+
* @param messageIds 消息ID列表
|
|
1489
|
+
* @param promise Promise对象
|
|
1528
1490
|
*/
|
|
1529
1491
|
@ReactMethod
|
|
1530
1492
|
public void sendReadReceipt(ReadableMap conversationMap, ReadableArray messageIds, Promise promise) {
|
|
@@ -1535,17 +1497,50 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1535
1497
|
msgIdList.add(messageIds.getString(i));
|
|
1536
1498
|
}
|
|
1537
1499
|
|
|
1538
|
-
JIM.getInstance().getMessageManager().sendReadReceipt(conversation, msgIdList,
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1500
|
+
JIM.getInstance().getMessageManager().sendReadReceipt(conversation, msgIdList,
|
|
1501
|
+
new IMessageManager.ISendReadReceiptCallback() {
|
|
1502
|
+
@Override
|
|
1503
|
+
public void onSuccess() {
|
|
1504
|
+
promise.resolve(true);
|
|
1505
|
+
}
|
|
1543
1506
|
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1507
|
+
@Override
|
|
1508
|
+
public void onError(int errorCode) {
|
|
1509
|
+
promise.reject("error", "Error code: " + errorCode);
|
|
1510
|
+
}
|
|
1511
|
+
});
|
|
1512
|
+
} catch (Exception e) {
|
|
1513
|
+
e.printStackTrace();
|
|
1514
|
+
promise.reject(e);
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* 更新消息
|
|
1520
|
+
*
|
|
1521
|
+
* @param messageId 消息ID
|
|
1522
|
+
* @param contentMap 新的消息内容
|
|
1523
|
+
* @param conversationMap 会话对象
|
|
1524
|
+
* @param promise Promise对象
|
|
1525
|
+
*/
|
|
1526
|
+
@ReactMethod
|
|
1527
|
+
public void updateMessage(String messageId, ReadableMap contentMap, ReadableMap conversationMap, Promise promise) {
|
|
1528
|
+
try {
|
|
1529
|
+
MessageContent content = convertMapToMessageContent(contentMap);
|
|
1530
|
+
Conversation conversation = convertMapToConversation(conversationMap);
|
|
1531
|
+
|
|
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
|
+
}
|
|
1538
|
+
|
|
1539
|
+
@Override
|
|
1540
|
+
public void onError(int errorCode) {
|
|
1541
|
+
promise.reject("error", "Error code: " + errorCode);
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1549
1544
|
} catch (Exception e) {
|
|
1550
1545
|
e.printStackTrace();
|
|
1551
1546
|
promise.reject(e);
|
|
@@ -1554,27 +1549,29 @@ public class JuggleIMManager extends ReactContextBaseJavaModule {
|
|
|
1554
1549
|
|
|
1555
1550
|
/**
|
|
1556
1551
|
* 设置消息置顶
|
|
1557
|
-
*
|
|
1552
|
+
*
|
|
1553
|
+
* @param messageId 消息ID
|
|
1558
1554
|
* @param conversationMap 会话对象
|
|
1559
|
-
* @param isTop
|
|
1560
|
-
* @param promise
|
|
1555
|
+
* @param isTop 是否置顶
|
|
1556
|
+
* @param promise Promise对象
|
|
1561
1557
|
*/
|
|
1562
1558
|
@ReactMethod
|
|
1563
1559
|
public void setMessageTop(String messageId, ReadableMap conversationMap, boolean isTop, Promise promise) {
|
|
1564
1560
|
try {
|
|
1565
1561
|
Conversation conversation = convertMapToConversation(conversationMap);
|
|
1566
1562
|
|
|
1567
|
-
JIM.getInstance().getMessageManager().setTop(messageId, conversation, isTop,
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1563
|
+
JIM.getInstance().getMessageManager().setTop(messageId, conversation, isTop,
|
|
1564
|
+
new IMessageManager.ISimpleCallback() {
|
|
1565
|
+
@Override
|
|
1566
|
+
public void onSuccess() {
|
|
1567
|
+
promise.resolve(true);
|
|
1568
|
+
}
|
|
1572
1569
|
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1570
|
+
@Override
|
|
1571
|
+
public void onError(int errorCode) {
|
|
1572
|
+
promise.reject("error", "Error code: " + errorCode);
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1578
1575
|
} catch (Exception e) {
|
|
1579
1576
|
e.printStackTrace();
|
|
1580
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
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// JModelFactory.h
|
|
3
|
+
// juggle_im
|
|
4
|
+
//
|
|
5
|
+
// Created by Fei Li on 2025/5/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <JuggleIM/JuggleIM.h>
|
|
10
|
+
|
|
11
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
+
|
|
13
|
+
@interface JModelFactory : NSObject
|
|
14
|
+
|
|
15
|
+
+ (NSDictionary *)conversationToDic:(JConversation *)conversation;
|
|
16
|
+
+ (NSDictionary *)conversationMentionMessageToDic:(JConversationMentionMessage *)message;
|
|
17
|
+
+ (NSDictionary *)conversationMentionInfoToDic:(JConversationMentionInfo *)info;
|
|
18
|
+
+ (NSDictionary *)conversationInfoToDic:(JConversationInfo *)conversationInfo;
|
|
19
|
+
+ (NSString *)messageContentToString:(JMessageContent *)content;
|
|
20
|
+
+ (NSDictionary *)groupMessageReadInfoToDic:(JGroupMessageReadInfo *)info;
|
|
21
|
+
+ (NSDictionary *)groupMessageMemberReadDetailToDic:(JGroupMessageMemberReadDetail *)detail;
|
|
22
|
+
+ (NSDictionary *)userInfoToDic:(JUserInfo *)info;
|
|
23
|
+
+ (NSDictionary *)groupInfoToDic:(JGroupInfo *)info;
|
|
24
|
+
+ (NSDictionary *)groupMemberToDic:(JGroupMember *)member;
|
|
25
|
+
+ (NSDictionary *)messageMentionInfoToDic:(JMessageMentionInfo *)info;
|
|
26
|
+
+ (NSDictionary *)messageToDic:(JMessage *)message;
|
|
27
|
+
+ (NSDictionary *)favoriteMessageToDic:(JFavoriteMessage *)message;
|
|
28
|
+
+ (NSDictionary *)messageReactionToDic:(JMessageReaction *)reaction;
|
|
29
|
+
+ (NSDictionary *)callMemberToDic:(JCallMember *)callMember;
|
|
30
|
+
+ (NSDictionary *)callSessionToDic:(id<JCallSession>)callSession;
|
|
31
|
+
+ (NSDictionary *)callInfoToDic:(JCallInfo *)callInfo;
|
|
32
|
+
+ (NSDictionary *)searchConversationResultToDic:(JSearchConversationsResult *)result;
|
|
33
|
+
+ (NSDictionary *)momentToDic:(JMoment *)moment;
|
|
34
|
+
+ (NSDictionary *)momentMediaToDic:(JMomentMedia *)media;
|
|
35
|
+
+ (NSDictionary *)momentReactionToDic:(JMomentReaction *)reaction;
|
|
36
|
+
+ (NSDictionary *)momentCommentToDic:(JMomentComment *)comment;
|
|
37
|
+
|
|
38
|
+
+ (JConversation *)conversationFromDic:(NSDictionary *)dic;
|
|
39
|
+
+ (JMessage *)messageFromDic:(NSDictionary *)dic;
|
|
40
|
+
+ (JMessageOptions *)sendMessageOptionFromDic:(NSDictionary *)dic;
|
|
41
|
+
+ (JGetMessageOptions *)getMessageOptionFromDic:(NSDictionary *)dic;
|
|
42
|
+
+ (JMomentMedia *)momentMediaFromDic:(NSDictionary *)dic;
|
|
43
|
+
+ (JGetMomentOption *)getMomentOptionFromDic:(NSDictionary *)dic;
|
|
44
|
+
+ (JGetMomentCommentOption *)getMomentCommentOptionFromDic:(NSDictionary *)dic;
|
|
45
|
+
|
|
46
|
+
+ (JMessageContent *)messageContentFromString:(NSString *)string
|
|
47
|
+
type:(nonnull NSString *)contentType;
|
|
48
|
+
+ (JMediaMessageContent *)mediaMessageContentFromString:(NSString *)string
|
|
49
|
+
type:(NSString *)contentType;
|
|
50
|
+
|
|
51
|
+
@end
|
|
52
|
+
|
|
53
|
+
NS_ASSUME_NONNULL_END
|