juggleim-rnsdk 0.0.10 → 0.0.12

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 CHANGED
@@ -6,7 +6,7 @@ React Native wrapper for Juggle IM SDK,提供即时通讯功能的React Native
6
6
  ## 安装
7
7
 
8
8
  ```bash
9
- npm install im-rn-sdk --registry=https://repo.juggle.im/repository/npm-hosted/ --legacy-peer-deps
9
+ npm install im-rn-sdk --legacy-peer-deps
10
10
  ```
11
11
 
12
12
  ## 初始化
@@ -1082,12 +1082,11 @@ RCT_EXPORT_METHOD(getMessages:(NSDictionary *)conversationDict
1082
1082
  /**
1083
1083
  * 撤回消息
1084
1084
  */
1085
- RCT_EXPORT_METHOD(recallMessage:(NSDictionary *)messageDict
1085
+ RCT_EXPORT_METHOD(recallMessage:(NSString *)messageId
1086
1086
  extras:(NSDictionary *)extras
1087
1087
  resolver:(RCTPromiseResolveBlock)resolve
1088
1088
  rejecter:(RCTPromiseRejectBlock)reject) {
1089
1089
  @try {
1090
- NSString *messageId = messageDict[@"messageId"];
1091
1090
  NSDictionary *extrasDict = extras ?: @{};
1092
1091
 
1093
1092
  [JIM.shared.messageManager recallMessage:messageId
@@ -1095,7 +1094,7 @@ RCT_EXPORT_METHOD(recallMessage:(NSDictionary *)messageDict
1095
1094
  success:^(JMessage *message){
1096
1095
  resolve(@YES);
1097
1096
  } error:^(JErrorCode errorCode) {
1098
- reject(@"RECALL_MESSAGE_ERROR", @"撤回消息失败", [NSError errorWithDomain:@"JuggleIM" code:errorCode userInfo:nil]);
1097
+ reject(@"RECALL_MESSAGE_ERROR", [NSString stringWithFormat:@"Error code: %ld", (long)errorCode], nil);
1099
1098
  }];
1100
1099
  } @catch (NSException *exception) {
1101
1100
  reject(@"RECALL_MESSAGE_ERROR", exception.reason, nil);
@@ -1105,8 +1104,8 @@ RCT_EXPORT_METHOD(recallMessage:(NSDictionary *)messageDict
1105
1104
  /**
1106
1105
  * 根据clientMsgNo列表删除消息
1107
1106
  */
1108
- RCT_EXPORT_METHOD(deleteMessagesByClientMsgNoList:(NSArray<NSNumber *> *)clientMsgNos
1109
- conversation:(NSDictionary *)conversationMap
1107
+ RCT_EXPORT_METHOD(deleteMessagesByClientMsgNoList:(NSDictionary *)conversationMap
1108
+ clientMsgNos:(NSArray<NSNumber *> *)clientMsgNos
1110
1109
  resolver:(RCTPromiseResolveBlock)resolve
1111
1110
  rejecter:(RCTPromiseRejectBlock)reject) {
1112
1111
  @try {
@@ -1117,7 +1116,7 @@ RCT_EXPORT_METHOD(deleteMessagesByClientMsgNoList:(NSArray<NSNumber *> *)clientM
1117
1116
  success:^{
1118
1117
  resolve(@YES);
1119
1118
  } error:^(JErrorCode errorCode) {
1120
- reject(@"DELETE_MESSAGES_ERROR", @"删除消息失败", [NSError errorWithDomain:@"JuggleIM" code:errorCode userInfo:nil]);
1119
+ reject(@"DELETE_MESSAGES_ERROR", [NSString stringWithFormat:@"Error code: %ld", (long)errorCode], nil);
1121
1120
  }];
1122
1121
  } @catch (NSException *exception) {
1123
1122
  reject(@"DELETE_MESSAGES_ERROR", exception.reason, nil);
@@ -1141,7 +1140,7 @@ RCT_EXPORT_METHOD(addMessageReaction:(NSDictionary *)messageDict
1141
1140
  success:^{
1142
1141
  resolve(@YES);
1143
1142
  } error:^(JErrorCode errorCode) {
1144
- reject(@"ADD_REACTION_ERROR", @"添加反应失败", [NSError errorWithDomain:@"JuggleIM" code:errorCode userInfo:nil]);
1143
+ reject(@"ADD_REACTION_ERROR", [NSString stringWithFormat:@"Error code: %ld", (long)errorCode], nil);
1145
1144
  }];
1146
1145
  } @catch (NSException *exception) {
1147
1146
  reject(@"ADD_REACTION_ERROR", exception.reason, nil);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juggleim-rnsdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "React Native wrapper for Juggle IM SDK",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -657,12 +657,12 @@ declare module "im-rn-sdk" {
657
657
 
658
658
  /**
659
659
  * 撤回消息
660
- * @param messageIds 消息ID列表
660
+ * @param messageId 消息ID列表
661
661
  * @param extras 扩展字段
662
662
  * @returns {Promise<Boolean>} 是否撤回成功
663
663
  */
664
664
  static recallMessage(
665
- messageIds: string[],
665
+ messageId: string,
666
666
  extras?: { [key: string]: any }
667
667
  ): Promise<Boolean>;
668
668
 
package/src/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { NativeModules, Platform, NativeEventEmitter } from "react-native";
2
2
 
3
3
  const { JuggleIM: JMI } = NativeModules;
4
- // 为避免警告,仅在Android平台传入JMI参数
5
- const juggleIMEmitter = Platform.OS === 'android' ? new NativeEventEmitter(JMI) : new NativeEventEmitter();
4
+ const juggleIMEmitter = new NativeEventEmitter(JMI);
6
5
 
7
6
  /**
8
7
  * Juggle IM React Native SDK
@@ -825,11 +824,11 @@ class JuggleIM {
825
824
 
826
825
  /**
827
826
  * 撤回消息
828
- * @param {Object} message - 消息对象
827
+ * @param {String} messageId - 消息ID
829
828
  * @param {Object} extras - kv 扩展信息
830
829
  */
831
- static recallMessage(message, extras = {}) {
832
- return JMI.recallMessage(message, extras);
830
+ static recallMessage(messageId, extras = {}) {
831
+ return JMI.recallMessage(messageId, extras);
833
832
  }
834
833
 
835
834
  /**
@@ -839,11 +838,10 @@ class JuggleIM {
839
838
  * @returns {Promise<boolean>} 删除结果
840
839
  */
841
840
  static deleteMessagesByClientMsgNoList(conversation, clientMsgNos) {
842
- if (Platform.OS === "android") {
843
- return JMI.deleteMessagesByClientMsgNoList(conversation, clientMsgNos);
844
- } else if (Platform.OS === "ios") {
845
- return JMI.deleteMessagesByClientMsgNoList(conversation, clientMsgNos);
846
- }
841
+ const nums = (clientMsgNos || [])
842
+ .map(n => Number(n))
843
+ .filter(n => !isNaN(n));
844
+ return JMI.deleteMessagesByClientMsgNoList(conversation, nums);
847
845
  }
848
846
 
849
847
  /**