Skip to content

Commit efc574d

Browse files
committed
UPDATE: getAllUnreadCount return same value with iOS returns & update partial doc
1 parent a6a0c54 commit efc574d

File tree

2 files changed

+90
-3
lines changed

2 files changed

+90
-3
lines changed

android/src/io/jchat/android/JMessageModule.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,10 +1710,13 @@ public void createChatRoomConversation(String roomId, Callback success) {
17101710
*/
17111711
@ReactMethod
17121712
public void getAllUnreadCount(Callback success) {
1713-
WritableMap map = Arguments.createMap();
1713+
// WritableMap map = Arguments.createMap();
17141714
int count = JMessageClient.getAllUnReadMsgCount();
1715-
map.putInt("count", count);
1716-
success.invoke(map);
1715+
// map.putInt("count", count);
1716+
if (count < 0) {
1717+
count = 0;
1718+
}
1719+
success.invoke(count);
17171720
}
17181721

17191722
@ReactMethod

document/API.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import JMessage from 'jmessage-react-plugin';
3333
- [applyJoinGroup](#applyjoingroup)
3434
- [processApplyJoinGroup](#processapplyjoingroup)
3535
- [dissolveGroup](#dissolvegroup)
36+
- [getGroupIds](#getgroupids)
37+
- [getGroupInfo](#getgroupinfo)
3638
- [聊天](#聊天)
3739
- [createSendMessage](#createsendmessage)
3840
- [sendMessage](#sendmessage)
@@ -55,6 +57,7 @@ import JMessage from 'jmessage-react-plugin';
5557
- [exitConversation](#exitconversation)
5658
- [getConversation](#getconversation)
5759
- [getConversations](#getconversations)
60+
- [getAllUnreadCount](#getallunreadcount)
5861
- [resetUnreadMessageCount](#resetunreadmessagecount)
5962
- [聊天室](#聊天室)
6063
- [getChatRoomListByApp](#getchatroomlistbyapp)
@@ -397,6 +400,65 @@ JMessage.dissolveGroup({ groupId: 'group_id' },
397400
#### 参数说明
398401
- groupId (string): 要解散的群组 id。
399402

403+
### getGroupIds
404+
405+
获取当前用户群组
406+
407+
#### 示例
408+
```js
409+
JMessage.getGroupIds(
410+
(result) => {
411+
/**
412+
* result {Array[Number]} 当前用户所加入的群组的groupID的list
413+
*/
414+
}, (error) => {
415+
/**
416+
* error {Object} {code:Number,desc:String}
417+
*/
418+
}
419+
)
420+
```
421+
422+
#### 参数说明
423+
424+
425+
426+
### getGroupInfo
427+
428+
根据群组id获取群组信息
429+
430+
#### 示例
431+
432+
```js
433+
JMessage.getGroupInfo(
434+
{ id: "1234567" },
435+
(result) => {
436+
/**
437+
* result {Object} 群组信息
438+
{
439+
desc:""
440+
id:"1234567"
441+
isBlocked:false
442+
isNoDisturb:false
443+
level:0
444+
maxMemberCount:500
445+
name:"China no 1"
446+
owner:"1234"
447+
ownerAppKey:"abcdef..."
448+
type:"group" // or single
449+
}
450+
*/
451+
}, (error) => {
452+
/**
453+
* error {Object} {code:Number,desc:String}
454+
*/
455+
}
456+
)
457+
```
458+
459+
#### 参数说明
460+
461+
- id(string): 指定群组
400462

401463
### addGroupAdmins
402464

@@ -1157,6 +1219,28 @@ JMessage.getConversations((conArr) => { // conArr: 会话数组。
11571219
})
11581220
```
11591221
1222+
### getAllUnreadCount
1223+
1224+
当前用户所有会话的未读消息总数
1225+
1226+
- ⚠️ 截止jmessage-sdk-2.6.1 返回的数量为会话列表的未读总数即包括了被移除的群组、好友的未读.
1227+
1228+
#### 示例
1229+
1230+
```js
1231+
JMessage.getAllUnreadCount(
1232+
(result) => {
1233+
/**
1234+
* result {Number} 当前用户所有会话的未读消息总数
1235+
*/
1236+
}
1237+
)
1238+
```
1239+
1240+
#### 参数说明
1241+
1242+
1243+
11601244
### resetUnreadMessageCount
11611245
11621246
重置会话的未读消息数。

0 commit comments

Comments
 (0)