Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/AgoraIO/Doc-Source-Private
Browse files Browse the repository at this point in the history
… into staging

# Conflicts:
#	shared/chat-sdk/client-api/messages/manage-messages/understand/android.mdx
#	shared/chat-sdk/reference/error-codes/android.mdx
#	shared/chat-sdk/reference/error-codes/ios.mdx
#	shared/chat-sdk/reference/error-codes/web.mdx
#	shared/chat-sdk/restful-api/_message-management.mdx
#	shared/chat-sdk/restful-api/_user-system-registration.mdx
  • Loading branch information
atovpeko committed Dec 6, 2023
2 parents 6673dbe + c57aacf commit 52015fb
Show file tree
Hide file tree
Showing 83 changed files with 2,942 additions and 560 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: 'Manage chat group member attributes'
sidebar_position: 5
type: docs
description: >
Introduces how to use the Agora Chat SDK to manage the attributes of the members of a chat group in your app.
---

import ChatGroupMemberAttributes from '@docs/shared/chat-sdk/client-api/chat-group/_manage-group-member-attributes.mdx';

export const toc = [{}];

<ChatGroupMemberAttributes PRODUCT="Chat" COMPANY="Agora" SDK="Chat SDK" CLIENT="app" />
2 changes: 1 addition & 1 deletion agora-chat/client-api/messages/retrieve-messages.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 'Retrieve messages'
title: 'Manage server-side messages'
sidebar_position: 4
type: docs
description: >
Expand Down
2 changes: 1 addition & 1 deletion agora-chat/reference/downloads.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Download the demo <Vpl k="CLIENT" /> for <Vg k="COMPANY" /> <Vg k="CHAT" /> to e


- **Demo**:
- <Link to = "https://download.agora.io/sdk/release/agorachatdemo_android_1.1.0.apk"> Agora Chat demo app for
- <Link to = "https://download.agora.io/sdk/release/agorachatdemo_android_1.2.0.apk"> Agora Chat demo app for
Android</Link>
- **Sample**:
- <Link to = "https://github.com/AgoraIO/Agora-Chat-API-Examples/tree/main/Chat-Android"> Agora Chat sample for Android</Link>
Expand Down
Binary file added assets/images/chat/chat_feature_overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/chat/message-recall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/chat/text_rule_create_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/chat/text_rule_test_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as data from '@site/data/variables';
import Understand from '@docs/shared/chat-sdk/client-api/chat-group/manage-group-member-attributes/understand/index.mdx';
import ProjectImplement from '@docs/shared/chat-sdk/client-api/chat-group/manage-group-member-attributes/project-implementation/index.mdx';

Chat groups enable real-time messaging among multiple users.

This page shows how to use the Agora Chat SDK to manage the attributes of the members of a chat group in your app.


## Understand the tech

<Understand />


## Prerequisites

Before proceeding, ensure that you meet the following requirements:

- You have initialized the Chat SDK. For details, <Link to="/agora-chat/get-started/get-started-sdk"><Vg k="GET_STARTED"/></Link>.
- You understand the call frequency limits of the Chat APIs supported by different pricing plans as described in [Limitations](/agora-chat/reference/limitations).
- You understand the number of chat groups and chat group members supported by different pricing plans as described in [Pricing Plan Details](/agora-chat/reference/pricing-plan-details).


## Implementation

This section describes how to call the APIs provided by the Chat SDK to implement chat group features.

<ProjectImplement />
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<PlatformWrapper platform="android">

### Set custom attributes of a group member via key and value items

Each chat group member can set their own attributes. Chat group admins/owners can also modify all members' attributes. Each custom attribute should be in key-value format.

Refer to the following sample code to set a custom attribute of a group member:

```java
Map<String,String> attributeMap = new HashMap<>();
attributeMap.put("nickName",nickName);

ChatClient.getInstance().groupManager().asyncSetGroupMemberAttributes(groupId, userId, attributeMap, new CallBack() {
@Override
public void onSuccess() {
}
@Override
public void onError(int code, String error) {
}
});
```

### Fetch group member custom attributes

Chat group members and group admins/owners can retrieve custom attributes of multiple group members by attribute key.

Refer to the following sample code to use the attribute key to fetch custom attributes of multiple group members:

