The Interactive Message Service SDK lets you easily implement business requirements, such as group announcements and status information, without requiring additional support from your business servers.
Procedure
Information about custom audience groups.
Set group information when you create a group.
Client API: Use the Administrator operation: Create a group API. The relevant field is GroupMeta.
Server-side OpenAPI: Use the Create a live interactive group API. The relevant field is GroupInfo.
Dynamically change group information after the group is created.
Client API: Use the Modify a group API.
Server-side OpenAPI: Use the Modify live interactive group information API.
When a client successfully joins a group, it receives the group details through the onSuccess callback function. The ImJoinGroupRsp response contains the group information.
ImJoinGroupReq req = new ImJoinGroupReq(); req.groupId = groupId; groupInterface.joinGroup(req, new ImSdkValueCallback<ImJoinGroupRsp>() { @Override public void onSuccess(ImJoinGroupRsp data) { } @Override public void onFailure(Error error) { } });When group information changes, clients receive real-time update notifications through the onInfoChange group listener. If you set this listener, all relevant clients are immediately notified of the change through a callback.
// Add a group listener groupManager.addGroupListener(new ImGroupListener() { @Override public void onMemberChange(String groupId, int memberCount, ArrayList<ImUser> joinUsers, ArrayList<ImUser> leaveUsers) { } @Override public void onExit(String groupId, int reason) { } @Override public void onMuteChange(String groupId, ImGroupMuteStatus status) { } @Override public void onInfoChange(String groupId, ImGroupInfoStatus info) { } });The ImGroupInfoStatus object in the onInfoChange callback contains the group information.
What to do next
The flexible definition of group information supports various business needs. For example, you can define the group information as a JSON string in the following format:
{ "GroupStatus": 1, // "Not started" "Message":"Live from 7 PM to 9 PM every night", ... "notice":"Be respectful" }When a user joins the group or the group information changes, the client receives the updated group information in real time.