Skip to content

Commit 7a1ce2c

Browse files
Merge pull request #66 from jpush/dev
Dev
2 parents 2323a7a + 7ef751c commit 7a1ce2c

34 files changed

+2205
-537
lines changed
-1.43 MB
Binary file not shown.
1.55 MB
Binary file not shown.

android/src/io/jchat/android/Constant.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class Constant {
3636
public static final String SERVER_ID = "serverMessageId";
3737
public static final String MESSAGE_ID = "messageId";
3838
public static final String GROUP_ID = "groupId";
39+
public static final String GROUP_TYPE = "groupType";
3940
public static final String NAME = "name";
4041
public static final String DESC = "desc";
4142
public static final String LEVEL = "level";
@@ -47,6 +48,16 @@ public class Constant {
4748
public static final String LATEST_MESSAGE = "latestMessage";
4849
public static final String UNREAD_COUNT = "unreadCount";
4950
public static final String CONVERSATION_TYPE = "conversationType";
51+
public static final String IS_INITIATIVE_APPLY = "isInitiativeApply";
52+
public static final String SEND_APPLY_USER = "sendApplyUser";
53+
public static final String JOIN_GROUP_USERS = "joinGroupUsers";
54+
public static final String IS_AGREE = "isAgree";
55+
public static final String GROUP_ADMIN = "groupAdmin";
56+
public static final String USERS = "users";
57+
public static final String GROUP_MANAGER = "groupManager";
58+
public static final String START = "start";
59+
public static final String COUNT = "count";
60+
public static final String IS_RESPOND_INVITER = "isRespondInviter";
5061

5162
/**
5263
* Message
@@ -94,11 +105,19 @@ public class Constant {
94105
static final String PROGRESS = "progress";
95106
public static final String UNRECEIPT_COUNT = "unreceiptCount";
96107
public static final String IS_DESCEND = "isDescend";
108+
97109
/**
98110
* ChatRoom
99111
*/
100112
public static final String ROOM_ID = "roomId";
101113
public static final String ROOM_IDS = "roomIds";
102114
public static final String ROOM_NAME = "roomName";
103115
public static final String MEMBER_COUNT = "memberCount";
116+
/**
117+
* Event
118+
*/
119+
public static final String EVENT_ID = "eventId";
120+
public static final String EVENTS = "events";
121+
public static final String APPLY_EVENT_ID = "applyEventId";
122+
104123
}

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

Lines changed: 409 additions & 91 deletions
Large diffs are not rendered by default.

android/src/io/jchat/android/utils/ResultUtils.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import cn.jpush.im.android.api.enums.MessageDirect;
3535
import cn.jpush.im.android.api.model.ChatRoomInfo;
3636
import cn.jpush.im.android.api.model.Conversation;
37+
import cn.jpush.im.android.api.model.GroupBasicInfo;
3738
import cn.jpush.im.android.api.model.GroupInfo;
3839
import cn.jpush.im.android.api.model.Message;
3940
import cn.jpush.im.android.api.model.UserInfo;
@@ -119,6 +120,19 @@ public static WritableMap toJSObject(GroupInfo groupInfo) {
119120
return result;
120121
}
121122

123+
public static WritableMap toJSObject(GroupBasicInfo groupInfo) {
124+
WritableMap result = Arguments.createMap();
125+
126+
result.putString(Constant.TYPE, Constant.TYPE_GROUP);
127+
result.putString(Constant.ID, String.valueOf(groupInfo.getGroupID()));
128+
result.putString(Constant.NAME, groupInfo.getGroupName());
129+
result.putString(Constant.DESC, groupInfo.getGroupDescription());
130+
result.putInt(Constant.LEVEL, groupInfo.getGroupLevel());
131+
result.putString(Constant.AVATAR_THUMB_PATH, groupInfo.getAvatar());
132+
result.putInt(Constant.MAX_MEMBER_COUNT, groupInfo.getMaxMemberCount());
133+
return result;
134+
}
135+
122136
public static WritableMap toJSObject(Message msg) {
123137
WritableMap result = Arguments.createMap();
124138
try {
@@ -169,6 +183,7 @@ public static WritableMap toJSObject(Message msg) {
169183
case file:
170184
result.putString(Constant.TYPE, Constant.FILE);
171185
FileContent fileContent = (FileContent) content;
186+
result.putString(Constant.PATH, fileContent.getLocalPath());
172187
result.putString(Constant.FILE_NAME, fileContent.getFileName());
173188
break;
174189
case custom:
@@ -200,6 +215,9 @@ public static WritableMap toJSObject(Message msg) {
200215
//群成员退群事件
201216
result.putString(Constant.EVENT_TYPE, "group_member_exit");
202217
break;
218+
case group_info_updated:
219+
result.putString(Constant.EVENT_TYPE, "group_info_updated");
220+
break;
203221
}
204222
default:
205223
return null;
@@ -277,6 +295,8 @@ public static WritableArray toJSArray(List list) {
277295
array.pushMap(toJSObject((UserInfo) object));
278296
} else if (object instanceof GroupInfo) {
279297
array.pushMap(toJSObject((GroupInfo) object));
298+
} else if (object instanceof GroupBasicInfo) {
299+
array.pushMap(toJSObject((GroupBasicInfo) object));
280300
} else if (object instanceof Message) {
281301
array.pushMap(toJSObject((Message) object));
282302
} else if (object instanceof Conversation) {

document/API.md

Lines changed: 238 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ import JMessage from 'jmessage-react-plugin';
2323
- [updateMyInfo](#updatemyinfo)
2424
- [downloadThumbUserAvatar](#downloadthumbuseravatar)
2525
- [downloadOriginalUserAvatar](#downloadoriginaluseravatar)
26+
27+
- [群组](#群组)
28+
- [createGroup](#creategroup)
29+
- [addGroupAdmins](#addgroupadmins)
30+
- [removeGroupAdmins](#removegroupadmins)
31+
- [changeGroupType](#changegrouptype)
32+
- [getPublicGroupInfos](#getpublicgroupinfos)
33+
- [applyJoinGroup](#applyjoingroup)
34+
- [processApplyJoinGroup](#processapplyjoingroup)
35+
- [dissolveGroup](#dissolvegroup)
2636
- [聊天](#聊天)
2737
- [createSendMessage](#createsendmessage)
2838
- [sendMessage](#sendmessage)
@@ -82,6 +92,21 @@ import JMessage from 'jmessage-react-plugin';
8292
- [登录状态变更](#addloginstatechangedlistener)
8393
- [addLoginStateChangedListener](#addloginstatechangedlistener)
8494
- [removeLoginStateChangedListener](#addloginstatechangedlistener)
95+
96+
- [监听接收入群申请事件](#addreceiveapplyjoingroupapprovallistener)
97+
- [addReceiveApplyJoinGroupApprovalListener](#addreceiveapplyjoingroupapprovallistener)
98+
- [removeReceiveApplyJoinGroupApprovalListener](#removereceiveapplyjoingroupapprovallistener)
99+
100+
- [监听管理员拒绝入群申请事件](#addreceivegroupadminrejectlistener)
101+
- [addReceiveGroupAdminRejectListener](#addreceivegroupadminrejectlistener)
102+
- [removeReceiveGroupAdminRejectListener](#removereceivegroupadminrejectlistener)
103+
104+
- [监听管理员同意入群申请事件](#addreceivegroupadminapprovallistener)
105+
- [addReceiveGroupAdminApprovalListener](#addreceivegroupadminapprovallistener)
106+
- [removeReceiveGroupAdminApprovalListener](#removereceivegroupadminapprovallistener)
107+
108+
109+
85110
- [点击消息通知事件(Android Only)](#addclickmessagenotificationlistener)
86111
- [addClickMessageNotificationListener](#addclickmessagenotificationlistener)
87112
- [removeClickMessageNotificationListener](#addclickmessagenotificationlistener)
@@ -347,8 +372,151 @@ JMessage.createGroup({ name: 'group_name', desc: 'group_desc' },
347372

348373
#### 参数说明
349374

350-
- name: 群组名。不支持 "\n" 和 "\r" 字符,长度限制为 0 ~ 64 Byte。
351-
- desc: 群组描述。长度限制为 0 ~ 250 Byte。
375+
- name (string): 群组名。不支持 "\n" 和 "\r" 字符,长度限制为 0 ~ 64 Byte。
376+
- groupType (string): 指定创建群的类型,可以为 'private' 和 'public', 默认为 private。
377+
- desc (string): 群组描述。长度限制为 0 ~ 250 Byte。
378+
379+
380+
### dissolveGroup
381+
382+
解散群
383+
384+
#### 示例
385+
```js
386+
JMessage.dissolveGroup({ groupId: 'group_id' },
387+
() => { //
388+
// do something.
389+
390+
}, (error) => {
391+
var code = error.code
392+
var desc = error.description
393+
})
394+
```
395+
396+
#### 参数说明
397+
- groupId (string): 要解散的群组 id。
398+
399+
400+
### addGroupAdmins
401+
402+
批量添加管理员
403+
404+
#### 示例
405+
```js
406+
JMessage.addGroupAdmins({ groupId: 'group_id', usernames: ['ex_username1', 'ex_username2'] },
407+
() => { //
408+
// do something.
409+
410+
}, (error) => {
411+
var code = error.code
412+
var desc = error.description
413+
})
414+
```
415+
416+
#### 参数说明
417+
- groupId (string): 指定操作的群 groupId。
418+
- usernames (array<string>): 被添加的的用户名数组。
419+
420+
### removeGroupAdmins
421+
422+
批量删除管理员
423+
424+
#### 示例
425+
```js
426+
JMessage.removeGroupAdmins({ groupId: 'group_id', usernames: ['ex_username1', 'ex_username2'] },
427+
() => { //
428+
// do something.
429+
430+
}, (error) => {
431+
var code = error.code
432+
var desc = error.description
433+
})
434+
```
435+
436+
#### 参数说明
437+
- groupId (string): 指定操作的群 groupId。
438+
- usernames (array<string>): 被移除的的用户名数组。
439+
440+
### changeGroupType
441+
442+
修改群类型
443+
444+
#### 示例
445+
```js
446+
JMessage.changeGroupType({ groupId: 'group_id', type: 'public' },
447+
() => { //
448+
// do something.
449+
450+
}, (error) => {
451+
var code = error.code
452+
var desc = error.description
453+
})
454+
```
455+
456+
#### 参数说明
457+
- groupId (string): 指定操作的群 groupId。
458+
- type (string): 要修改的类型可以为如下值 'private' | 'public'
459+
460+
### getPublicGroupInfos
461+
462+
分页获取指定 appKey 下的共有群
463+
464+
#### 示例
465+
```js
466+
JMessage.getPublicGroupInfos({ appKey: 'my_appkey', start: 0, count: 20 },
467+
(groudArr) => { //group = [{GroupInfo}]
468+
// do something.
469+
470+
}, (error) => {
471+
var code = error.code
472+
var desc = error.description
473+
})
474+
```
475+
476+
#### 参数说明
477+
- appKey (string): 获取指定 appkey
478+
- start (int): 开始的位置
479+
- count (int): 获取的数量
480+
481+
### applyJoinGroup
482+
483+
申请入群(公开群)
484+
485+
#### 示例
486+
```js
487+
JMessage.applyJoinGroup({ appKey: 'group_id', reason: 'Hello I from ...' },
488+
() => {
489+
// do something.
490+
491+
}, (error) => {
492+
var code = error.code
493+
var desc = error.description
494+
})
495+
```
496+
497+
#### 参数说明
498+
499+
### processApplyJoinGroup
500+
501+
批量处理入群(公开群)申请
502+
503+
#### 示例
504+
```js
505+
JMessage.processApplyJoinGroup({ events: ['ex_event_id_1', 'ex_event_id_2'], reason: 'Hello I from ...' },
506+
() => {
507+
// do something.
508+
509+
}, (error) => {
510+
var code = error.code
511+
var desc = error.description
512+
})
513+
```
514+
515+
#### 参数说明
516+
- events (array<string>): eventId 数组,当有用户申请入群的时候(或者被要求)会回调一个 event(通过 addReceiveApplyJoinGroupApprovalListener 监听),每个 event 会有个 id,用于审核入群操作。
517+
- reason (string): 入群理由。
518+
519+
352520

353521
## 聊天
354522

@@ -1464,3 +1632,71 @@ JMessage.removeUploadProgressListener(listener) // 移除监听(一般在 compon
14641632
- result
14651633
- messageId:消息 id。
14661634
- progress:上传进度,从 0-1 float 类型。
1635+
1636+
### 群组事件
1637+
1638+
#### addReceiveApplyJoinGroupApprovalListener
1639+
1640+
监听接收入群申请事件
1641+
1642+
##### 示例
1643+
1644+
```javascript
1645+
var listener = (result) => { }
1646+
1647+
JMessage.addReceiveApplyJoinGroupApprovalListener(listener) // 添加监听
1648+
JMessage.removeReceiveApplyJoinGroupApprovalListener(listener) // 移除监听(一般在 componentWillUnmount 中调用)
1649+
```
1650+
1651+
##### 回调参数说明
1652+
1653+
- event
1654+
- eventId (string):消息 id。
1655+
- groupId (string):申请入群的 groudId。
1656+
- isInitiativeApply (boolean):是否是用户主动申请入群,YES:主动申请加入,NO:被邀请加入
1657+
- sendApplyUser ([{UserInfo}]):发送申请的用户
1658+
- reason (string):入群原因
1659+
1660+
#### addReceiveGroupAdminRejectListener
1661+
1662+
监听管理员拒绝入群申请事件
1663+
1664+
##### 示例
1665+
1666+
```javascript
1667+
var listener = (result) => { }
1668+
1669+
JMessage.addReceiveGroupAdminRejectListener(listener) // 添加监听
1670+
JMessage.removeReceiveGroupAdminRejectListener(listener) // 移除监听(一般在 componentWillUnmount 中调用)
1671+
```
1672+
1673+
##### 回调参数说明
1674+
1675+
- result
1676+
- eventId (string): 消息 id。
1677+
- rejectReason (string): 拒绝原因。
1678+
- groupManager ({UserInfo}): 操作的管理员
1679+
1680+
1681+
#### addReceiveGroupAdminApprovalListener
1682+
1683+
监听管理员同意入群申请事件
1684+
1685+
##### 示例
1686+
1687+
```javascript
1688+
var listener = (result) => { }
1689+
1690+
JMessage.addReceiveGroupAdminApprovalListener(listener) // 添加监听
1691+
JMessage.removeReceiveGroupAdminApprovalListener(listener) // 移除监听(一般在 componentWillUnmount 中调用)
1692+
```
1693+
1694+
##### 回调参数说明
1695+
1696+
- result
1697+
- isAgreeApply (boolean): 管理员是否同意申请,YES:同意,NO:拒绝.
1698+
- applyEventID (string): 申请入群事件的事件 id.
1699+
- groupId (string): 群 gid.
1700+
- groupAdmin {GroupInfo}: 操作的管理员.
1701+
- users [{UserInfo}]: 申请或被邀请加入群的用户,即:实际入群的用户
1702+

document/Models.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [FileMessage](#filemessage)
1313
- [CustomMessage](#custommessage)
1414
- [EventMessage](#eventmessage)
15+
1516

1617
## UserInfo
1718

@@ -38,15 +39,16 @@ isFriend:boolean // 是否为好友
3839
```js
3940
type: 'group',
4041
id: string, // 群组 id
41-
avatarThumbPath: string, // 头像的缩略图地址
42+
groupType: string, // 'public' | 'private' 公共群和私有群
43+
avatarThumbPath: string, // 头像的缩略图地址,不过不存在可以调用 下载缩略图的相关接口
4244
name: string, // 群组名称
4345
desc: string, // 群组描述
44-
level: number, // 群组等级,默认等级 4
45-
owner: string, // 群主的 username
46-
ownerAppKey: string, // 群主的 appKey
46+
level?: number, // 群组等级,默认等级 4
47+
owner?: string, // 群主的 username
48+
ownerAppKey?: string, // 群主的 appKey
4749
maxMemberCount: number, // 最大成员数
48-
isNoDisturb: boolean, // 是否免打扰
49-
isBlocked: boolean // 是否屏蔽群消息
50+
isNoDisturb?: boolean, // 是否免打扰
51+
isBlocked?: boolean // 是否屏蔽群消息
5052
```
5153

5254
## ChatRoomInfo

0 commit comments

Comments
 (0)