```java
List<String> keyList = new ArrayList<>();
keyList.add("nickName");

List<String> userIds = new ArrayList<>();
userIds.add("Tom");
userIds.add("Jack");

ChatClient.getInstance().groupManager().asyncFetchGroupMembersAttributes(groupId, userIds, keyList, new ValueCallBack<Map<String, Map<String, String>>>() {
@Override
public void onSuccess(Map<String, Map<String, String>> value) {
if (value != null){
for (String user : userIds) {
Map<String,String> map = value.get(user);
if (map != null){
//……
}
}
}
}

@Override
public void onError(int code, String error) {
}
});
```

### Listen for attribute changes of a group member

`GroupChangeListener` class holds callbacks that can be used to monitor the change of any key-value items. When such a change occurs, an `onGroupMemberAttributeChanged` callback will notify the Client SDK by returning chat group ID, UID, and key-value pairs of the changes.

```java
//Create a GroupChangeListener object
GroupChangeListener groupChangeListener = new GroupChangeListener() {
@Override
public void onGroupMemberAttributeChanged(String groupId, String userId, Map<String, String> attribute, String from) {
if ( attribute != null && attribute.size() > 0){
//EMLog.d(TAG,"onGroupMemberAttributeChanged: " + groupId +" - "+ attribute.toString());
}
}
};

//Add a group change listener:
ChatClient.getInstance().groupManager().addGroupChangeListener(groupChangeListener);

//Remove a group change listener:
ChatClient.getInstance().groupManager().removeGroupChangeListener(groupChangeListener);
```

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<PlatformWrapper platform="flutter">

### Set custom attributes of a group member via key and value items

Each chat group member can set their own attributes. Chat group admins/owners can also modify all members' attributes. Each custom attribute should be in key-value format.

Refer to the following sample code to set a custom attribute of a group member:

```dart
await ChatClient.getInstance.groupManager.setMemberAttributes(
groupId: groupId,
userId: userId,
attributes: {'key': 'value'},
);
```

### Fetch group member custom attributes

Chat group members and group admins/owners can retrieve custom attributes of multiple group members by attribute key.

Refer to the following sample code to use the attribute key to fetch custom attributes of multiple group members:

```dart
Map<String, String> attribute =
await ChatClient.getInstance.groupManager.fetchMemberAttributes(
groupId: 'groupId',
userId: 'userId',
);
```


### Listen for attribute changes of a group member

`ChatGroupEventHandler` class holds callbacks that can be used to monitor the change of any key-value items. When such a change occurs, an `onAttributesChangedOfGroupMember` callback will notify the Client SDK by returning chat group ID, UID, and key-value pairs of the changes.

```dart
// Add an event handler
ChatClient.getInstance.groupManager.addEventHandler(
'UNIQUE_HANDLER_ID',
ChatGroupEventHandler(
onAttributesChangedOfGroupMember:
(groupId, userId, attributes, operatorId) {},
),
);
...
// Remove an event handler
ChatClient.getInstance.groupManager.removeEventHandler('UNIQUE_HANDLER_ID');
```

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Android from './android.mdx';
import Ios from './ios.mdx';
import Flutter from './flutter.mdx';
import ReactNative from './react-native.mdx';
import Windows from './windows.mdx';
import Web from './web.mdx';
import Unity from './unity.mdx';

<Android />
<Ios />
<Flutter />
<ReactNative />
<Windows />
<Web />
<Unity />
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<PlatformWrapper platform="ios">

### Set custom attributes of a group member via key and value items

Each chat group member can set their own attributes. Chat group admins/owners can also modify all members' attributes. Each custom attribute should be in key-value format.

Refer to the following sample code to set a custom attribute of a group member:

```objc
[AgoraChatClient.sharedClient.groupManager setMemberAttribute:@"groupId" userId:@"userId" attributes:@{@"key":@"value"} completion:^(AgoraChatError * _Nullable error) {

}];
```
### Fetch group member custom attributes
Chat group members and group admins/owners can retrieve custom attributes of multiple group members by attribute key.
Refer to the following sample code to use the attribute key to fetch custom attributes of multiple group members:
```objc
[AgoraChatClient.sharedClient.groupManager fetchMembersAttributes:@"groupId" userIds:@[@"userId1",@"userId2"] keys:@[@"key1",@"key2"] completion:^(NSDictionary<NSString *,NSDictionary<NSString *,NSString *> *> * _Nullable attributes, AgoraChatError * _Nullable error) {
}];
```


### Listen for attribute changes of a group member

`AgoraChatGroupManagerDelegate` class holds callbacks that can be used to monitor the change of any key-value items. When such a change occurs, an `onAttributesChangedOfGroupMember` callback will notify the Client SDK by returning chat group ID, UID, and key-value pairs of the changes.

```objc
- (void)onAttributesChangedOfGroupMember:(NSString *)groupId userId:(NSString *)userId attributes:(NSDictionary<NSString *,NSString *> *)attributes operatorId:(NSString *)operatorId {
}
```

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<PlatformWrapper platform="react-native">

### Set custom attributes of a group member via key and value items

Each chat group member can set their own attributes. Chat group admins/owners can also modify all members' attributes. Each custom attribute should be in key-value format.

Refer to the following sample code to set a custom attribute of a group member:

```typescript
// groupId: The group ID.
// member: The user ID of the group member.
// attributes: The custom attributes to set.
ChatClient.getInstance()
.groupManager.setMemberAttribute(groupId, member, attributes)
.then(() => {
console.log("set group members attributes success.");
})
.catch((reason) => {
console.log("set group members attributes fail.", reason);
});

```

### Fetch group member custom attributes

Chat group members and group admins/owners can retrieve custom attributes of multiple group members by attribute key.

Refer to the following sample code to use the attribute key to fetch custom attributes of multiple group members:

```typescript
// groupId: The group ID.
// member: The user ID of the group member.
ChatClient.getInstance()
.groupManager.fetchMemberAttributes(groupId, member)
.then((attributes: Record<string, string> | undefined) => {
console.log("get group members attributes success.", attributes);
})
.catch((reason) => {
console.log("get group members attributes fail.", reason);
});
```


### Listen for attribute changes of a group member

`ChatGroupEventListener` class holds callbacks that can be used to monitor the change of any key-value items. When such a change occurs, an `onMemberAttributesChanged` callback will notify the Client SDK by returning chat group ID, UID, and key-value pairs of the changes.

```typescript
onMemberAttributesChanged(params: {
groupId: string;
member: string;
attributes: any;
operator: string;
}): void {
console.log(`${QuickTestScreenBase.TAG}: onStateChanged:`, params);
this.that.setState({
recvResult: `onMemberAttributesChanged: ` + params,
});
}
```

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<PlatformWrapper platform="unity">

### Set custom attributes of a group member via key and value items

Each chat group member can set their own attributes. Chat group admins/owners can also modify all members' attributes. Each custom attribute should be in key-value format.

Refer to the following sample code to set a custom attribute of a group member:

```csharp
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("key", "value");

SDKClient.Instance.GroupManager.SetMemberAttributes(groupId, userId, dict, new CallBack(
onSuccess: () =>
{
Console.WriteLine($"SetMemberAttributes success.");
},
onError: (code, desc) =>
{
Console.WriteLine($"SetMemberAttributes failed, code:{code}, desc:{desc}");
}
));

```

### Fetch group member custom attributes

Chat group members and group admins/owners can retrieve custom attributes of multiple group members by attribute key.

Refer to the following sample code to use the attribute key to fetch custom attributes of multiple group members:

```csharp
List<string> userList = new List<string>();
userList.Add("user");

// keyList: The array of keys for custom attributes of group members. If you pass in no value or an empty array, this method retrieves all custom attributes of these group members.
List<string> keyList = new List<string>();
keyList.Add("key");

SDKClient.Instance.GroupManager.FetchMemberAttributes(groupId, userList, keyList, new ValueCallBack<Dictionary<string, Dictionary<string, string>>>(
onSuccess: (dict) =>
{

},
onError: (code, desc) =>
{

}
));
```


### Listen for attribute changes of a group member

`IGroupManagerDelegate` class holds callbacks that can be used to monitor the change of any key-value items. When such a change occurs, an `OnUpdateMemberAttributesFromGroup` callback will notify the Client SDK by returning chat group ID, UID, and key-value pairs of the changes.

```csharp

// Inherit and implement `IGroupManagerDelegate`.
public class GroupManagerDelegate : IGroupManagerDelegate {

public void OnUpdateMemberAttributesFromGroup(string groupId, string userId, Dictionary<string, string> attributes, string from)
{
}
}

// Add a delegate.
GroupManagerDelegate adelegate = new GroupManagerDelegate();
SDKClient.Instance.GroupManager.AddGroupManagerDelegate(adelegate);

// Remove the delegate when it is unnecessary.
SDKClient.Instance.GroupManager.RemoveGroupManagerDelegate(adelegate);
```

</PlatformWrapper>
Loading

0 comments on commit 52015fb

Please sign in to comment.