类和枚举

更新时间: 2024/09/14 17:52:42

本文介绍网易云信即时通讯 SDK(简称 NIM SDK)客户端接口类和枚举信息。

支持平台

Android iOS macOS/Windows Web/uni-app/小程序 HarmonyOS
✔️ ✔️ ✔️ ✔️ ✔️

V2NIMSuccessCallback

操作成功回调对象。

Android
Javapublic interface V2NIMSuccessCallback<T> {
    void onSuccess(T t);
}
iOS
Objective-Ctypedef void (^V2NIMSuccessCallback)(void);
macOS/Windows
C++template <typename T>
class V2NIMSuccessCallback : public nstd::function<void(T)> {
public:
    using nstd::function<void(T)>::function;
    using nstd::function<void(T)>::operator=;
    using nstd::function<void(T)>::operator();
    V2NIMSuccessCallback<T>(nstd::function<void(T)> func)
        : nstd::function<void(T)>(func) {}
};

template <>
class V2NIMSuccessCallback<void> : public nstd::function<void()> {
public:
    using nstd::function<void()>::function;
    using nstd::function<void()>::operator=;
    using nstd::function<void()>::operator();
    V2NIMSuccessCallback<void>(nstd::function<void()> func)
        : nstd::function<void()>(func) {}
};

成员函数

onSuccess

操作成功回调。

参数名称 类型 说明
value T 回调数据类型

V2NIMFailureCallback

操作失败回调对象。

Android
Javapublic interface V2NIMFailureCallback {
    void onFailure(V2NIMError error);
}
iOS
Objective-Ctypedef void (^V2NIMFailureCallback)(V2NIMError *error);
macOS/Windows
C++using V2NIMFailureCallback = nstd::function<void(V2NIMError error)>;

成员函数

onFailed

操作失败回调。

参数名称 类型 说明
error V2NIMError 回调错误详情

V2NIMProgressCallback

操作进度回调对象。

Android
Javapublic interface V2NIMProgressCallback {
    // progress int
    // 进度回调 取值范围[0,100],表示百分比
    // 100 表示上传成功
    // 0 表示未开始上传
    void onProgress(int progress);
}
iOS
Objective-Ctypedef void (^V2NIMProgressCallback)(NSUInteger);
macOS/Windows
C++using V2NIMProgressCallback = nstd::function<void(uint32_t progress)>;
Web/uni-app/小程序
TypeScriptexport type V2NIMProgressCallback = (progress: { [key: string]: any }) => void
HarmonyOS
TypeScriptexport type V2NIMProgressCallback = (progress: number) => void

成员函数

onProgress

操作进度回调。

参数名称 类型 说明
progress int 操作进度,取值范围 [0,100],100 表示操作成功,0 表示未开始。

V2NIMError

错误信息。具体错误码请参考 API 错误码文档

参数名称 类型 说明
code int 错误码
desc String 错误描述
detail Map 错误详情,用于补充上下文细节。

V2NIMLoginOption

登录配置参数。

Android
Javapublic class V2NIMLoginOption {

    public Integer getRetryCount() {
        return retryCount;
    }

    public void setRetryCount(Integer retryCount) {
        this.retryCount = retryCount;
    }

    public long getTimeout() {
        return timeout;
    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    public boolean getForceMode() {
        return forceMode;
    }

    public void setForceMode(boolean forceMode) {
        this.forceMode = forceMode;
    }

    public V2NIMLoginAuthType getAuthType() {
        return authType;
    }

    public void setAuthType(V2NIMLoginAuthType authType) {
        this.authType = authType;
    }

    public V2NIMTokenProvider getTokenProvider() {
        return tokenProvider;
    }

    public void setTokenProvider(V2NIMTokenProvider tokenProvider) {
        this.tokenProvider = tokenProvider;
    }

    public V2NIMLoginExtensionProvider getLoginExtensionProvider() {
        return loginExtensionProvider;
    }

    public void setLoginExtensionProvider(V2NIMLoginExtensionProvider loginExtensionProvider) {
        this.loginExtensionProvider = loginExtensionProvider;
    }

    public V2NIMDataSyncLevel getSyncLevel() {
        return syncLevel;
    }

    public void setSyncLevel(V2NIMDataSyncLevel syncLevel) {
        this.syncLevel = syncLevel;
    }
}
iOS
Objective-C@interface V2NIMLoginOption : NSObject

@property(nonatomic,assign) NSInteger retryCount;

@property(nonatomic,assign) NSInteger timeout;

@property(nonatomic,assign) BOOL forceMode;

@property(nonatomic,assign) V2NIMLoginAuthType authType;

@property(nullable,nonatomic,strong) id<V2NIMTokenProvider> tokenProvider;

@property(nullable,nonatomic,strong) id<V2NIMLoginExtensionProvider> loginExtensionProvider;

@property(nonatomic,assign) V2NIMDataSyncLevel syncLevel;

@end
macOS/Windows
C++struct V2NIMLoginOption {
    uint32_t retryCount{3};
    uint64_t timeout{V2NIM_DEFAULT_LOGIN_TIMEOUT};
    bool forceMode{false};
    V2NIMLoginAuthType authType{V2NIM_LOGIN_AUTH_TYPE_DEFAULT};
    V2NIMTokenProvider tokenProvider{nullptr};
    V2NIMLoginExtensionProvider loginExtensionProvider{nullptr};
    V2NIMDataSyncLevel syncLevel{V2NIM_DATA_SYNC_LEVEL_FULL};
};
Web/uni-app/小程序
TypeScriptexport type V2NIMLoginOption = {
  retryCount?: number
  timeout?: number
  forceMode?: boolean
  authType?: V2NIMLoginAuthType
  loginExtensionProvider?: (accountId: string) => Promise<string> | string
  tokenProvider?: (accountId: string) => Promise<string> | string
  syncLevel?: V2NIMDataSyncLevel
}
HarmonyOS
TypeScriptexport interface V2NIMLoginOption {

  retryCount?: number
  timeout?: number
  forceMode?: boolean
  authType?: V2NIMLoginAuthType
  loginExtensionProvider?: V2NIMLoginExtensionProvider
  tokenProvider?: V2NIMTokenProvider
  syncLevel?: V2NIMDataSyncLevel
}

成员参数

名称 类型 是否必填 默认值 说明
retryCount int 3 登录失败后,重试登录的次数。
若登录成功后因网络原因断开连接,则不限次数重连。
timeout int 60000 登录超时时间,单位毫秒。
系统会在超时时间内重试登录,重试次数最大为 retryCount

forceMode

Bool

false

多端登录互踢时,是否强制登录:

  • true:强制登录模式。设置为该模式后,如果在 网易云信控制台 上配置了 多端登录互踢策略,则无论本端是否为登录存续状态(未登出但退出应用),登录成功时将其他在线设备端踢下线。
  • false:非强制登录模式。设置为该模式后,如果在 网易云信控制台 上配置了 多端登录互踢策略
  • 如果本段为登录存续状态,本端登录失败且返回 417 错误码(禁止多端登录)。此时可决定再次登录并设置强制登录模式或放弃登录。
  • 如果本段为非登录存续状态,则登录成功时将其他在线设备端踢下线。
authType V2NIMLoginAuthType 0 鉴权方式,包括静态 Token 鉴权(默认)、动态 Token 鉴权、通过第三方回调鉴权。
tokenProvider V2NIMTokenProvider 否,若使用动态 Token 鉴权则为必填 - 获取动态 Token 回调,用于动态 Token 登录鉴权。该回调在登录连接完成、登录鉴权校验前触发。若函数执行有异常或返回非预期内容(非法字符串),则登录中止并报错。
loginExtensionProvider V2NIMLoginExtensionProvider 否,若使用第三方回调鉴权则为必填 - 获取用户登录业务扩展数据回调,用于第三方登录鉴权。该回调在登录连接完成、登录鉴权校验前触发。若函数执行有异常或返回非预期内容(非法字符串),则登录中止并报错。
syncLevel V2NIMDataSyncLevel - 数据同步模式,分为完全同步和基础数据同步。Web 端仅支持完全同步。

V2NIMTokenProvider

获取动态 Token 回调。

Android
Javapublic interface V2NIMTokenProvider {
    String getToken(String account);
}
iOS
Objective-C@protocol V2NIMTokenProvider <NSObject>

- (nullable NSString *)getToken:(NSString *)accountId;

@end
macOS/Windows
C++using V2NIMTokenProvider = nstd::function<nstd::optional<nstd::string>(nstd::string accountId)>;
Web/uni-app/小程序
TypeScriptexport type V2NIMTokenProvider = (accountId: string) => Promise<string> | string
HarmonyOS
TypeScriptexport type V2NIMTokenProvider = (accountId: string) => Promise<string> | string

成员参数

如果您的应用平台为 Android 或 iOS,则需要调用对应的成员函数获取对应参数。

名称 类型 说明
accountId String 登录账号

V2NIMLoginExtensionProvider

用户登录业务扩展数据回调。

Android
Javapublic interface V2NIMLoginExtensionProvider {
    String getLoginExtension(String accountId);
}
iOS
Objective-C@protocol V2NIMLoginExtensionProvider <NSObject>

- (nullable NSString *)getLoginExtension:(NSString *)accountId;

@end
macOS/Windows
C++using V2NIMLoginExtensionProvider = nstd::function<nstd::optional<nstd::string>(nstd::string accountId)>;
Web/uni-app/小程序
TypeScriptexport type V2NIMLoginExtensionProvider = (accountId: string) => Promise<string> | string
HarmonyOS
TypeScriptexport type V2NIMLoginExtensionProvider = (accountId: string) => Promise<string> | string

成员参数

如果您的应用平台为 Android 或 iOS,则需要调用对应的成员函数获取对应参数。

名称 类型 说明
accountId String 登录账号

V2NIMLoginClient

当前处于登录状态的客户端信息。

Android
Javapublic interface V2NIMLoginClient {
    V2NIMLoginClientType getType();

    String getOs();

    long getTimestamp();

    String getCustomTag();

    int getCustomClientType();

    String getClientId();
}
iOS
Objective-C@interface V2NIMLoginClient : NSObject

@property(nonatomic,assign,readonly) V2NIMLoginClientType type;

@property(nullable,nonatomic,copy,readonly) NSString *os;

@property(nonatomic,assign,readonly) NSTimeInterval timestamp;

@property(nullable,nonatomic,copy,readonly) NSString *customTag;

@property(nonatomic,assign,readonly) NSInteger customClientType;

@property(nullable,nonatomic,copy,readonly) NSString *clientId;

@end
macOS/Windows
C++struct V2NIMLoginClient {
    V2NIMLoginClientType type{V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN};
    nstd::string os;
    uint64_t timestamp{0};
    nstd::string customTag;
    uint32_t customClientType{0};
    nstd::string clientId;
};
Web/uni-app/小程序
TypeScriptexport type V2NIMLoginClient = {
  type: V2NIMLoginClientType
  os: string
  timestamp: number
  customTag?: string
  customClientType?: number
  clientId: string
}
HarmonyOS
TypeScriptexport interface V2NIMLoginClient {
  type: V2NIMLoginClientType
  os: string
  timestamp: number
  customTag?: string
  customClientType?: number
  clientId: string
}

成员参数

参数名称 类型 是否只读 默认值 说明
type V2NIMLoginClientType - 客户端类型。
os String - 客户端操作系统。
timestamp long - 客户端登录时间戳。
customTag String - 自定义标签,不得超过 32 个字符。可以通过该参数对不同终端设备进行区分。
customClientType int 0 自定义客户端类型,小于或等于 0 表示无自定义类型。
clientId String - 客户端 ID,客户端唯一标识。

V2NIMReconnectDelayProvider

登录重连延时回调对象。

Android
Javapublic interface V2NIMReconnectDelayProvider {
    long getReconnectDelay(long delay);
}
iOS
Objective-C@protocol V2NIMReconnectDelayProvider <NSObject>

- (nullable uint32_t *)getReconnectDelay:(uint32_t *)delay;

@end
macOS/Windows
C++using V2NIMReconnectDelayProvider = nstd::function<nstd::optional<nstd::int>(nstd::int delay)>;
Web/uni-app/小程序
TypeScriptexport type V2NIMReconnectDelayProvider = (delay: number) => number
HarmonyOS
TypeScriptexport type V2NIMReconnectDelayProvider = (delay: number) => number

成员参数

如果平台为 Android 或 iOS,则需要通过成员函数 getReconnectDelay 获取登录重连延时。

参数名称 类型 是否必填 默认值 说明
delay 视平台而定 - 登录重连延时。

返回值

登录重连延时时间,单位为毫秒。

V2NIMKickedOfflineDetail

登录客户端被踢详细信息。

Android
Javapublic interface V2NIMKickedOfflineDetail {
    V2NIMKickedOfflineReason getReason();

    String getReasonDesc();

    V2NIMLoginClientType getClientType();

    Integer getCustomClientType();
}
iOS
Objective-C@interface V2NIMKickedOfflineDetail : NSObject

@property(nonatomic,assign,readonly) V2NIMKickedOfflineReason reason;
@property(nullable,nonatomic,copy,readonly) NSString *reasonDesc;
@property(nonatomic,assign,readonly) V2NIMLoginClientType clientType;
@property(nonatomic,assign,readonly) NSInteger customClientType;

@end
macOS/Windows
C++struct V2NIMKickedOfflineDetail {
    V2NIMKickedOfflineReason reason{V2NIM_KICKED_OFFLINE_REASON_CLIENT_EXCLUSIVE};
    nstd::string reasonDesc;
    V2NIMLoginClientType clientType{V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN};
    uint32_t customClientType{0};
};
Web/uni-app/小程序
TypeScriptexport type V2NIMKickedOfflineDetail = {
  reason: V2NIMKickedOfflineReason
  reasonDesc: string
  clientType: V2NIMLoginClientType
  customClientType: number
}
HarmonyOS
TypeScriptexport interface V2NIMKickedOfflineDetail {
  reason: V2NIMKickedOfflineReason
  reasonDesc: string
  clientType: V2NIMLoginClientType
  customClientType: number
}

成员参数

如果平台为 Android,则需要通过成员函数 getReconnectDelay 获取登录重连延时。

参数名称 类型 是否必填 默认值 说明
reason V2NIMKickedOfflineReason - - 客户端被踢原因类型。
reasonDesc String - - 客户端被踢原因详情。
clientType V2NIMLoginClientType - - 踢端的客户端类型。
customClientType int - - 踢端自定义客户端类型。

V2NIMDataSyncDetail

数据同步状态详细信息。

Android
Javapublic interface V2NIMDataSyncDetail {
    V2NIMDataSyncType getType();
    V2NIMDataSyncState getState();
}
iOS
Objective-C@interface V2NIMDataSyncDetail : NSObject

@property(nonatomic,assign,readonly) V2NIMDataSyncType type;
@property(nonatomic,assign,readonly) V2NIMDataSyncState state;

@end
macOS/Windows
C++struct V2NIMDataSyncDetail {
    V2NIMDataSyncType type{V2NIM_DATA_SYNC_MAIN};
    V2NIMDataSyncState state{V2NIM_DATA_SYNC_STATE_WAITING};
};
Web/uni-app/小程序
TypeScriptexport type V2NIMDataSyncDetail = {

  type: V2NIMDataSyncType
  state: V2NIMDataSyncState
}
HarmonyOS
TypeScriptexport interface V2NIMDataSyncDetail {

  type: V2NIMDataSyncType
  state: V2NIMDataSyncState
}

成员参数

参数名称 类型 是否必填 默认值 说明
type V2NIMDataSyncType - - 同步数据类型。
state V2NIMDataSyncState - - 同步数据状态类型。

V2NIMLoginListener

登录相关监听器。

Android
Javapublic interface V2NIMLoginListener {

    void onLoginStatus(V2NIMLoginStatus status);

    void onLoginFailed(V2NIMError error);

    void onKickedOffline(V2NIMKickedOfflineDetail detail);

    void onLoginClientChanged(V2NIMLoginClientChange change, List<V2NIMLoginClient> clients);
}
iOS
Objective-C@protocol V2NIMLoginListener <NSObject>

@optional

- (void)onLoginStatus:(V2NIMLoginStatus)status;

- (void)onLoginFailed:(V2NIMError *)error;

- (void)onKickedOffline:(V2NIMKickedOfflineDetail *)detail;

- (void)onLoginClientChanged:(V2NIMLoginClientChange)change
                     clients:(nullable NSArray<V2NIMLoginClient *> *)clients;

@end
macOS/Windows
C++struct V2NIMLoginListener {
    nstd::function<void(V2NIMLoginStatus)> onLoginStatus;
    nstd::function<void(V2NIMError)> onLoginFailed;
    nstd::function<void(V2NIMKickedOfflineDetail)> onKickedOffline;
    nstd::function<void(V2NIMLoginClientChange, nstd::vector<V2NIMLoginClient>)> onLoginClientChanged;
    /// @internal
    bool operator==(const V2NIMLoginListener& other) const {
        return onLoginStatus == other.onLoginStatus && onLoginFailed == other.onLoginFailed && onKickedOffline == other.onKickedOffline &&
               onLoginClientChanged == other.onLoginClientChanged;
    }
};
Web/uni-app/小程序
TypeScriptexport type V2NIMLoginListener = {

  onLoginStatus: [status: V2NIMLoginStatus]
  onLoginFailed: [error: V2NIMError]
  onKickedOffline: [detail: V2NIMKickedOfflineDetail]
  onLoginClientChanged: [change: V2NIMLoginClientChange, clients: V2NIMLoginClient[]]
  onConnectStatus: [status: V2NIMConnectStatus]
  onDisconnected: [error: V2NIMError]
  onConnectFailed: [error: V2NIMError]
  onDataSync: [type: V2NIMDataSyncType, state: V2NIMDataSyncState, error?: V2NIMError]
}
HarmonyOS
TypeScriptexport interface V2NIMLoginListener extends NIMEBaseListener {

  onLoginStatus: [status: V2NIMLoginStatus]
  onLoginFailed: [error: V2NIMError]
  onKickedOffline: [detail: V2NIMKickedOfflineDetail]
  onLoginClientChanged: [change: V2NIMLoginClientChange, clients: V2NIMLoginClient[]]
  onConnectStatus: [status: V2NIMConnectStatus]
  onDisconnected: [error: V2NIMError]
  onConnectFailed: [error: V2NIMError]
  onDataSync: [type: V2NIMDataSyncType, state: V2NIMDataSyncState, error?: V2NIMError]
}

成员函数

  • onLoginStatus

    登录状态变化回调。

    参数名称 类型 说明
    status V2NIMLoginStatus 登录状态
  • onLoginFailed

    登录失败回调。

    参数名称 类型 说明
    error V2NIMError 登录失败错误码及错误信息
  • onKickedOffline

    客户端被踢回调。

    参数名称 类型 说明
    detail V2NIMKickedOfflineDetail 客户端被踢详细信息
  • onLoginClientChanged

    多端登录时,其他在线客户端登录状态变化回调。

    参数名称 类型 说明
    change V2NIMLoginClientChange 其他客户端登录状态变更原因
    clients List<V2NIMLoginClient> 其他客户端登录状态变更具体信息

V2NIMLoginDetailListener

登录连接状态监听器。

Android
Javapublic interface V2NIMLoginDetailListener {

    void onConnectStatus(V2NIMConnectStatus status);

    void onDisconnected(V2NIMError error);

    void onConnectFailed(V2NIMError error);

    void onDataSync(V2NIMDataSyncType type, V2NIMDataSyncState state, V2NIMError error);
}
iOS
Objective-C@protocol V2NIMLoginDetailListener <NSObject>

@optional

- (void)onConnectStatus:(V2NIMConnectStatus)status;

- (void)onDisconnected:(nullable V2NIMError *)error;

- (void)onConnectFailed:(nullable V2NIMError *)error;

- (void)onDataSync:(V2NIMDataSyncType)type
             state:(V2NIMDataSyncState)state
             error:(nullable V2NIMError *)error;

@end
macOS/Windows
C++struct V2NIMLoginDetailListener {
    nstd::function<void(V2NIMConnectStatus)> onConnectStatus;
    nstd::function<void(nstd::optional<V2NIMError>)> onDisconnected;
    nstd::function<void(V2NIMError)> onConnectFailed;
    nstd::function<void(V2NIMDataSyncType, V2NIMDataSyncState, nstd::optional<V2NIMError>)> onDataSync;
    bool operator==(const V2NIMLoginDetailListener& other) const {
        return onConnectStatus == other.onConnectStatus && onDisconnected == other.onDisconnected && onConnectFailed == other.onConnectFailed &&
               onDataSync == other.onDataSync;
    }
};
Web/uni-app/小程序

web 端不区分 detail 事件,所以上文的 V2NIMLoginListener 包含 detail 相关的事件

HarmonyOS

HarmonyOS 不区分 detail 事件,所以上文的 V2NIMLoginListener 包含 detail 相关的事件

成员函数

  • onConnectStatus

    登录连接状态变化回调。

    参数名称 类型 说明
    status V2NIMConnectStatus 登录连接状态
  • onDisconnected

    登录连接断开回调。

    参数名称 类型 说明
    error V2NIMError 登录连接断开错误码及错误信息
  • onConnectFailed

    登录连接失败回调。

    参数名称 类型 说明
    error V2NIMError 登录连接失败错误码及错误信息
  • onDataSync

    数据同步状态变化回调。

    参数名称 类型 说明
    type V2NIMDataSyncType 数据同步类型
    state V2NIMDataSyncState 数据同步状态
    error V2NIMError 数据同步失败错误码及错误信息

V2NIMConversationOption

云端会话查询选项。

Android
Javapublic class V2NIMConversationOption {
    private List<V2NIMConversationType> conversationTypes = null;
    private boolean onlyUnread = false;
    private List<String> conversationGroupIds = null;

    public V2NIMConversationOption() {}

    public V2NIMConversationOption(List<V2NIMConversationType> conversationTypes) {
        this.conversationTypes = conversationTypes;
    }

    public V2NIMConversationOption(List<V2NIMConversationType> conversationTypes, boolean onlyUnread) {
        this.conversationTypes = conversationTypes;
        this.onlyUnread = onlyUnread;
    }
}
    public V2NIMConversationOption(List<V2NIMConversationType> conversationTypes, boolean onlyUnread, List<String> conversationGroupIds) {
        this.conversationTypes = conversationTypes;
        this.onlyUnread = onlyUnread;
        this.conversationGroupIds = conversationGroupIds;
    }

    public List<V2NIMConversationType> getConversationTypes() {
        return conversationTypes;
    }

    public void setConversationTypes(List<V2NIMConversationType> conversationTypes) {
        this.conversationTypes = conversationTypes;
    }

    public boolean isOnlyUnread() {
        return onlyUnread;
    }

    public void setOnlyUnread(boolean onlyUnread) {
        this.onlyUnread = onlyUnread;
    }

    public List<String> getConversationGroupIds() {
        return conversationGroupIds;
    }

    public void setConversationGroupIds(List<String> conversationGroupIds) {
        this.conversationGroupIds = conversationGroupIds;
    }

    public void setOnlyUnread(boolean onlyUnread) {
        this.onlyUnread = onlyUnread;
    }

    public List<String> getConversationGroupIds() {
        return conversationGroupIds;
    }

    @Override
    public String toString() {
        return "V2NIMConversationOption{" +
                "conversationTypes=" + conversationTypes +
                ", onlyUnread=" + onlyUnread +
                ", conversationGroupIds=" + conversationGroupIds +
                '}';
    }
}
iOS
Objective-C@interface V2NIMConversationOption : NSObject

@property(nullable,nonatomic,copy,readwrite) NSArray<NSNumber *> *conversationTypes;

@property(nonatomic,assign,readwrite) BOOL onlyUnread;

@property(nullable,nonatomic,copy,readwrite) NSArray<NSString *> *conversationGroupIds;

@end
macOS/Windows
C++struct V2NIMConversationOption {
    nstd::vector<V2NIMConversationType> conversationTypes;
    nstd::optional<nstd::vector<nstd::string>> conversationGroupIds;
    bool onlyUnread{false};
};
Web/uni-app/小程序
TypeScriptexport type V2NIMConversationOption = {
  conversationTypes?: V2NIMConversationType[]
  onlyUnread?: boolean
  conversationGroupIds?: string[]
}
HarmonyOS
TypeScriptexport interface V2NIMConversationOption {
  conversationTypes?: V2NIMConversationType[]
  onlyUnread?: boolean
  conversationGroupIds?: string[]
}

成员参数

名称 类型 是否必填 默认值 说明
conversationTypes List<V2NIMConversationType> [] 或 null 会话类型,null 表示不限制会话类型。
onlyUnread Bool false 是否仅查询未读会话:
  • true:仅查询未读会话
  • false:查询所有会话。
  • conversationGroupIds Optional<List> null 会话分组 ID 列表。null 表示查询所有会话分组,empty 表示查询未添加到会话分组的会话。

    V2NIMConversationResult

    云端会话查询结果。

    Android
    Javapublic interface V2NIMConversationResult extends Serializable {
        long getOffset();
    
        boolean isFinished();
    
        List<V2NIMConversation> getConversationList();
    }
    
    iOS
    Objective-C@interface V2NIMConversationResult : NSObject
    
    @property(nonatomic,assign,readonly) long long cursor;
    
    @property(nonatomic,assign,readonly) BOOL finished;
    
    @property(nullable,nonatomic,copy,readonly) NSArray<V2NIMConversation *> *conversationList;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversationResult {
        uint64_t offset{0};
        bool finished{false};
        V2NIMConversationList conversationList;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationResult = {
      offset: number
      finished: boolean
      conversationList: V2NIMConversation[]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMConversationResult {
      offset: number
      finished: boolean
      conversationList: V2NIMConversation[]
    }
    

    成员参数

    名称 类型 是否只读 说明
    offset long 分页偏移。
    finished Bool 数据是否获取完毕:
  • true:获取完毕
  • false:未获取完毕,需要继续调用方法获取。
  • conversationList List<V2NIMConversation> 会话对象列表。

    V2NIMConversation

    云端会话对象。

    Android
    Javapublic interface V2NIMConversation extends Serializable {
    
        String getConversationId();
    
        V2NIMConversationType getType();
    
        String getName();
    
        String getAvatar();
    
        boolean isMute();
    
        boolean isStickTop();
    
        List<String> getGroupIds();
    
        String getLocalExtension();
    
        String getServerExtension();
    
        V2NIMMessage getLastMessage();
    
        int getUnreadCount();
    
        long getOrder();
    
        long getCreateTime();
    
        long getUpdateTime();
    
    }
    
    iOS
    Objective-C@interface V2NIMConversation : NSObject <NSCopying>
    
    @property(nonatomic,copy,readonly) NSString *conversationId;
    
    @property(nonatomic,assign,readonly) V2NIMConversationType type;
    
    @property(nullable,nonatomic,copy,readonly) NSString *name;
    
    @property(nullable,nonatomic,copy,readonly) NSString *avatar;
    
    @property(nonatomic,assign,readonly) BOOL mute;
    
    @property(nonatomic,assign,readonly) BOOL stickTop;
    
    @property(nullable,nonatomic,copy,readonly) NSArray<NSString *> *grpupIds;
    
    @property(nullable,nonatomic,copy,readonly) NSString *localExtension;
    
    @property(nullable,nonatomic,copy,readonly) NSString *serverExtension;
    
    @property(nullable,nonatomic,copy,readonly) V2NIMMessage *lastMessage;
    
    @property(nonatomic,assign,readonly) NSInteger unreadCount;
    
    @property(nonatomic,assign,readonly) NSTimeInterval orderTime;
    
    @property(nonatomic,assign,readonly) NSTimeInterval createTime;
    
    @property(nonatomic,assign,readonly) NSTimeInterval updateTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversation {
        nstd::string conversationId;
        V2NIMConversationType type{V2NIM_CONVERSATION_TYPE_UNKNOWN};
        nstd::optional<nstd::string> name;
        nstd::optional<nstd::string> avatar;
        nstd::optional<bool> mute;
        bool stickTop{false};
        nstd::vector<nstd::string> groupIds;
        nstd::string localExtension;
        nstd::string serverExtension;
        V2NIMMessage lastMessage;
        uint32_t unreadCount{0};
        uint64_t sortOrder{0};
        uint64_t createTime{0};
        uint64_t updateTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversation = {
      conversationId: string
      type: V2NIMConversationType
      name?: string
      avatar?: string
      mute?: boolean
      stickTop: boolean
      groupIds?: string[]
      localExtension: string
      serverExtension: string
      lastMessage?: V2NIMMessage
      unreadCount: number
      sortOrder: number
      createTime: number
      updateTime: number
    }
    
    HarmonyOS
    TypeScript/**
     * v2 会话结构
     */
    export interface V2NIMConversation {
    
      conversationId: string
      type: V2NIMConversationType
      name?: string
      avatar?: string
      mute?: boolean
      stickTop: boolean
      groupIds?: string[]
      localExtension?: string
      serverExtension: string
      lastMessage?: V2NIMLastMessage
      unreadCount: number
      sortOrder: number
      createTime: number
      updateTime: number
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    conversationId String - 会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    type V2NIMConversationType V2NIM_CONVERSATION_TYPE_UNKNOWN 会话类型。
    name String null 会话名称。
  • 如果会话类型为单聊,则为聊天对象的用户名(好友备注/用户名称/用户账号)。
  • 如果会话类型为群组或超大群,则为群组名(群组名称/群组 ID)。
  • avatar String null 会话头像。
  • 如果会话类型为单聊,则为聊天对象的头像。
  • 如果会话类型为群组或超大群,则为群组头像。
  • mute boolean null 会话是否为静音状态。
    stickTop boolean false 会话是否为置顶状态。
    groupIds List<String> null 会话所属分组列表。
    localExtension String "" 会话本地扩展字段,不会多端同步。长度上限为 1024 字节。如果平台为 Web,该字段仅在当前实例生命周期内有效。
    serverExtension String "" 会话服务端扩展字段,多端同步。长度上限为 1024 字节。
    lastMessage V2NIMLastMessage null 会话中最后一条消息。
    unreadCount int 0 会话消息未读数。
    createTime long 0 会话创建时间戳(毫秒)
    updateTime long 0 会话更新时间戳(毫秒)
    sortOrder long 0 会话排序字段。默认将置顶会话排首位,如有多条置顶会话,则按其创建时间进行排序。

    V2NIMConversationFilter

    云端会话过滤器对象。

    Android
    Javapublic class V2NIMConversationFilter {
    
        private List<V2NIMConversationType> conversationTypes = null;
        private String conversationGroupId = null;
        private boolean ignoreMuted = false;
        private Set<V2NIMConversationType> conversationTypeSet = null;
    
        public V2NIMConversationFilter() {
        }
    
        public V2NIMConversationFilter(List<V2NIMConversationType> types) {
            this.conversationTypes = types;
            if (types != null) {
                this.conversationTypeSet = new HashSet<>(types);
            }
        }
    }
    
    public class V2NIMConversationFilter {
    
        private List<V2NIMConversationType> conversationTypes;
        private Set<V2NIMConversationType> conversationTypeSet;
        private String conversationGroupId;
        private boolean ignoreMuted;
    
        public V2NIMConversationFilter(List<V2NIMConversationType> types, String groupId) {
            this.conversationTypes = types;
            if (types != null) {
                this.conversationTypeSet = new HashSet<>(types);
            }
            this.conversationGroupId = groupId;
        }
    
        public V2NIMConversationFilter(List<V2NIMConversationType> types, String groupId, boolean ignoreMuted) {
            this.conversationTypes = types;
            if (types != null) {
                this.conversationTypeSet = new HashSet<>(types);
            }
            this.conversationGroupId = groupId;
            this.ignoreMuted = ignoreMuted;
        }
    
        public List<V2NIMConversationType> getConversationTypes() {
            return conversationTypes;
        }
    }
    
        public Set<V2NIMConversationType> getConversationTypeSet() {
            if(CollectionUtil.isNotEmpty(conversationTypes) && CollectionUtil.isEmpty(conversationTypeSet)) {
                conversationTypeSet = new HashSet<>(conversationTypes);
            }
            return conversationTypeSet;
        }
    
        public void setConversationTypes(List<V2NIMConversationType> conversationTypes) {
            this.conversationTypes = conversationTypes;
        }
    
        public String getConversationGroupId() {
            return conversationGroupId;
        }
    
        public void setConversationGroupId(String conversationGroupId) {
            this.conversationGroupId = conversationGroupId;
        }
    
        public boolean isIgnoreMuted() {
            return ignoreMuted;
        }
    
        public void setIgnoreMuted(boolean ignoreMuted) {
            this.ignoreMuted = ignoreMuted;
        }
    
        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (!(o instanceof V2NIMConversationFilter)) {
                return false;
            }
            V2NIMConversationFilter that = (V2NIMConversationFilter) o;
            return ignoreMuted == that.ignoreMuted && Objects.equals(conversationGroupId, that.conversationGroupId) && Objects.equals(getConversationTypeSet(), that.getConversationTypeSet());
        }
    
        @Override
        public int hashCode() {
            return Objects.hash(conversationGroupId, ignoreMuted, getConversationTypeSet());
        }
    
        @Override
        public String toString() {
            return "V2NIMConversationFilter{" +
                    "conversationTypes=" + conversationTypes +
                    ", conversationGroupId='" + conversationGroupId + '\'' +
                    ", ignoreMuted=" + ignoreMuted +
                    '}';
        }
    
        public boolean isValid() {
            return !CollectionUtil.isEmpty(conversationTypes) || !TextUtils.isEmpty(conversationGroupId) || ignoreMuted;
        }
    }
    
    iOS
    Objective-C@interface V2NIMConversationFilter : NSObject <NSCopying>
    
    @property(nullable,nonatomic,copy,readwrite) NSArray<NSNumber *> *conversationTypes;
    
    @property(nullable,nonatomic,copy,readwrite) NSArray<NSString *> *conversationGroupIds;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversationFilter {
        nstd::set<V2NIMConversationType> conversationTypes;
        nstd::string conversationGroupId;
        bool ignoreMuted{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationFilter = {
      conversationTypes?: V2NIMConversationType[]
      conversationGroupId?: string
      ignoreMuted?: boolean
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMConversationFilter {
      conversationTypes?: V2NIMConversationType[]
      conversationGroupId?: string
      ignoreMuted?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    conversationTypes List null 会话类型列表,null 表示不按照会话类型过滤。
    conversationGroupId String null 会话分组 ID,null 表示不按照会话 ID 过滤。
    ignoreMuted Bool false 是否过滤具有免打扰属性(mutetrue)的会话对象:
  • true:过滤免打扰的会话
  • false:不过滤免打扰的会话。
  • V2NIMConversationOperationResult

    单条云端会话操作结果。

    Android
    Javapublic interface V2NIMConversationOperationResult {
        String getConversationId();
        V2NIMError getError();
    }
    
    macOS/Windows
    C++struct V2NIMConversationOperationResult {
        nstd::string conversationId;
        V2NIMError error;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationOperationResult = {
      conversationId: string
      error: V2NIMError
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMConversationOperationResult {
      conversationId: string
      error: V2NIMError
    }
    

    成员参数

    名称 类型 是否只读 说明
    conversationId String 操作失败的会话 ID。如果操作成功则为空。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    error V2NIMError 操作失败的错误码和错误信息,如果操作成功,则为空。

    V2NIMConversationUpdate

    云端会话更新对象。

    Android
    Javapublic class V2NIMConversationUpdate {
        private String serverExtension;
    
        public V2NIMConversationUpdate() {
        }
    
        public V2NIMConversationUpdate(String serverExtension) {
            this.serverExtension = serverExtension;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        public void setServerExtension(String serverExtension) {
            this.serverExtension = serverExtension;
        }
    }
    
    iOS
    Objective-C@interface V2NIMConversationUpdate : NSObject
    
    @property(nullable,nonatomic,copy,readwrite) NSString *serverExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversationUpdate {
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationUpdate = {
      serverExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMConversationUpdate {
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    serverExtension String "" 服务端扩展字段,多端同步。长度上限为 1024 字节。

    V2NIMConversationListener

    云端会话相关监听器。

    调用 addConversationListener 注册会话监听后,当会话相关事件发生时,会返回对应回调。

    Android
    Javapublic interface V2NIMConversationListener {
        void onSyncStarted();
        void onSyncFinished();
        void onSyncFailed(V2NIMError error);
        void onConversationCreated(V2NIMConversation conversation);
        void onConversationDeleted(List<String> conversationIds);
        void onConversationChanged(List<V2NIMConversation> conversationList);
        void onTotalUnreadCountChanged(int unreadCount);
        void onUnreadCountChangedByFilter(V2NIMConversationFilter filter, int unreadCount);
        void onConversationReadTimeUpdated(String conversationId, long readTime);
    }
    
    iOS
    Objective-C@protocol V2NIMConversationListener
    
    @optional
    
    - (void)onSyncStarted;
    
    - (void)onSyncFinished;
    
    - (void)onSyncFailed:(V2NIMError *)error;
    
    - (void)onConversationCreated:(V2NIMConversation *)conversation;
    
    - (void)onConversationDeleted:(NSArray<NSString *> *)conversationIds;
    
    - (void)onConversationChanged:(NSArray<V2NIMConversation *> *)conversations;
    
    - (void)onTotalUnreadCountChanged:(NSInteger)unreadCount;
    
    - (void)onUnreadCountChangedByFilter:(V2NIMConversationFilter *)filter
                             unreadCount:(NSInteger)unreadCount;
    
    - (void)onConversationReadTimeUpdated:(NSString *)conversationId
                                 readTime:(NSTimeInterval)readTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversationListener {
        nstd::function<void()> onSyncStarted;
        nstd::function<void()> onSyncFinished;
        nstd::function<void(V2NIMError error)> onSyncFailed;
        nstd::function<void(V2NIMConversation conversation)> onConversationCreated;
        nstd::function<void(nstd::vector<nstd::string> conversationIds)> onConversationDeleted;
        nstd::function<void(nstd::vector<V2NIMConversation> conversationList)> onConversationChanged;
        nstd::function<void(uint32_t unreadCount)> onTotalUnreadCountChanged;
        nstd::function<void(V2NIMConversationFilter filter, uint32_t unreadCount)> onUnreadCountChangedByFilter;
        nstd::function<void(const nstd::string& conversationId, time_t readTime)> onConversationReadTimeUpdated;
    };
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationListener = {
      onSyncStarted: []
      onSyncFinished: []
      onSyncFailed: [error: V2NIMError]
      onConversationCreated: [conversation: V2NIMConversation]
      onConversationDeleted: [conversationIds: string[]]
      onConversationChanged: [conversationList: V2NIMConversation[]]
      onTotalUnreadCountChanged: [unreadCount: number]
      onUnreadCountChangedByFilter: [
        filter: V2NIMConversationFilter & {
          equals: (filter: V2NIMConversationFilter) => boolean
        },
        unreadCount: number
      ]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMConversationListener extends NIMEBaseListener {
      onSyncStarted: []
      onSyncFinished: []
      onSyncFailed: [error: V2NIMError]
      onConversationCreated: [conversation: V2NIMConversation]
      onConversationDeleted: [conversationIds: string[]]
      onConversationChanged: [conversationList: V2NIMConversation[]]
      onTotalUnreadCountChanged: [unreadCount: number]
      onUnreadCountChangedByFilter: [
        filter: V2NIMConversationUnreadCountChangedFilter,
        unreadCount: number
      ]
    }
    

    成员函数

    • onSyncStarted

      会话数据同步开始回调。

    • onSyncFinished

      会话数据同步结束回调。

      请在收到该回调之后进行会话相关操作,否则可能导致会话数据不完整。

    • onSyncFailed

      会话数据同步失败回调。

      如果在收到该回调之后进行会话相关操作,会话数据可能不完整。

      参数名称 类型 说明
      error V2NIMError 会话数据同步失败错误码及错误信息
    • onConversationCreated

      会话成功创建回调。
      当本地端或多端同步创建会话成功时会触发该回调。

      参数名称 类型 说明
      conversation V2NIMConversation 创建的会话对象。
    • onConversationDeleted

      主动删除会话回调。
      当本地端或多端同步删除会话成功时会触发该回调。

      参数名称 类型 说明
      conversation V2NIMConversation 删除的会话对象。
    • onConversationChanged

      会话变更回调。
      当本地端或多端同步置顶会话、设置会话免打扰、会话有新消息、主动更新会话成功时会触发该回调。

      参数名称 类型 说明
      conversationList List<V2NIMConversation> 变更的会话对象列表
    • onTotalUnreadCountChanged

      会话消息总未读数变更回调。

      参数名称 类型 说明
      unreadCount int 变更后的会话消息总未读数
    • onUnreadCountChangedByFilter

      会话过滤后的未读数变更回调。
      调用 subscribeUnreadCountByFilter 订阅监听后,当会话过滤后的未读数变化时会返回该回调。

      参数名称 类型 说明
      filter V2NIMConversationFilter 会话过滤对象
      unreadCount int 会话过滤后的消息未读数
    • onConversationReadTimeUpdated

      同一账号多端登录后的会话已读时间戳标记的回调。

      当某一账号分别登录设备 A 和 B,A 的会话已读时间戳标记会同步到 B。

      参数名称 类型 说明
      conversationId String 同步标记的会话 ID
      readTime Long 标记的时间戳

    V2NIMConversationGroup

    会话分组对象。

    Android
    Javapublic interface V2NIMConversationGroup extends Serializable {
    
        String getGroupId();
    
        String getName();
    
        String getServerExtension();
    
        long getCreateTime();
    
        long getUpdateTime();
    
    }
    
    iOS
    Objective-C@interface V2NIMConversationGroup : NSObject <NSCopying>
    
    @property(nullable,nonatomic,copy,readonly) NSString *groupId;
    
    @property(nullable,nonatomic,copy,readonly) NSString *name;
    
    @property(nullable,nonatomic,copy,readonly) NSString *serverExtension;
    
    @property(nonatomic,assign,readonly) NSTimeInterval createTime;
    
    @property(nonatomic,assign,readonly) NSTimeInterval updateTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversationGroup {
        nstd::string groupId;
        nstd::string name;
        nstd::optional<nstd::string> serverExtension;
        uint64_t createTime{0};
        uint64_t updateTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationGroup = {
      groupId: string
      name: string
      serverExtension: string
      createTime: number
      updateTime: number
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMConversationGroup = {
    
      groupId: string
      name: string
      serverExtension: string
      createTime: number
      updateTime: number
    }
    

    成员参数

    名称 类型 是否只读 说明
    groupId String 会话分组 ID
    name String 会话分组名称。
    serverExtension String 会话服务端扩展字段。必须为 JSON 格式封装,长度上限为 1024 字节,多端同步。
    createTime long 会话分组创建时间戳(毫秒)
    updateTime long 会话分组更新时间戳(毫秒)

    V2NIMConversationGroupResult

    会话分组操作结果对象。

    Android
    Javapublic interface V2NIMConversationGroupResult {
    
        V2NIMConversationGroup getGroup();
    
        List<V2NIMConversationOperationResult> getFailedList();
    }
    
    iOS
    Objective-C@interface V2NIMConversationGroupResult : NSObject
    
    @property(nullable,nonatomic,copy,readonly) V2NIMConversationGroup *group;
    
    @property(nullable,nonatomic,copy,readonly) NSArray<V2NIMConversationOperationResult *> *failedList;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversationGroupResult {
        V2NIMConversationGroup group;
        nstd::vector<V2NIMConversationOperationResult> failedList;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationGroupResult = {
      group: V2NIMConversationGroup
      failedList: V2NIMConversationOperationResult[]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMConversationGroupResult = {
    
      group: V2NIMConversationGroup
      failedList: V2NIMConversationOperationResult[]
    }
    

    成员参数

    名称 类型 是否只读 说明
    group V2NIMConversationGroup 会话分组。
    failedList List<V2NIMConversationOperationResult> 失败结果列表,包含操作失败的会话分组列表和错误信息。

    V2NIMConversationGroupListener

    会话分组相关监听器。

    调用 addConversationGroupListener 注册会话分组监听后,当会话分组相关事件发生时,会返回对应回调。

    Android
    Javapublic interface V2NIMConversationGroupListener {
        void onConversationGroupCreated(V2NIMConversationGroup conversationGroup, List<V2NIMConversation> conversations);
        void onConversationGroupDeleted(String groupId);
        void onConversationGroupChanged(V2NIMConversationGroup group);
        void onConversationsAddedToGroup(String groupId, List<V2NIMConversation> conversations);
        void onConversationsRemovedFromGroup(String groupId, List<String> conversationIds);
    }
    
    iOS
    Objective-C@protocol V2NIMConversationGroupListener
    
    @optional
    
    - (void)onConversationGroupCreated:(V2NIMConversationGroup *)conversationGroup;
    
    - (void)onConversationGroupDeleted:(NSString *)groupId;
    
    - (void)onConversationGroupChanged:(V2NIMConversationGroup *)conversationGroup;
    
    - (void)onConversationsAddedToGroup:(NSString *)groupId
                          conversations:(NSArray<V2NIMConversation *> *)conversations;
    
    - (void)onConversationsRemovedFromGroup:(NSString *)groupId
                            conversationIds:(NSArray<NSString *> *)conversationIds;
    
    @end
    
    macOS/Windows
    C++struct V2NIMConversationGroupListener {
        nstd::function<void(V2NIMConversationGroup conversationGroup)> onConversationGroupCreated;
        nstd::function<void(nstd::string groupId)> onConversationGroupDeleted;
        nstd::function<void(V2NIMConversationGroup conversationGroup)> onConversationGroupChanged;
        nstd::function<void(nstd::string groupId, V2NIMConversationList conversationList)> onConversationsAddedToGroup;
        nstd::function<void(nstd::string groupId, nstd::vector<nstd::string> conversationIds)> onConversationsRemovedFromGroup;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMConversationGroupListener = {
    
      onConversationGroupCreated: [conversationGroup: V2NIMConversationGroup]
      onConversationGroupDeleted: [groupId: string]
      onConversationGroupChanged: [conversationGroup: V2NIMConversationGroup]
      onConversationsAddedToGroup: [groupId: string, list: V2NIMConversation[]]
      onConversationsRemovedFromGroup: [groupId: string, list: string[]]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMConversationGroupListener extends NIMEBaseListener {
    
      onConversationGroupCreated: [conversationGroup: V2NIMConversationGroup]
      onConversationGroupDeleted: [groupId: string]
      onConversationGroupChanged: [conversationGroup: V2NIMConversationGroup]
      onConversationsAddedToGroup: [groupId: string, list: V2NIMConversation[]]
      onConversationsRemovedFromGroup: [groupId: string, list: string[]]
    }
    

    成员函数

    • onConversationGroupCreated

      会话分组成功创建回调。 当本地端或多端同步创建会话分组成功时会触发该回调。

      参数名称 类型 说明
      conversationGroup V2NIMConversationGroup 创建的会话分组对象
    • onConversationGroupDeleted

      主动删除会话分组回调。 当本地端或多端同步删除会话分组成功时会触发该回调。

      参数名称 类型 说明
      groupId String 删除的会话分组 ID
    • onConversationGroupChanged

      会话分组变更回调。 当本地端或多端同步更新会话分组成功时会触发该回调。

      参数名称 类型 说明
      conversationGroup V2NIMConversationGroup 变更的会话分组对象
    • onConversationsAddedToGroup

      添加会话到会话分组回调。 当本地端或多端同步添加会话到分组成功时会触发该回调。

      参数名称 类型 说明
      groupId String 会话分组 ID
      conversations List<V2NIMConversation> 添加到分组的会话对象列表。
    • onConversationsRemovedFromGroup

      会话从分组移除回调。 当本地端或多端同步移除会话成功时会触发该回调。

      参数名称 类型 说明
      groupId String 会话分组 ID
      conversationIds List<String> 移除的会话 ID 列表

    V2NIMConversationIdUtil

    会话 ID 构建工具。

    成员函数

    • p2pConversationId

      构造单聊会话 ID。

      参数名称 类型 说明
      accountId String 聊天对象账号
    • teamConversationId

      构造群聊(高级群)会话 ID。

      参数名称 类型 说明
      teamId String 高级群的群组 ID
    • superTeamConversationId

      构造群聊(超大群)会话 ID。

      参数名称 类型 说明
      superTeamId String 超大群的群组 ID
    • parseConversationType

      解析会话类型。提取拼接的中间段。

      参数名称 类型 说明
      conversationId String 会话 ID
    • parseConversationType

      解析会话类型。提取拼接的中间段。

      参数名称 类型 说明
      conversationId String 会话 ID

      返回值:V2NIMConversationType

    • parseConversationType

      解析会话目标账号。提取拼接的最后一段。

      参数名称 类型 说明
      conversationId String 会话 ID

      返回值:String targetId

    示例代码

    Android
    Javapublic final class V2NIMConversationIdUtil {
    
     /**
      * 生成会话 ID
      * @param targetId 目标 ID
      * @param type 会话类型
      * @return 会话 ID
      */
     public static String conversationId(String targetId, V2NIMConversationType type) {
      if(!SDKCache.isV2Api())
      {
       return null;
      }
      if (TextUtils.isEmpty(targetId) || type == null) {
       return null;
      }
      String account = SDKCacheUI.getAccount();
      if(TextUtils.isEmpty(account))
      {
       return null;
      }
      return String.format(Locale.ENGLISH,CONVERSATION_ID_FORMAT, account, type.getValue(), targetId);
     }
    
     public static String conversationId(String sessionId, SessionTypeEnum type) {
      switch (type){
       case P2P:
        return p2pConversationId(sessionId);
       case Team:
        return teamConversationId(sessionId);
       case SUPER_TEAM:
        return superTeamConversationId(sessionId);
       default:
        return null;
      }
     }
    
     /**
      * 生成 p2p 会话 ID
      * @param accountId 对方账号 ID
      * @return 会话 ID
      */
     public static String p2pConversationId(String accountId){
      return conversationId(accountId, V2NIMConversationType.V2NIM_CONVERSATION_TYPE_P2P);
     }
    
     /**
      * 生成 team 会话 ID
      * @param teamId 群 ID
      * @return 会话 ID
      */
     public static String teamConversationId(String teamId){
      return conversationId(teamId, V2NIMConversationType.V2NIM_CONVERSATION_TYPE_TEAM);
     }
    
     /**
      * 生成 superTeam 会话 ID
      * @param superTeamId 超大群 ID
      * @return 会话 ID
      */
     public static String superTeamConversationId(String superTeamId){
      return conversationId(superTeamId, V2NIMConversationType.V2NIM_CONVERSATION_TYPE_SUPER_TEAM);
     }
    
     /**
      * 根据会话 ID 返回会话类型
      * @param conversationId 会话 ID
      * @return 会话类型
      */
     public static V2NIMConversationType conversationType(String conversationId) {
      if (TextUtils.isEmpty(conversationId)) {
       return V2NIMConversationType.V2NIM_CONVERSATION_TYPE_UNKNOWN;
      }
      String[] components = conversationId.split(CONVERSATION_ID_SPLIT);
      // 3 parts
      if (components.length != 3) {
       return V2NIMConversationType.V2NIM_CONVERSATION_TYPE_UNKNOWN;
      }
      // account and target
    
      if (TextUtils.isEmpty(components[0]) || TextUtils.isEmpty(components[2])) {
       return V2NIMConversationType.V2NIM_CONVERSATION_TYPE_UNKNOWN;
      }
      try {
       int type = Integer.parseInt(components[1]);
    
       return V2NIMConversationType.typeOfValue(type);
      }
      catch (Throwable e) {
       NimLog.e(TAG, "conversationType error, conversationId=" + conversationId + ", e=" + e.getMessage());
       return V2NIMConversationType.V2NIM_CONVERSATION_TYPE_UNKNOWN;
      }
     }
    
     /**
      * 根据会话 ID 返回会话对应目标 ID(accountId、teamId、superTeamId)
      * @param conversationId 会话 ID
      * @return 会话目标 ID
      */
     public static String conversationTargetId(String conversationId) {
      if (TextUtils.isEmpty(conversationId)) {
       return null;
      }
      String[] components = conversationId.split(CONVERSATION_ID_SPLIT);
      // 3 parts
      if (components.length != 3) {
       return null;
      }
      // account and target
    
      if (TextUtils.isEmpty(components[0]) || TextUtils.isEmpty(components[2])) {
       return null;
      }
    
      return components[2];
     }
    
     /**
      * 会话 ID 是否合法
      * @param conversationId 会话 ID
      * @return 是否合法 true:合法 false:不合法
      */
     public static boolean isConversationIdValid(String conversationId){
      if (TextUtils.isEmpty(conversationId)) {
       return false;
      }
      String[] components = conversationId.split(CONVERSATION_ID_SPLIT);
      // 3 parts
      if (components.length != 3) {
       return false;
      }
    
      String account = SDKCacheUI.getAccount();
      if(account != null && !account.equals(components[0]))
      {
       return false;
      }
    
      if(TextUtils.isEmpty(components[0]))
      {
       return false;
      }
    
      V2NIMConversationType type;
      try {
       int typeInt = Integer.parseInt(components[1]);
       type = V2NIMConversationType.typeOfValue(typeInt);
      }
      catch (NumberFormatException e) {
       return false;
      }
      if(type == V2NIMConversationType.V2NIM_CONVERSATION_TYPE_UNKNOWN)
      {
       return false;
      }
    
      if(TextUtils.isEmpty(components[2]))
      {
       return false;
      }
    
      return true;
    
     }
    
     @Nullable
     public static SessionTypeEnum sessionTypeV1(@Nullable V2NIMConversationType conversationType) {
      if (conversationType == null) {
       return null;
      }
      switch (conversationType) {
       case V2NIM_CONVERSATION_TYPE_P2P:
        return SessionTypeEnum.P2P;
       case V2NIM_CONVERSATION_TYPE_TEAM:
        return SessionTypeEnum.Team;
       case V2NIM_CONVERSATION_TYPE_SUPER_TEAM:
        return SessionTypeEnum.SUPER_TEAM;
       default:
        return SessionTypeEnum.None;
      }
     }
    }
    
    iOS
    Objective-C@interface V2NIMConversationIdUtil : NSObject
    
    /**
     * 使用账号 ID 构造会话 ID
     *
     * @param accountId 账号 ID
     * @return 返回会话 ID
     * @discussion
     */
    + (nullable NSString *)p2pConversationId:(NSString *)accountId;
    /**
     * 使用群 ID 构造会话 ID
     *
     * @param teamId 群 ID
     * @return 返回会话 ID
     * @discussion
     */
    + (nullable NSString *)teamConversationId:(NSString *)teamId;
    /**
     * 使用群 ID 构造会话 ID(超大群)
     *
     * @param teamId 群 ID
     * @return 返回会话 ID
     * @discussion
     */
    + (nullable NSString *)superTeamConversationId:(NSString *)teamId;
    
    /**
     * 从会话 ID 中获取会话类型
     *
     * @param conversationId 会话 ID
     * @return 返回会话类型
     * @discussion
     */
    + (V2NIMConversationType)conversationType:(NSString *)conversationId;
    /**
     * 从会话 ID 中获取会话对象 ID
     *
     * @param conversationId 会话 ID
     * @return 返回会话对象 ID
     * @discussion
     */
    + (nullable NSString *)conversationTargetId:(NSString *)conversationId;
    
    @end
    
    macOS/Windows
    C++class V2NIMConversationIdUtil {
    public:
        /// @brief 获取点对点会话 ID
        /// @param accountId 账号 ID
        /// @return nstd::string
        /// @par 示例代码
        /// @code
        /// auto conversationId = V2NIMConversationIdUtil::p2pConversationId("target_account_id");
        /// @endcode
        static nstd::string p2pConversationId(const nstd::string& accountId);
    
        /// @brief 获取群组会话 ID
        /// @param teamId 群组 ID
        /// @return nstd::string
        /// @par 示例代码
        /// @code
        /// auto conversationId = V2NIMConversationIdUtil::teamConversationId("team_id");
        /// @endcode
        static nstd::string teamConversationId(const nstd::string& teamId);
    
        /// @brief 获取超级群会话 ID
        /// @param superTeamId 超级群 ID
        /// @return nstd::string
        /// @par 示例代码
        /// @code
        /// auto conversationId = V2NIMConversationIdUtil::superTeamConversationId("super_team_id");
        /// @endcode
        static nstd::string superTeamConversationId(const nstd::string& superTeamId);
    
        /// @brief 获取会话 ID 对应的会话类型
        /// @param conversationId 会话 ID
        /// @return V2NIMConversationType
        /// @par 示例代码
        /// @code
        /// auto conversationType = V2NIMConversationIdUtil::parseConversationType("conversation_id");
        /// @endcode
        static V2NIMConversationType parseConversationType(const nstd::string& conversationId);
    
        /// @brief 获取会话 ID 对应的目标 ID
        /// @param conversationId 会话 ID
        /// @return nstd::string
        /// @par 示例代码
        /// @code
        /// auto targetId = V2NIMConversationIdUtil::parseConversationTargetId("conversation_id");
        /// @endcode
        static nstd::string parseConversationTargetId(const nstd::string& conversationId);
    };
    
    Web/uni-app/小程序
    TypeScriptconst p2pConversationId = nim.V2NIMConversationIdUtil.p2pConversationId('ACCOUND_ID')
    const teamConversationId = nim.V2NIMConversationIdUtil.teamConversationId('TEAM_ID')
    const superTeamConversationId = nim.V2NIMConversationIdUtil.superTeamConversationId('SUPER_TEAM_ID')
    const conversationType = nim.V2NIMConversationIdUtil.parseConversationType('CONVERSATION_ID')
    const targetId = nim.V2NIMConversationIdUtil.parseConversationTargetId('CONVERSATION_ID')
    
    HarmonyOS
    TypeScriptconst p2pConversationId = nim.conversationIdUtil.p2pConversationId('ACCOUND_ID')
    const teamConversationId = nim.conversationIdUtil.teamConversationId('TEAM_ID')
    const superTeamConversationId = nim.conversationIdUtil.superTeamConversationId('SUPER_TEAM_ID')
    const conversationType = nim.conversationIdUtil.parseConversationType('CONVERSATION_ID')
    const targetId = nim.conversationIdUtil.parseConversationTargetId('CONVERSATION_ID')
    

    V2NIMMessageListener

    消息相关监听器。

    Android
    Javapublic interface V2NIMMessageListener {
    
        void onSendMessage(V2NIMMessage message);
    
        void onReceiveMessages(List<V2NIMMessage> messages);
    
        void onReceiveP2PMessageReadReceipts(List<V2NIMP2PMessageReadReceipt> readReceipts);
    
        void onReceiveTeamMessageReadReceipts(List<V2NIMTeamMessageReadReceipt> readReceipts);
    
        void onMessageRevokeNotifications(List<V2NIMMessageRevokeNotification> revokeNotifications);
    
        void onMessagePinNotification(V2NIMMessagePinNotification pinNotification);
    
        void onMessageQuickCommentNotification(V2NIMMessageQuickCommentNotification quickCommentNotification);
    
        void onMessageDeletedNotifications(List<V2NIMMessageDeletedNotification> messageDeletedNotifications);
    
        void onClearHistoryNotifications(List<V2NIMClearHistoryNotification> clearHistoryNotifications);
    
        void onReceiveMessagesModified(List<V2NIMMessage> messages);
    }
    
    iOS
    Objective-C@protocol V2NIMMessageListener <NSObject>
    
    - (void)onSendMessage:(V2NIMMessage *)message;
    
    - (void)onReceiveMessages:(NSArray <V2NIMMessage *> *)messages;
    
    - (void)onReceiveP2PMessageReadReceipts:(NSArray <V2NIMP2PMessageReadReceipt *>*)readReceipts;
    
    - (void)onReceiveTeamMessageReadReceipts:(NSArray <V2NIMTeamMessageReadReceipt *>*)readReceipts;
    
    - (void)onMessageRevokeNotifications:(V2NIMMessageRevokeNotification *)revokeNotification;
    
    - (void)onMessagePinNotification:(V2NIMMessagePinNotification *)pinNotification;
    
    - (void)onMessageQuickCommentNotification:(V2NIMMessageQuickCommentNotification *)notification;
    
    - (void)onMessageDeletedNotifications:(NSArray<V2NIMMessageDeletedNotification *> *)messageDeletedNotification;
    
    - (void)onClearHistoryNotifications:(NSArray<V2NIMClearHistoryNotification *> *)clearHistoryNotification;
    
    - (void)onReceiveMessagesModified:(NSArray <V2NIMMessage *>*)messages;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageListener {
        nstd::function<void(nstd::vector<V2NIMMessage> messages)> onReceiveMessages;
        nstd::function<void(nstd::vector<V2NIMP2PMessageReadReceipt> readReceipts)> onReceiveP2PMessageReadReceipts;
        nstd::function<void(nstd::vector<V2NIMTeamMessageReadReceipt> readReceipts)> onReceiveTeamMessageReadReceipts;
        nstd::function<void(nstd::vector<V2NIMMessageRevokeNotification> revokeNotifications)> onMessageRevokeNotifications;
        nstd::function<void(V2NIMMessagePinNotification pinNotification)> onMessagePinNotification;
        nstd::function<void(V2NIMMessageQuickCommentNotification quickCommentNotification)> onMessageQuickCommentNotification;
        nstd::function<void(nstd::vector<V2NIMMessageDeletedNotification> messageDeletedNotification)> onMessageDeletedNotifications;
        nstd::function<void(nstd::vector<V2NIMClearHistoryNotification> clearHistoryNotification)> onClearHistoryNotifications;
        nstd::function<void(const V2NIMMessage &message)> 	onSendMessage;
        nstd::function<void(nstd::vector<V2NIMMessage> messages)> onReceiveMessagesModified;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMMessageListener = {
    
      onSendMessage: [message: V2NIMMessage]
      onReceiveMessages: [messages: V2NIMMessage[]]
      onReceiveP2PMessageReadReceipts: [readReceipts: V2NIMP2PMessageReadReceipt[]]
      onReceiveTeamMessageReadReceipts: [readReceipts: V2NIMTeamMessageReadReceipt[]]
      onMessageRevokeNotifications: [notification: V2NIMMessageRevokeNotification[]]
      onMessageDeletedNotifications: [notification: V2NIMMessageDeletedNotification[]]
      onClearHistoryNotifications: [notification: V2NIMClearHistoryNotification[]]
      onMessagePinNotification: [notification: V2NIMMessagePinNotification]
      onMessageQuickCommentNotification: [notification: V2NIMMessageQuickCommentNotification]
      onReceiveMessagesModified: [messages: V2NIMMessage[]]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMMessageListener = {
      onReceiveMessages: [messages: V2NIMMessage[]]
      onReceiveP2PMessageReadReceipts: [readReceipts: V2NIMP2PMessageReadReceipt[]]
      onReceiveTeamMessageReadReceipts: [readReceipts: V2NIMTeamMessageReadReceipt[]]
      onMessageRevokeNotifications: [notification: V2NIMMessageRevokeNotification[]]
      onMessageDeletedNotifications: [notification: V2NIMMessageDeletedNotification[]]
      onClearHistoryNotifications: [notification: V2NIMClearHistoryNotification[]]
      onMessagePinNotification: [notification: V2NIMMessagePinNotification]
      onMessageQuickCommentNotification: [notification: V2NIMMessageQuickCommentNotification]
    }
    

    成员函数

    • onSendMessage

      本端发送消息状态回调,本端发送消息或插入消息成功后,SDK 会返回该回调。

      参数名称 类型 说明
      message V2NIMMessage 发送或插入的消息
    • onReceiveMessages

      消息接收回调,本端接收到发送方消息,或其他端同步的消息时会触发该回调。

      参数名称 类型 说明
      messages List<V2NIMMessage> 消息列表
    • onReceiveMessagesModified

      消息更新回调,本端更新消息成功后,会话参与者以及登录的其他客户端会收到该回调通知(包括更新消息在线同步通知、更新消息多端同步通知以及更新消息漫游通知)。

      参数名称 类型 说明
      messages List<V2NIMMessage> 更新后的消息列表
    • onReceiveP2PMessageReadReceipts

      单聊消息已读回调。

      本端发送已读回执成功后,其他登录客户端和消息发送方均会收到该回调。

      参数名称 类型 说明
      readReceipts List<V2NIMP2PMessageReadReceipt> 单聊消息已读回执列表
    • onReceiveTeamMessageReadReceipts

      高级群消息已读回调。 本端发送已读回执成功后,其他登录客户端和消息发送方均会收到该回调。

      参数名称 类型 说明
      readReceipts List<V2NIMTeamMessageReadReceipt> 高级群消息已读回执列表
    • onMessageRevokeNotifications

      消息撤回通知回调。 本地端或多端同步撤回消息成功后,SDK 会返回该回调。

      参数名称 类型 说明
      readReceipts List<V2NIMMessageRevokeNotification> 消息撤回通知列表
    • onMessageQuickCommentNotification

      消息快捷评论操作通知回调。 本地端或多端同步添加或移除消息快捷评论成功后,消息发送方和消息接收方均会收到该回调。

      参数名称 类型 说明
      quickCommentNotification V2NIMMessageQuickCommentNotification 快捷评论通知列表
    • onMessagePinNotification

      Pin 消息状态变化通知回调。 本地端或多端同步 Pin 消息成功后,消息发送方和消息接收方均会收到该回调。

      参数名称 类型 说明
      pinNotification V2NIMMessagePinNotification Pin 消息状态变化通知列表
    • onMessageDeletedNotifications

      消息被删除回调。 本地端或多端同步删除消息成功后,SDK 会返回该回调。

      参数名称 类型 说明
      messageDeletedNotifications List<V2NIMMessageDeletedNotification> 消息删除通知列表
    • onClearHistoryNotifications

      会话历史消息清除回调。 本地端或多端同步清空会话内历史消息成功后,SDK 会返回该回调。

      参数名称 类型 说明
      clearHistoryNotifications List<V2NIMClearHistoryNotification> 会话历史消息清除通知列表

    V2NIMMessage

    单聊、群组会话内消息对象。

    Android
    Javapublic interface V2NIMMessage extends V2NIMMessageRefer, Serializable {
    
        String getMessageClientId();
    
        String getMessageServerId();
    
        long getCreateTime();
    
        String getSenderId();
    
        V2NIMConversationType getConversationType();
    
        String getReceiverId();
    
        V2NIMMessageType getMessageType();
    
        int getSubType();
    
        String getText();
    
        V2NIMMessageAttachment getAttachment();
    
        String getServerExtension();
    
        String getLocalExtension();
    
        String getCallbackExtension();
    
        V2NIMMessageConfig getMessageConfig();
    
        V2NIMMessagePushConfig getPushConfig();
    
        V2NIMMessageRouteConfig getRouteConfig();
    
        V2NIMMessageAntispamConfig getAntispamConfig();
    
        V2NIMMessageRobotConfig getRobotConfig();
    
        V2NIMMessageRefer getThreadRoot();
    
        V2NIMMessageRefer getThreadReply();
    
        V2NIMMessageStatus getMessageStatus();
    
        String getConversationId();
    
        boolean isSelf();
    
        V2NIMMessageAttachmentUploadState getAttachmentUploadState();
    
        V2NIMMessageSendingState getSendingState();
    
        void setSubType(int subType);
    
        void setText(String text);
    
        void setAttachment(V2NIMMessageAttachment attachment);
    
        void setServerExtension(String serverExtension);
    
        void setLocalExtension(String localExtension);
    
        V2NIMMessageAIConfig getAIConfig();
    
        void setAIConfig(V2NIMMessageAIConfig aiConfig);
        
        long getModifyTime();
    
        String getModifyAccountId();
    }
    
    iOS
    Objective-C@interface V2NIMMessage : V2NIMMessageRefer <NSCopying>
    
    @property(nonatomic,assign,readonly) BOOL isSelf;
    
    @property(nonatomic,assign,readonly) V2NIMMessageAttachmentUploadState attachmentUploadState;
    
    @property(nonatomic,assign,readonly) V2NIMMessageSendingState sendingState;
    
    @property(nonatomic,assign) V2NIMMessageType messageType;
    
    @property(nonatomic,assign) NSInteger subType;
    
    @property(nullable,nonatomic,strong) NSString *text;
    
    @property(nullable,nonatomic,strong) V2NIMMessageAttachment *attachment;
    
    @property(nullable,nonatomic,strong) NSString *serverExtension;
    
    @property(nullable,nonatomic,strong) NSString *localExtension;
    
    @property(nullable,nonatomic,strong,readonly) NSString *callbackExtension;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageConfig *messageConfig;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessagePushConfig *pushConfig;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageRouteConfig *routeConfig;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageAntispamConfig *antispamConfig;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageRobotConfig *robotConfig;
    
    @property(nullable,nonatomic,strong,readwrite) V2NIMMessageRefer *threadRoot;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageRefer *threadReply;
    
    @property(nullable,nonatomic,strong,readwrite) V2NIMMessageAIConfig *aiConfig;
    
    @property(nonnull,nonatomic,strong, readonly) V2NIMMessageStatus *messageStatus;
    
    @property(nonatomic,assign, readonly) NSTimeInterval modifyTime;
    
    @property(nullable,nonatomic,copy, readonly) NSString *modifyAccountId;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessage {
        nstd::string messageClientId;
        nstd::string messageServerId;
        uint64_t createTime{0};
        nstd::string senderId;
        nstd::string senderName;
        nstd::string receiverId;
        V2NIMConversationType conversationType{V2NIM_CONVERSATION_TYPE_UNKNOWN};
        nstd::string conversationId;
        V2NIMMessageType messageType{V2NIM_MESSAGE_TYPE_TEXT};
        uint32_t subType{0};
        nstd::string text;
        nstd::shared_ptr<V2NIMMessageAttachment> attachment;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<nstd::string> localExtension;
        nstd::optional<nstd::string> callbackExtension;
        nstd::optional<V2NIMMessageSendingState> sendingState;
        nstd::optional<V2NIMMessageAttachmentUploadState> attachmentUploadState;
        V2NIMMessageStatus messageStatus;
        V2NIMMessageConfig messageConfig;
        V2NIMMessagePushConfig pushConfig;
        V2NIMMessageRouteConfig routeConfig;
        V2NIMMessageAntispamConfig antispamConfig;
        V2NIMMessageRobotConfig robotConfig;
        nstd::optional<V2NIMMessageRefer> threadRoot;
        nstd::optional<V2NIMMessageRefer> threadReply;
        nstd::optional<V2NIMMessageAIConfig> aiConfig;
        nstd::optional<uint64_t> modifyTime;
        nstd::optional<nstd::string> modifyAccountId;
        bool isSelf{false};
        operator V2NIMMessageRefer() const {
            V2NIMMessageRefer messageRefer;
            messageRefer.senderId = senderId;
            messageRefer.receiverId = receiverId;
            messageRefer.messageClientId = messageClientId;
            messageRefer.messageServerId = messageServerId;
            messageRefer.conversationType = conversationType;
            messageRefer.conversationId = conversationId;
            messageRefer.createTime = createTime;
            return messageRefer;
        }
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMMessage = {
    
      messageClientId: string
    
      messageServerId: string
    
      createTime: number
    
      senderId: string
    
      receiverId: string
    
      conversationType: V2NIMConversationType
    
      conversationId: string
    
      isSelf: boolean
    
      attachmentUploadState?: V2NIMMessageAttachmentUploadState
    
      sendingState: V2NIMMessageSendingState
    
      messageType: V2NIMMessageType
    
      subType?: number
    
      text?: string
    
      attachment?: V2NIMMessageAttachment
    
      serverExtension?: string
    
      callbackExtension?: string
    
      messageConfig?: V2NIMMessageConfig
    
      pushConfig?: V2NIMMessagePushConfig
    
      routeConfig?: V2NIMMessageRouteConfig
    
      antispamConfig?: V2NIMMessageAntispamConfig
    
      robotConfig?: V2NIMMessageRobotConfig
    
      threadRoot?: V2NIMMessageRefer
    
      threadReply?: V2NIMMessageRefer
    
      messageStatus: V2NIMMessageStatus
    
      aiConfig?: V2NIMMessageAIConfig
    
      modifyTime?: number
    
      modifyAccountId?: string
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMMessage = {
    
      messageClientId: string
      messageServerId: string
      createTime: number
      senderId: string
      receiverId: string
      conversationType: V2NIMConversationType
      conversationId: string
      isSelf: boolean
      sendingState: V2NIMMessageSendingState
      messageType: V2NIMMessageType
      subType?: number
      text?: string
      attachment?:
        | V2NIMMessageAttachment
        | Partial<V2NIMMessageFileAttachment>
        | Partial<V2NIMMessagImageAttachment>
        | Partial<V2NIMMessageAudioAttachment>
        | Partial<V2NIMMessageVideoAttachment>
        | Partial<V2NIMMessageLocationAttachment>
        | Partial<V2NIMMessageNotificationAttachment>
        | V2NIMMessageNotificationAttachment
      serverExtension?: string
      callbackExtension?: string
      messageConfig?: V2NIMMessageConfig
      pushConfig?: V2NIMMessagePushConfig
      routeConfig?: V2NIMMessageRouteConfig
      antispamConfig?: V2NIMMessageAntispamConfig
      robotConfig?: V2NIMMessageRobotConfig
      threadRoot?: V2NIMMessageRefer
      threadReply?: V2NIMMessageRefer
    }
    

    成员参数

    名称 类型 是否只读 说明
    messageClientId String 客户端消息 ID,消息在客户端生成的 UUID。不会多端同步。
    messageServerId String 服务器消息 ID,消息发送成功后 服务器生成的 UUID。会多端同步。
    消息发送成功前只存在 messageClientId
    createTime long 消息时间戳,单位毫秒。
  • 消息发送成功前,该字段为消息发送者本地时间。
  • 消息发送成功后,该字段为服务器时间。
  • senderId String 消息发送方账号(accountId)
    receiverId String 消息接收方账号
  • 如果消息所属会话类型为单聊,该字段为聊天对象账号 accountId。
  • 如果消息所属会话类型为群组,该字段为群组 ID。
  • conversationType

    V2NIMConversationType

    消息所属会话类型:

    • V2NIM_CONVERSATION_TYPE_P2P:点对点
    • V2NIM_CONVERSATION_TYPE_TEAM:高级群
    • V2NIM_CONVERSATION_TYPE_SUPER_TEAM:超大群
    conversationId String 会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    aiConfig V2NIMMessageAIConfig 数字人相关的 AI 聊天信息。
    isSelf boolean 消息发送方是否为本人。
    attachmentUploadState V2NIMMessageAttachmentUploadState 消息附件上传状态。
    sendingState V2NIMMessageSendingState 消息发送状态。
    messageType V2NIMMessageType 消息类型。
    subType int 自定义消息子类型,0 表示无消息子类型。
    text String 消息文本内容,仅文本类型的消息有该字段。
    attachment V2NIMMessageAttachment 消息附件,仅图片、语音、视频、文件类型消息有该字段。长度上限为 4096 字节。
    serverExtension String 消息服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    localExtension String 消息本地扩展字段,必须为 JSON 格式封装,不可多端同步。长度上限为 2048 字节。默认为空("")。
    callbackExtension String 第三方回调透传的自定义扩展字段,长度上限为 2048 字节。
    第三方回调功能需要在 网易云信控制台开通
    messageConfig V2NIMMessageConfig 消息相关配置。
    pushConfig V2NIMMessagePushConfig 第三方推送相关配置。
    第三方推送功能需要在 网易云信控制台配置
    routeConfig V2NIMMessageRouteConfig 消息事件抄送相关配置。
    消息抄送功能需要在 网易云信控制台开通
    antispamConfig V2NIMMessageAntispamConfig 反垃圾相关配置。
    反垃圾功能包括客户端反垃圾和安全通,均需要在 网易云信控制台开通
    robotConfig V2NIMMessageRobotConfig 机器人相关配置。
    机器人功能需要在 网易云信控制台配置
    threadRoot V2NIMMessageRefer 消息回复的根消息参考信息。
    消息回复功能需要在 网易云信控制台开通
    threadReply V2NIMMessageRefer 消息回复的父消息参考信息。
    消息回复功能需要在 网易云信控制台开通
    messageStatus V2NIMMessageStatus 消息状态相关信息。
    modifyTime Long 消息更新是时间,默认为 0。
    modifyAccountId String 消息更新者账号,默认为 null/undefined。

    V2NIMMessageStatus

    消息状态对象,包含消息发送失败的错误码以及是否已发送过已读回执。

    Android
    Javapublic interface V2NIMMessageStatus {
    
        /**
         * 获取消息发送错误码
         * @return 消息发送错误码
         */
        int getErrorCode();
    
        /**
         * 获取是否已经发送过已读回执请求
         * @return 是否已经发送过已读回执请求
         */
        boolean getReadReceiptSent();
    }
    
    iOS
    Objective-C@interface V2NIMMessageStatus : NSObject<NSCopying>
    /// 消息发送错误码
    @property(nonatomic,assign,readwrite) NSInteger errorCode;
    /// 群消息开启已读回执配置
    @property(nonatomic,assign,readwrite) BOOL readReceiptSent;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageStatus {
        V2NIMErrorCode errorCode{V2NIM_ERROR_CODE_UNKNOWN};
        bool readReceiptSent{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMMessageStatus = {
      /**
       * 消息发送错误码
       */
      errorCode: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    errorCode Integer 200 消息发送失败的错误码。用户可以对该错误码做详细处理,以适配上层业务。
    • 当错误码由客户端回填时,发送状态为失败。
    • 当错误码由服务端回填时,发送状态为成功,服务端会返回对应的提示。
    • 当发生以下情况时,会返回错误码:
      • 本地命中反垃圾拦截
      • 本地发送超时
      • 服务器 AI 响应消息由于反垃圾失败返回
      • 服务器 AI 响应消息由于三方回调拦截返回
      • 被对方拉黑发送失败
      • 其他发送失败情况,如文件上传失败,文件上传取消
    readReceiptSent Boolean false 是否已发送过已读回执。当用户开启群消息已读回执时,客户端收到消息后需要发送已读回执请求,为了避免重复发送,需要通过该字段判断是否已发送过已读回执。该字段只对群消息有效。

    V2NIMMessageConfig

    消息相关配置。

    Android
    Javapublic class V2NIMMessageConfig implements Serializable {
    
        public boolean isReadReceiptEnabled() {
            return readReceiptEnabled;
        }
    
        public boolean isLastMessageUpdateEnabled() {
            return lastMessageUpdateEnabled;
        }
    
        public boolean isHistoryEnabled() {
            return historyEnabled;
        }
    
        public boolean isRoamingEnabled() {
            return roamingEnabled;
        }
    
        public boolean isOnlineSyncEnabled() {
            return onlineSyncEnabled;
        }
    
        public boolean isOfflineEnabled() {
            return offlineEnabled;
        }
    
        public boolean isUnreadEnabled() {
            return unreadEnabled;
        }
    
        @Override
        public String toString() {
            return "V2NIMMessageConfig{" +
                    "readReceiptEnabled=" + readReceiptEnabled +
                    ", lastMessageUpdateEnabled=" + lastMessageUpdateEnabled +
                    ", historyEnabled=" + historyEnabled +
                    ", roamingEnabled=" + roamingEnabled +
                    ", onlineSyncEnabled=" + onlineSyncEnabled +
                    ", offlineEnabled=" + offlineEnabled +
                    ", unreadEnabled=" + unreadEnabled +
                    '}';
        }
    
        public static final boolean DEFAULT_READ_RECEIPT_ENABLED = false;
        public static final boolean DEFAULT_CONVERSATION_UPDATE_ENABLED = true;
        public static final boolean DEFAULT_HISTORY_ENABLED = true;
        public static final boolean DEFAULT_ROAMING_ENABLED = true;
        public static final boolean DEFAULT_ONLINE_SYNC_ENABLED = true;
        public static final boolean DEFAULT_OFFLINE_ENABLED = true;
        public static final boolean DEFAULT_UNREAD_ENABLED = true;
    
        public static final class V2NIMMessageConfigBuilder {
    
            public static V2NIMMessageConfigBuilder builder() {
                return new V2NIMMessageConfigBuilder();
            }
    
            public V2NIMMessageConfigBuilder withReadReceiptEnabled(boolean readReceiptEnabled) {
                this.readReceiptEnabled = readReceiptEnabled;
                return this;
            }
    
            public V2NIMMessageConfigBuilder withLastMessageUpdateEnabled(boolean lastMessageUpdateEnabled) {
                this.lastMessageUpdateEnabled = lastMessageUpdateEnabled;
                return this;
            }
    
            public V2NIMMessageConfigBuilder withHistoryEnabled(boolean historyEnabled) {
                this.historyEnabled = historyEnabled;
                return this;
            }
    
            public V2NIMMessageConfigBuilder withRoamingEnabled(boolean roamingEnabled) {
                this.roamingEnabled = roamingEnabled;
                return this;
            }
    
            public V2NIMMessageConfigBuilder withOnlineSyncEnabled(boolean onlineSyncEnabled) {
                this.onlineSyncEnabled = onlineSyncEnabled;
                return this;
            }
    
            public V2NIMMessageConfigBuilder withOfflineEnabled(boolean offlineEnabled) {
                this.offlineEnabled = offlineEnabled;
                return this;
            }
    
            public V2NIMMessageConfigBuilder withUnreadEnabled(boolean unreadEnabled) {
                this.unreadEnabled = unreadEnabled;
                return this;
            }
    
            public V2NIMMessageConfig build() {
                return new V2NIMMessageConfig(readReceiptEnabled, lastMessageUpdateEnabled, historyEnabled, roamingEnabled, onlineSyncEnabled, offlineEnabled, unreadEnabled);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageConfig : NSObject <NSCopying>
    
    @property(nonatomic,assign,readwrite) BOOL readReceiptEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL lastMessageUpdateEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL historyEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL roamingEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL onlineSyncEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL offlineEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL unreadEnabled;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageConfig {
    
        bool readReceiptEnabled{false};
    
        bool lastMessageUpdateEnabled{true};
    
        bool historyEnabled{true};
    
        bool roamingEnabled{true};
    
        bool onlineSyncEnabled{true};
    
        bool offlineEnabled{true};
    
        bool unreadEnabled{true};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMMessageConfig = {
    
      readReceiptEnabled?: boolean
    
      lastMessageUpdateEnabled?: boolean
    
      historyEnabled?: boolean
    
      roamingEnabled?: boolean
    
      onlineSyncEnabled?: boolean
    
      offlineEnabled?: boolean
    
      unreadEnabled?: boolean
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMMessageConfig = {
    
      readReceiptEnabled?: boolean
      lastMessageUpdateEnabled?: boolean
      historyEnabled?: boolean
      roamingEnabled?: boolean
      onlineSyncEnabled?: boolean
      offlineEnabled?: boolean
      unreadEnabled?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    readReceiptEnabled boolean false 是否需要消息已读回执信息。
    lastMessageUpdateEnabled boolean true 是否需要更新消息所属的会话信息。
    historyEnabled boolean true 是否需要在服务端保存历史消息。
    roamingEnabled boolean true 是否需要保存漫游消息。
    onlineSyncEnabled boolean true 是否需要发送方消息多端同步。
    offlineEnabled boolean true 是否需要保存离线消息。
    unreadEnabled boolean true 是否需要计入未读数。

    V2NIMMessagePushConfig

    消息第三方推送相关配置。

    Android
    Javapublic class V2NIMMessagePushConfig implements Serializable {
    
        public boolean isPushEnabled() {
            return pushEnabled;
        }
    
        public boolean isPushNickEnabled() {
            return pushNickEnabled;
        }
    
        public String getPushContent() {
            return pushContent;
        }
    
        public String getPushPayload() {
            return pushPayload;
        }
    
        public boolean isForcePush() {
            return forcePush;
        }
    
        public String getForcePushContent() {
            return forcePushContent;
        }
    
        public List<String> getForcePushAccountIds() {
            return forcePushAccountIds;
        }
    
        @Override
        public String toString() {
            return "V2NIMMessagePushConfig{" +
                    "pushEnabled=" + pushEnabled +
                    ", pushNickEnabled=" + pushNickEnabled +
                    ", content='" + pushContent + '\'' +
                    ", payload='" + pushPayload + '\'' +
                    ", forcePush=" + forcePush +
                    ", forcePushContent='" + forcePushContent + '\'' +
                    ", forcePushAccountIds=" + forcePushAccountIds +
                    '}';
        }
    
        public static final boolean DEFAULT_PUSH_ENABLE = true;
        public static final boolean DEFAULT_PUSH_NICK_ENABLE = true;
    
        public static final class V2NIMMessagePushConfigBuilder {
    
            public static V2NIMMessagePushConfigBuilder builder() {
                return new V2NIMMessagePushConfigBuilder();
            }
    
            public V2NIMMessagePushConfigBuilder withPushEnabled(boolean pushEnabled) {
                this.pushEnabled = pushEnabled;
                return this;
            }
    
            public V2NIMMessagePushConfigBuilder withPushNickEnabled(boolean pushNickEnabled) {
                this.pushNickEnabled = pushNickEnabled;
                return this;
            }
    
            public V2NIMMessagePushConfigBuilder withContent(String content) {
                this.content = content;
                return this;
            }
    
            public V2NIMMessagePushConfigBuilder withPayload(String payload) {
                this.payload = payload;
                return this;
            }
    
            public V2NIMMessagePushConfigBuilder withForcePush(boolean forcePush) {
                this.forcePush = forcePush;
                return this;
            }
    
            public V2NIMMessagePushConfigBuilder withForcePushContent(String forcePushContent) {
                this.forcePushContent = forcePushContent;
                return this;
            }
    
            public V2NIMMessagePushConfigBuilder withForcePushAccountIds(List<String> forcePushAccountIds) {
                this.forcePushAccountIds = forcePushAccountIds;
                return this;
            }
    
            public V2NIMMessagePushConfig build() {
                return new V2NIMMessagePushConfig(pushEnabled, pushNickEnabled, content, payload, forcePush, forcePushContent, forcePushAccountIds);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessagePushConfig : NSObject <NSCopying>
    
    @property(nonatomic,assign,readwrite) BOOL pushEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL pushNickEnabled;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *pushContent;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *pushPayload;
    
    @property(nonatomic,assign,readwrite) BOOL forcePush;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *forcePushContent;
    
    @property(nullable,nonatomic,strong,readwrite) NSArray<NSString *> *forcePushAccountIds;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessagePushConfig {
    
        bool pushEnabled{true};
    
        bool pushNickEnabled{true};
    
        nstd::string pushContent;
    
        nstd::string pushPayload;
    
        bool forcePush{false};
    
        nstd::string forcePushContent;
    
        nstd::vector<nstd::string> forcePushAccountIds;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessagePushConfig {
    
      pushEnabled?: boolean
    
      pushNickEnabled?: boolean
    
      pushContent?: string
    
      pushPayload?: string
    
      forcePush?: boolean
    
      forcePushContent?: string
    
      forcePushAccountIds?: string[]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessagePushConfig {
    
      pushEnabled?: boolean
      pushNickEnabled?: boolean
      pushContent?: string
      pushPayload?: string
      forcePush?: boolean
      forcePushContent?: string
      forcePushAccountIds?: string[]
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    pushEnabled boolean true 是否需要推送消息。
    pushNickEnabled boolean true 是否需要推送消息发送方昵称。
    pushContent String 云信内置的推送文案 推送文案。
    pushPayload String - 推送 Payload
    forcePush boolean false 是否忽略用户消息提醒相关设置,强制推送。该字段仅对群消息有效。
    forcePushContent String - 强制推送文案。
    forcePushAccountIds List<String> - 强制推送目标账号列表。

    V2NIMMessageRouteConfig

    消息事件抄送相关配置。

    Android
    Javapublic class V2NIMMessageRouteConfig implements Serializable {
    
        public boolean isRouteEnabled() {
            return routeEnabled;
        }
    
        public String getRouteEnvironment() {
            return routeEnvironment;
        }
    
        @Override
        public String toString() {
            return "V2NIMMessageRouteConfig{" +
                    "routeEnabled=" + routeEnabled +
                    ", routeEnvironment='" + routeEnvironment + '\'' +
                    '}';
        }
    
        public static final boolean DEFAULT_ROUTE_ENABLE = true;
    
        public static final class V2NIMMessageRouteConfigBuilder {
    
            public static V2NIMMessageRouteConfigBuilder builder() {
                return new V2NIMMessageRouteConfigBuilder();
            }
    
            public V2NIMMessageRouteConfigBuilder withRouteEnabled(boolean routeEnabled) {
                this.routeEnabled = routeEnabled;
                return this;
            }
    
            public V2NIMMessageRouteConfigBuilder withRouteEnvironment(String routeEnvironment) {
                this.routeEnvironment = routeEnvironment;
                return this;
            }
    
            public V2NIMMessageRouteConfig build() {
                return new V2NIMMessageRouteConfig(routeEnabled, routeEnvironment);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageRouteConfig : NSObject <NSCopying>
    
    @property(nonatomic,assign,readwrite) BOOL routeEnabled;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *routeEnvironment;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageRouteConfig {
    
        bool routeEnabled{true};
    
        nstd::optional<nstd::string> routeEnvironment;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageRouteConfig {
    
      routeEnabled?: boolean
    
      routeEnvironment?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageRouteConfig {
    
      routeEnabled?: boolean
      routeEnvironment?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    routeEnabled boolean true 是否需要消息事件抄送。
    routeEnvironment String routeEnabled 为 true 则为必填 - 环境变量,用于指向不同消息事件抄送、第三方回调等配置。

    V2NIMMessageAntispamConfig

    消息反垃圾配置,包括客户端本地反垃圾和安全通的相关配置。

    Android
    Javapublic class V2NIMMessageAntispamConfig implements Serializable {
    
        public boolean isAntispamEnabled() {
            return antispamEnabled;
        }
    
        public String getAntispamBusinessId() {
            return antispamBusinessId;
        }
    
        public String getAntispamCustomMessage() {
            return antispamCustomMessage;
        }
    
        public String getAntispamCheating() {
            return antispamCheating;
        }
    
        public String getAntispamExtension() {
            return antispamExtension;
        }
    
        @Override
        public String toString() {
            return "V2NIMMessageAntispamConfig{" +
                    "antispamEnabled=" + antispamEnabled +
                    ", antispamBusinessId='" + antispamBusinessId + '\'' +
                    ", antispamCustomMessage='" + antispamCustomMessage + '\'' +
                    ", antispamCheating='" + antispamCheating + '\'' +
                    ", antispamExtension='" + antispamExtension + '\'' +
                    '}';
        }
    
        public static final class V2NIMMessageAntispamConfigBuilder {
            private boolean antispamEnabled = DEFAULT_ANTISPAM_ENABLED;
            private String antispamBusinessId;
            private String antispamCustomMessage;
            private String antispamCheating;
            private String antispamExtension;
    
            public static V2NIMMessageAntispamConfigBuilder builder() {
                return new V2NIMMessageAntispamConfigBuilder();
            }
    
            public V2NIMMessageAntispamConfigBuilder withAntispamEnabled(boolean antispamEnabled) {
                this.antispamEnabled = antispamEnabled;
                return this;
            }
    
            public V2NIMMessageAntispamConfigBuilder withAntispamBusinessId(String antispamBusinessId) {
                this.antispamBusinessId = antispamBusinessId;
                return this;
            }
    
            public V2NIMMessageAntispamConfigBuilder withAntispamCustomMessage(String antispamCustomMessage) {
                this.antispamCustomMessage = antispamCustomMessage;
                return this;
            }
    
            public V2NIMMessageAntispamConfigBuilder withAntispamCheating(String antispamCheating) {
                this.antispamCheating = antispamCheating;
                return this;
            }
    
            public V2NIMMessageAntispamConfigBuilder withAntispamExtension(String antispamExtension) {
                this.antispamExtension = antispamExtension;
                return this;
            }
    
            public V2NIMMessageAntispamConfig build() {
                return new V2NIMMessageAntispamConfig(antispamEnabled, antispamBusinessId, antispamCustomMessage, antispamCheating, antispamExtension);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageAntispamConfig : NSObject <NSCopying>
    
    @property(nonatomic, assign, readwrite) BOOL antispamEnabled;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *antispamBusinessId;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *antispamCustomMessage;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *antispamCheating;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *antispamExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageAntispamConfig {
    
        nstd::optional<bool> antispamEnabled;
    
        nstd::optional<nstd::string> antispamBusinessId;
    
        nstd::optional<nstd::string> antispamCustomMessage;
    
        nstd::optional<nstd::string> antispamCheating;
    
        nstd::optional<nstd::string> antispamExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageAntispamConfig {
    
      antispamEnabled?: boolean
    
      antispamBusinessId?: string
    
      antispamCustomMessage?: string
    
      antispamCheating?: string
    
      antispamExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageAntispamConfig {
    
      antispamEnabled?: boolean
      antispamBusinessId?: string
      antispamCustomMessage?: string
      antispamCheating?: string
      antispamExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明

    clientAntispamEnabled

    boolean

    false

    是否启用本地反垃圾。

    • 仅对文本消息生效。
    • 如果开启本地发垃圾,发送消息时会进行本地反垃圾检测,完成后返回检测结果 V2NIMClientAntispamOperatorType
      • 0:检测通过,可以发送该消息。
      • 1:发送替换后的文本消息。
      • 2:检测不通过,消息发送失败,返回本地错误码。
      • 3:消息发送后,由服务端拦截。
    shield String clientAntispamEnabled 为 true,且检测结果为 1 时必填 - 本地反垃圾命中后替换的文本。
    antispamEnabled boolean true 是否对该消息启用安全通检测。
    antispamBusinessId String antispamEnabled 为 true 时必填 - 易盾业务 ID
    antispamCustomMessage String antispamEnabled 为 true 时必填 - 自定义消息中需要反垃圾的内容,必须是 JSON 格式,长度不超过 5000 字节。格式如下 { "type": 1, //1:文本,2:图片,3 视频 "data": "" //文本内容 or 图片地址 or 视频地址 }
    antispamCheating String antispamEnabled 为 true 时必填 - 易盾反作弊(辅助检测数据),必须为 JSON 格式,长度上限为 1024 字节。
    antispamExtension String antispamEnabled 为 true 时必填 - 易盾反垃圾(增强检测数据),必须为 JSON 格式,长度上限为 1024 字节。

    V2NIMMessageRobotConfig

    消息机器人相关配置

    Android
    Javapublic class V2NIMMessageRobotConfig implements Serializable {
    
        public String getAccountId() {
            return accountId;
        }
    
        public String getTopic() {
            return topic;
        }
    
        public String getFunction() {
            return function;
        }
    
        public String getCustomContent() {
            return customContent;
        }
    
        @Override
        public String toString() {
            return "V2NIMMessageRobotConfig{" +
                    "accountId='" + accountId + '\'' +
                    ", topic='" + topic + '\'' +
                    ", function='" + function + '\'' +
                    ", customContent='" + customContent + '\'' +
                    '}';
        }
    
        public static final class V2NIMMessageRobotConfigBuilder {
    
            public static V2NIMMessageRobotConfigBuilder builder() {
                return new V2NIMMessageRobotConfigBuilder();
            }
    
            public V2NIMMessageRobotConfigBuilder withAccountId(String accountId) {
                this.accountId = accountId;
                return this;
            }
    
            public V2NIMMessageRobotConfigBuilder withTopic(String topic) {
                this.topic = topic;
                return this;
            }
    
            public V2NIMMessageRobotConfigBuilder withFunction(String function) {
                this.function = function;
                return this;
            }
    
            public V2NIMMessageRobotConfigBuilder withCustomContent(String customContent) {
                this.customContent = customContent;
                return this;
            }
    
            public V2NIMMessageRobotConfig build() {
                return new V2NIMMessageRobotConfig(accountId, topic, function, customContent);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageRobotConfig : NSObject<NSCopying>
    
    @property(nullable,nonatomic,strong,readwrite) NSString *accountId;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *topic;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *function;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *customContent;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageRobotConfig {
    
        nstd::optional<nstd::string> accountId;
    
        nstd::optional<nstd::string> topic;
    
        nstd::optional<nstd::string> function;
    
        nstd::optional<nstd::string> customContent;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageRobotConfig {
    
      accountId?: string
    
      topic?: string
    
      function?: string
    
      customContent?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageRobotConfig {
    
      accountId?: string
      topic?: string
      function?: string
      customContent?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    accountId String - 机器人账号,必须与在 网易云信控制台 上配置的机器人账号一致。
    该字段仅对群组消息有效。
    topic String - 机器人消息话题。
    function String - 机器人具体功能。
    customContent String - 机器人自定义内容。

    V2NIMLastMessage

    会话最后一条消息。包含以下场景:

    • 发送的最后一条消息
    • 接受的最后一条消息
    • 插入的最后一条消息
    • 撤回消息的通知
    Android
    Javapublic interface V2NIMLastMessage extends Serializable {
    
        V2NIMLastMessageState getLastMessageState();
    
        V2NIMMessageRefer getMessageRefer();
    
        V2NIMMessageType getMessageType();
    
        int getSubType();
    
        V2NIMMessageSendingState getSendingState();
    
        String getText();
    
        V2NIMMessageAttachment getAttachment();
    
        String getRevokeAccountId();
    
        V2NIMMessageRevokeType getRevokeType();
    
        String getServerExtension();
    
        String getCallbackExtension();
    
        String getSenderName();
    
    }
    
    
    iOS
    Objective-C@interface V2NIMLastMessage : NSObject <NSCopying>
    
    @property(nonatomic,assign,readonly) V2NIMLastMessageState lastMessageState;
    
    @property(nonatomic,strong,readonly) V2NIMMessageRefer *messageRefer;
    
    @property(nonatomic,assign,readonly) V2NIMMessageType messageType;
    
    @property(nonatomic,assign,readonly) NSInteger subType;
    
    @property(nonatomic,assign,readonly) V2NIMMessageSendingState sendingState;
    
    @property(nullable,nonatomic,strong,readonly) NSString *text;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageAttachment *attachment;
    
    @property(nullable,nonatomic,strong,readonly) NSString *revokeAccountId;
    
    @property(nonatomic,assign,readonly) V2NIMMessageRevokeType revokeType;
    
    @property(nullable,nonatomic,strong,readonly) NSString *serverExtension;
    
    @property(nullable,nonatomic,strong,readonly) NSString *callbackExtension;
    
    @property(nullable,nonatomic,strong,readonly) NSString *senderName;
    
    @end
    
    macOS/Windows
    C++struct V2NIMLastMessage {
    
        V2NIMLastMessageState lastMessageState{V2NIM_MESSAGE_STATE_DEFAULT};
    
        nstd::optional<V2NIMMessageRefer> messageRefer;
    
        nstd::optional<V2NIMMessageType> messageType;
    
        nstd::optional<uint32_t> subType;
    
        nstd::optional<V2NIMMessageSendingState> sendingState;
    
        nstd::string text;
    
        nstd::shared_ptr<V2NIMMessageAttachment> attachment;
    
        nstd::optional<nstd::string> revokeAccountId;
    
        nstd::optional<V2NIMMessageRevokeType> revokeType;
    
        nstd::optional<nstd::string> senderId;
    
        nstd::optional<nstd::string> senderName;
    
        nstd::optional<nstd::string> serverExtension;
    
        nstd::optional<nstd::string> callbackExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMLastMessage = {
    
      lastMessageState: V2NIMLastMessageState
      messageRefer: V2NIMMessageRefer
      messageType?: V2NIMMessageType
      subType?: number
      sendingState?: V2NIMMessageSendingState
      text?: string
      attachment?: Partial<V2NIMMessageAttachment>
      revokeAccountId?: string
      revokeType?: V2NIMMessageRevokeType
      serverExtension?: string
      callbackExtension?: string
      senderName?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMLastMessage {
    
      lastMessageState: V2NIMLastMessageState
      messageRefer: V2NIMMessageRefer
      messageType?: V2NIMMessageType
      subType?: number
      sendingState?: V2NIMMessageSendingState
      text?: string
      attachment?: Partial<V2NIMMessageAttachment>
      revokeAccountId?: string
      revokeType?: V2NIMMessageRevokeType
      serverExtension?: string
      callbackExtension?: string
      senderName?: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    lastMessageState V2NIMLastMessageState 最后一条消息状态。
    messageRefer V2NIMMessageRefer 最后一条消息的参考信息。
    messageType V2NIMMessageType 消息类型,消息状态为正常时该字段有效。
    subType int 自定义消息子类型,0 代表无消息子类型。消息状态为正常时该字段有效。
    sendingState V2NIMMessageSendingState 消息发送状态。消息状态为正常时该字段有效。
    text String 文本消息的内容或撤回消息时的附言。
    attachment V2NIMMessageAttachment 消息附件。消息状态为正常时该字段有效。
    revokeAccountId String 消息撤回者账号(accountId)。消息状态为撤回时该字段有效。
    revokeType V2NIMMessageRevokeType 消息撤回类型。消息状态为撤回时该字段有效。
    serverExtension String 服务端扩展字段,多端同步。
    callbackExtension String 第三方回调透传的自定义扩展字段。
    第三方回调功能需要在 网易云信控制台开通
    senderName String 消息发送者名称(好友备注/群成员昵称/用户昵称)
  • 若最后一条消息被撤回,则为撤回者相关名称。
  • 若当前账号为发送者,则该字段不存在。
  • V2NIMMessageQuickComment

    消息快捷评论对象。

    Android
    Javapublic interface V2NIMMessageQuickComment {
    
        V2NIMMessageRefer getMessageRefer();
    
        String getOperatorId();
    
        long getIndex();
    
        long getCreateTime();
    
        String getServerExtension();
    }
    
    iOS
    Objective-C@interface V2NIMMessageQuickComment : NSObject
    
    @property(nonatomic,strong,readwrite) V2NIMMessageRefer *messageRefer;
    
    @property(nonatomic,strong,readwrite) NSString *operatorId;
    
    @property(nonatomic,assign,readwrite) NSTimeInterval index;
    
    @property(nonatomic,assign,readwrite) NSTimeInterval createTime;
    
    @property(nonatomic,strong,readwrite) NSString *serverExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageQuickComment {
    
        V2NIMMessageRefer messageRefer;
    
        nstd::string operatorId;
    
        uint64_t index{0};
    
        nstd::optional<nstd::string> serverExtension;
    
        nstd::optional<uint64_t> createTime;
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageQuickComment {
    
      messageRefer: V2NIMMessageRefer
      operatorId: string
      index: number
      serverExtension: string
      createTime: number
      pushConfig?: V2NIMMessageQuickCommentPushConfig
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageQuickComment {
    
      messageRefer: V2NIMMessageRefer
      operatorId: string
      index: number
      serverExtension: string
      createTime: number
      pushConfig?: V2NIMMessageQuickCommentPushConfig
    }
    

    成员参数

    名称 类型 是否只读 说明
    messageRefer V2NIMMessageRefer 快捷评论的消息的参考信息。
    operatorId String 评论操作人账号(accountId),默认为空。
    index long 快捷评论索引,默认为 0。
    createTime long 评论时间戳。
    serverExtension String 服务端扩展字段,多端同步。

    V2NIMMessageQuickComment

    快捷评论推送配置。

    Android
    Javapublic class V2NIMMessageQuickCommentPushConfig {
    
        private final boolean pushEnabled;
        private final boolean needBadge;
        private final String pushTitle;
        private final String pushContent;
        private final String pushPayload;
    
        private V2NIMMessageQuickCommentPushConfig() {
            this(DEFAULT_PUSH_ENABLED, DEFAULT_NEED_BADGE, null, null, null);
        }
    
        private V2NIMMessageQuickCommentPushConfig(boolean pushEnabled, boolean needBadge, String pushTitle, String pushContent, String pushPayload) {
            this.pushEnabled = pushEnabled;
            this.needBadge = needBadge;
            this.pushTitle = pushTitle;
            this.pushContent = pushContent;
            this.pushPayload = pushPayload;
        }
    
        public boolean getPushEnabled() {
            return pushEnabled;
        }
    
        public boolean getNeedBadge() {
            return needBadge;
        }
    
        public String getPushTitle() {
            return pushTitle;
        }
    
        public String getPushContent() {
            return pushContent;
        }
    
        public String getPushPayload() {
            return pushPayload;
        }
    
        private static final boolean DEFAULT_PUSH_ENABLED = true;
        private static final boolean DEFAULT_NEED_BADGE = true;
    
        public static final class V2NIMMessageQuickCommentPushConfigBuilder {
            private boolean pushEnabled = DEFAULT_PUSH_ENABLED;
            private boolean needBadge = DEFAULT_NEED_BADGE;
            private String pushTitle;
            private String pushContent;
            private String pushPayload;
    
            private V2NIMMessageQuickCommentPushConfigBuilder() {
            }
    
            public static V2NIMMessageQuickCommentPushConfigBuilder builder() {
                return new V2NIMMessageQuickCommentPushConfigBuilder();
            }
    
            public V2NIMMessageQuickCommentPushConfigBuilder withPushEnabled(boolean pushEnabled) {
                this.pushEnabled = pushEnabled;
                return this;
            }
    
            public V2NIMMessageQuickCommentPushConfigBuilder withNeedBadge(boolean needBadge) {
                this.needBadge = needBadge;
                return this;
            }
    
            public V2NIMMessageQuickCommentPushConfigBuilder withPushTitle(String title) {
                this.pushTitle = title;
                return this;
            }
    
            public V2NIMMessageQuickCommentPushConfigBuilder withPushContent(String content) {
                this.pushContent = content;
                return this;
            }
    
            public V2NIMMessageQuickCommentPushConfigBuilder withPushPayload(String payload) {
                this.pushPayload = payload;
                return this;
            }
    
            public V2NIMMessageQuickCommentPushConfig build() {
                return new V2NIMMessageQuickCommentPushConfig(pushEnabled, needBadge, pushTitle, pushContent, pushPayload);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageQuickCommentPushConfig : NSObject
    
    @property(nonatomic,assign,readwrite) BOOL pushEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL needBadge;
    
    @property(nonatomic,strong,readwrite) NSString *title;
    
    @property(nonatomic,strong,readwrite) NSString *pushContent;
    
    @property(nonatomic,strong,readwrite) NSString *pushPayload;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageQuickCommentPushConfig {
    
        bool needPush{true};
        bool needBadge{true};
        nstd::string pushTitle;
        nstd::string pushContent;
        nstd::string pushPayload;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageQuickCommentPushConfig {
    
      pushEnabled?: boolean
      needBadge?: boolean
      title?: string
      pushContent?: string
      pushPayload?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageQuickCommentPushConfig {
    
      pushEnabled?: boolean
      needBadge?: boolean
      title?: string
      pushContent?: string
      pushPayload?: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    messageRefer V2NIMMessageRefer 快捷评论的消息的参考信息。
    operatorId String 评论操作人账号(accountId),默认为空。
    index long 快捷评论索引,默认为 0。
    createTime long 评论时间戳。
    serverExtension String 服务端扩展字段,多端同步。

    V2NIMMessagePin

    Pin 消息对象。

    Android
    Javapublic interface V2NIMMessagePin {
    
        V2NIMMessageRefer getMessageRefer();
    
        String getOperatorId();
    
        String getServerExtension();
    
        long getCreateTime();
    
        long getUpdateTime();
    }
    
    iOS
    Objective-C@interface V2NIMMessagePin : NSObject
    
    @property (nullable,nonatomic,strong) V2NIMMessageRefer *messageRefer;
    
    @property (nonatomic,strong) NSString *operatorId;
    
    @property (nonatomic,strong) NSString *serverExtension;
    
    @property (nonatomic,assign) NSTimeInterval createTime;
    
    @property (nonatomic,assign) NSTimeInterval updateTime;
    @end
    
    macOS/Windows
    C++struct V2NIMMessagePin {
    
        V2NIMMessageRefer messageRefer;
    
        nstd::string operatorId;
    
        nstd::optional<nstd::string> serverExtension;
    
        uint64_t createTime{0};
    
        uint64_t updateTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessagePin {
    
      messageRefer: V2NIMMessageRefer
    
      opeartorId: string
    
      serverExtension?: string
    
      createTime: number
    
      updateTime: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessagePin {
    
      messageRefer: V2NIMMessageRefer
      opeartorId: string
      serverExtension?: string
      createTime: number
      updateTime: number
    }
    
    

    成员参数

    名称 类型 是否只读 说明
    messageRefer V2NIMMessageRefer Pin 消息的参考信息。
    operatorId String 操作人账号(accountId),默认为空。
    createTime long Pin 消息时间戳。
    updateTime long 更新 Pin 消息时间戳。
    serverExtension String 服务端扩展字段,多端同步。

    V2NIMCollection

    消息收藏对象。

    Android
    Javapublic interface V2NIMCollection {
    
        String getCollectionId();
    
        int getCollectionType();
    
        String getCollectionData();
    
        String getServerExtension();
    
        long getCreateTime();
    
        long getUpdateTime();
    
        String getUniqueId();
    }
    
    iOS
    Objective-C@interface V2NIMCollection : NSObject
    
    @property (nullable,nonatomic,strong) NSString *collectionId;
    
    @property (nonatomic,assign) int collectionType;
    
    @property (nullable,nonatomic,strong,readonly) NSString *collectionData;
    
    @property (nullable,nonatomic,strong) NSString *serverExtension;
    
    @property (nonatomic,assign) NSTimeInterval createTime;
    
    @property (nonatomic,assign) NSTimeInterval updateTime;
    
    @property (nullable,nonatomic,strong) NSString *uniqueId;
    
    @end
    
    macOS/Windows
    C++struct V2NIMCollection {
    
        nstd::string collectionId;
    
        uint32_t collectionType{0};
    
        nstd::string collectionData;
    
        nstd::optional<nstd::string> serverExtension;
    
        uint64_t createTime{0};
    
        uint64_t updateTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMCollection {
    
      collectionId: string
    
      collectionType: number
    
      collectionData: string
    
      serverExtension?: string
    
      createTime: number
    
      updateTime: number
    
      uniqueId?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMCollection {
    
      collectionId: string
      collectionType: number
      collectionData: string
      serverExtension?: string
      createTime: number
      updateTime: number
    }
    

    成员参数

    名称 类型 是否只读 说明
    collectionId String 服务器消息收藏 ID
    collectionType int 自定义收藏类型,必须大于 0,默认为 0。
    collectionData String 收藏数据,上限为 20480 字节。
    createTime long 收藏时间戳。
    updateTime long 更新收藏时间戳。
    serverExtension String 服务端扩展字段,多端同步。长度上限为 1024 字节。
    uniqueId String 去重唯一 ID,如果 ID 相同,则不会新增收藏,只更新之前的收藏内容。

    V2NIMAddCollectionParams

    消息收藏配置参数。

    Android
    Javapublic class V2NIMAddCollectionParams {
    
        public int getCollectionType() {
            return collectionType;
        }
    
        public String getCollectionData() {
            return collectionData;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        @Override
        public String toString() {
            return "V2NIMAddCollectionParams{" +
                    "collectionType=" + collectionType +
                    ", collectionData='" + collectionData + '\'' +
                    ", serverExtension='" + serverExtension + '\'' +
                    '}';
        }
    
        public static final class V2NIMAddCollectionParamsBuilder {
    
            public static V2NIMAddCollectionParamsBuilder builder(int collectionType, String collectionData) {
                return new V2NIMAddCollectionParamsBuilder(collectionType, collectionData);
            }
    
            public V2NIMAddCollectionParamsBuilder withServerExtension(String serverExtension) {
                this.serverExtension = serverExtension;
                return this;
            }
    
            public V2NIMAddCollectionParams build() {
                return new V2NIMAddCollectionParams(collectionType, collectionData, serverExtension);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMAddCollectionParams : NSObject
    
    @property (nonatomic,assign) int collectionType;
    
    @property (nonnull,nonatomic,strong) NSString *collectionData;
    
    @property (nonnull,nonatomic,strong) NSString *serverExtension;
    
    @property (nullable,nonatomic,strong) NSString *uniqueId;
    
    @end
    
    macOS/Windows
    C++struct V2NIMAddCollectionParams {
    
        uint32_t collectionType{0};
    
        nstd::string collectionData;
    
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMAddCollectionParams {
    
      collectionType: number
    
      collectionData: string
    
      serverExtension?: string
    
      uniqueId?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMAddCollectionParams {
    
      collectionType: number
      collectionData: string
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    collectionType int - 自定义收藏类型,必须大于 0,否则返回 191004 参数错误。
    collectionData String - 收藏数据,上限为 20480 字节。
    serverExtension String - 服务端扩展字段。必须为 JSON 格式封装,多端同步,长度上限为 1024 字节。
    uniqueId String - 去重唯一 ID,如果 ID 相同,则不会新增收藏,只更新之前的收藏内容。

    V2NIMCollectionOption

    分页查询消息收藏选项。

    Android
    Javapublic class V2NIMCollectionOption {
    
        public long getBeginTime() {
            return beginTime;
        }
    
        public long getEndTime() {
            return endTime;
        }
    
        public V2NIMCollection getAnchorCollection() {
            return anchorCollection;
        }
    
        public V2NIMQueryDirection getDirection() {
            if (direction == null) {
                return DEFAULT_DIRECTION;
            } else {
                return direction;
            }
        }
    
        public int getLimit() {
            return limit;
        }
    
        public int getCollectionType() {
            return collectionType;
        }
    
        @Override
        public String toString() {
            return "V2NIMCollectionOption{" +
                    "beginTime=" + beginTime +
                    ", endTime=" + endTime +
                    ", anchorCollection=" + anchorCollection +
                    ", direction=" + direction +
                    ", limit=" + limit +
                    ", collectionType=" + collectionType +
                    '}';
        }
    
            public static V2NIMCollectionOptionBuilder builder() {
                return new V2NIMCollectionOptionBuilder();
            }
    
            public V2NIMCollectionOptionBuilder withBeginTime(long beginTime) {
                this.beginTime = beginTime;
                return this;
            }
    
            public V2NIMCollectionOptionBuilder withEndTime(long endTime) {
                this.endTime = endTime;
                return this;
            }
    
            public V2NIMCollectionOptionBuilder withDirection(V2NIMQueryDirection direction) {
                this.direction = direction;
                return this;
            }
    
            public V2NIMCollectionOptionBuilder withAnchorCollection(V2NIMCollection anchorCollection) {
                this.anchorCollection = anchorCollection;
                return this;
            }
    
            public V2NIMCollectionOptionBuilder withLimit(int limit) {
                this.limit = limit;
                return this;
            }
    
            public V2NIMCollectionOptionBuilder withCollectionType(int collectionType) {
                this.collectionType = collectionType;
                return this;
            }
    
            public V2NIMCollectionOption build() {
                return new V2NIMCollectionOption(beginTime, endTime, anchorCollection, direction, limit, collectionType);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMCollectionOption : NSObject
    
    @property (nonatomic,assign) NSTimeInterval beginTime;
    
    @property (nonatomic,assign) NSTimeInterval endTime;
    
    @property (nonatomic,assign) V2NIMQueryDirection direction;
    
    @property (nonatomic,strong) V2NIMCollection *anchorCollection;
    
    @property (nonatomic,assign) int limit;
    
    @property (nonatomic,assign) int collectionType;
    
    @property (nonatomic,assign) NSInteger excludeId;
    
    @end
    
    macOS/Windows
    C++struct V2NIMCollectionOption {
    
        uint64_t beginTime{0};
    
        uint64_t endTime{0};
    
        nstd::optional<V2NIMCollection> anchorCollection;
    
        V2NIMQueryDirection direction{V2NIM_QUERY_DIRECTION_DESC};
    
        uint32_t limit{V2NIM_DEFAULT_COLLECTION_LIST_LIMIT};
    
        uint32_t collectionType{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMCollectionOption {
    
      beginTime?: number
    
      endTime?: number
    
      anchorCollection?: V2NIMCollection
    
      direction?: V2NIMQueryDirection
    
      limit?: number
    
      collectionType?: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMCollectionOption {
    
      beginTime?: number
      endTime?: number
      anchorCollection?: V2NIMCollection
      direction?: V2NIMQueryDirection
      limit?: number
      collectionType?: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    beginTime long 0 查询开始时间。该字段必须小于等于 endTime
    endTime long 0 查询结束时间。该字段必须大于等于 beginTime,默认为系统当前时间。
    anchorCollection Optional<V2NIMCollection> - 查询的消息锚点。查询结果不包含该锚点消息。
  • 该字段为空,则以 [beginTime,endTime] 为查询范围。
  • 该字段不为空:
    • directionDESC,如果 endTime 为 0,则以 anchorCollection 对应的时间戳为准。如果 endTime 不为 0,则必须与 anchorCollection 时间相同,否则返回 191004 参数错误。
    • directionASC,如果 beginTime 为 0,则以 anchorCollection 的时间戳为准。如果 beiginTime 不为 0,则必须与 anchorCollection 时间相同,否则返回 191004 参数错误。
  • direction V2NIMQueryDirection V2NIM_QUERY_DIRECTION_DESC 查询方向:按照时间升序或降序。
    limit int 100 本次查询条数上限,取值范围为 [0,200)。大于等于 200 则返回 191004 参数错误,小于 0 则默认为 100。
    collectionType int 0,即查询所有类型 收藏类型。

    V2NIMSendMessageParams

    消息发送参数配置。

    Android
    Javapublic class V2NIMSendMessageParams {
    
        private final V2NIMMessageConfig messageConfig;
        private final V2NIMMessageRouteConfig routeConfig;
        private final V2NIMMessagePushConfig pushConfig;
        private final V2NIMMessageAntispamConfig antispamConfig;
        private final V2NIMMessageRobotConfig robotConfig;
        private final V2NIMMessageAIConfigParams    aiConfig;
        private final V2NIMMessageTargetConfig targetConfig;
        private final boolean clientAntispamEnabled;
        private final String clientAntispamReplace;
        private V2NIMSendMessageParams() {
            this(
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    DEFAULT_CLIENT_ANTISPAM_ENABLED,
                    DEFAULT_CLIENT_ANTISPAM_REPLACE);
        }
    
        private V2NIMSendMessageParams(V2NIMMessageConfig messageConfig, V2NIMMessageRouteConfig routeConfig, V2NIMMessagePushConfig pushConfig, V2NIMMessageAntispamConfig antispamConfig, V2NIMMessageRobotConfig robotConfig,V2NIMMessageAIConfigParams aiConfig, V2NIMMessageTargetConfig targetConfig, boolean clientAntispamEnabled, String clientAntispamReplace) {
            this.messageConfig = messageConfig;
            this.routeConfig = routeConfig;
            this.pushConfig = pushConfig;
            this.antispamConfig = antispamConfig;
            this.robotConfig = robotConfig;
            this.aiConfig = aiConfig;
            this.targetConfig = targetConfig;
            this.clientAntispamEnabled = clientAntispamEnabled;
            this.clientAntispamReplace = clientAntispamReplace;
        }
    
        public V2NIMMessageConfig getMessageConfig() {
            return messageConfig;
        }
    
        public V2NIMMessageRouteConfig getRouteConfig() {
            return routeConfig;
        }
    
        public V2NIMMessagePushConfig getPushConfig() {
            return pushConfig;
        }
    
        public V2NIMMessageAntispamConfig getAntispamConfig() {
            return antispamConfig;
        }
    
        public V2NIMMessageRobotConfig getRobotConfig() {
            return robotConfig;
        }
    
        public V2NIMMessageAIConfigParams getAIConfig() {
            return aiConfig;
        }
    
        public V2NIMMessageTargetConfig getTargetConfig() {
            return targetConfig;
        }
    
        public boolean isClientAntispamEnabled() {
            return clientAntispamEnabled;
        }
    
        public String getClientAntispamReplace() {
            return clientAntispamReplace;
        }
    
        @Override
        public String toString() {
            return "V2NIMSendMessageParams{" +
                    "messageConfig=" + messageConfig +
                    ", routeConfig=" + routeConfig +
                    ", pushConfig=" + pushConfig +
                    ", antispamConfig=" + antispamConfig +
                    ", robotConfig=" + robotConfig +
                    ", clientAntispamEnabled=" + clientAntispamEnabled +
                    ", clientAntispamReplace='" + clientAntispamReplace + '\'' +
                    '}';
        }
    
        private final static boolean DEFAULT_CLIENT_ANTISPAM_ENABLED = false;
        private final static String DEFAULT_CLIENT_ANTISPAM_REPLACE = "";
    
        /**
         * Builder for {@link V2NIMSendMessageParams}
         */
        public static final class V2NIMSendMessageParamsBuilder {
            private V2NIMMessageConfig messageConfig;
            private V2NIMMessageRouteConfig routeConfig;
            private V2NIMMessagePushConfig pushConfig;
            private V2NIMMessageAntispamConfig antispamConfig;
            private V2NIMMessageRobotConfig robotConfig;
            private V2NIMMessageAIConfigParams aiConfig;
            private V2NIMMessageTargetConfig targetConfig;
            private boolean clientAntispamEnabled = DEFAULT_CLIENT_ANTISPAM_ENABLED;
            private String clientAntispamReplace = DEFAULT_CLIENT_ANTISPAM_REPLACE;
    
            private V2NIMSendMessageParamsBuilder() {
            }
    
            /**
             * Create a new {@link V2NIMSendMessageParamsBuilder} instance
             * @return
             */
            public static V2NIMSendMessageParamsBuilder builder() {
                return new V2NIMSendMessageParamsBuilder();
            }
    
            /**
             * Set the message config
             * @param messageConfig the message config
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withMessageConfig(V2NIMMessageConfig messageConfig) {
                this.messageConfig = messageConfig;
                return this;
            }
    
            /**
             * Set the route config
             * @param routeConfig the route config
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withRouteConfig(V2NIMMessageRouteConfig routeConfig) {
                this.routeConfig = routeConfig;
                return this;
            }
            /**
             * Set the push config
             * @param pushConfig the push config
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withPushConfig(V2NIMMessagePushConfig pushConfig) {
                this.pushConfig = pushConfig;
                return this;
            }
            /**
             * Set the antispam config
             * @param antispamConfig the antispam config
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
                this.antispamConfig = antispamConfig;
                return this;
            }
            /**
             * Set the robot config
             * @param robotConfig the robot config
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withRobotConfig(V2NIMMessageRobotConfig robotConfig) {
                this.robotConfig = robotConfig;
                return this;
            }
            /**
             * Set the client antispam enabled
             * @param clientAntispamEnabled the client antispam enabled
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withClientAntispamEnabled(boolean clientAntispamEnabled) {
                this.clientAntispamEnabled = clientAntispamEnabled;
                return this;
            }
            /**
             * Set the client antispam replace
             * @param clientAntispamReplace the client antispam replace
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withClientAntispamReplace(String clientAntispamReplace) {
                this.clientAntispamReplace = clientAntispamReplace;
                return this;
            }
            /**
             * Set the AI config
             * @param aiConfig the AI config
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withAIConfig(V2NIMMessageAIConfigParams aiConfig) {
                this.aiConfig = aiConfig;
                return this;
            }
            /**
             * Set the target config
             * @param targetConfig the target config
             * @return V2NIMSendMessageParamsBuilder
             */
            public V2NIMSendMessageParamsBuilder withTargetConfig(V2NIMMessageTargetConfig targetConfig) {
                this.targetConfig = targetConfig;
                return this;
            }
    
            public V2NIMSendMessageParams build() {
                return new V2NIMSendMessageParams(messageConfig, routeConfig, pushConfig, antispamConfig, robotConfig,aiConfig,targetConfig, clientAntispamEnabled, clientAntispamReplace);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMSendMessageParams : NSObject<NSCopying>
    
    @property(nonatomic,strong,readwrite) V2NIMMessageConfig *messageConfig;
    
    @property(nonatomic,strong,readwrite) V2NIMMessageRouteConfig *routeConfig;
    
    @property(nonatomic,strong,readwrite) V2NIMMessagePushConfig *pushConfig;
    
    @property(nonatomic,strong,readwrite) V2NIMMessageAntispamConfig *antispamConfig;
    
    @property(nonatomic,strong,readwrite) V2NIMMessageRobotConfig *robotConfig;
    
    @property(nullable,nonatomic,strong,readwrite) V2NIMMessageAIConfigParams *aiConfig;
    
    @property(nullable,nonatomic,strong,readwrite) V2NIMMessageTargetConfig *targetConfig;
    
    @property(nonatomic, assign, readwrite) BOOL clientAntispamEnabled;
    
    @property(nullable,nonatomic,strong,readwrite) NSString *clientAntispamReplace;
    
    @end
    
    macOS/Windows
    C++struct V2NIMSendMessageParams {
        V2NIMMessageConfig messageConfig;
        V2NIMMessageRouteConfig routeConfig;
        V2NIMMessagePushConfig pushConfig;
        V2NIMMessageAntispamConfig antispamConfig;
        V2NIMMessageRobotConfig robotConfig;
        bool clientAntispamEnabled{false};
        nstd::string clientAntispamReplace;
        nstd::optional<V2NIMMessageAIConfigParams> aiConfig;
        nstd::optional<V2NIMMessageTargetConfig> targetConfig;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMSendMessageParams {
      messageConfig?: V2NIMMessageConfig
      routeConfig?: V2NIMMessageRouteConfig
      pushConfig?: V2NIMMessagePushConfig
      antispamConfig?: V2NIMMessageAntispamConfig
      robotConfig?: V2NIMMessageRobotConfig
      aiConfig?: V2NIMMessageAIConfigParams
      targetConfig?: V2NIMMessageTargetConfig
      clientAntispamEnabled?: boolean
      clientAntispamReplace?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMSendMessageParams {
      messageConfig?: V2NIMMessageConfig
      routeConfig?: V2NIMMessageRouteConfig
      pushConfig?: V2NIMMessagePushConfig
      antispamConfig?: V2NIMMessageAntispamConfig
      robotConfig?: V2NIMMessageRobotConfig
      clientAntispamEnabled?: boolean
      clientAntispamReplace?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    messageConfig V2NIMMessageConfig - 消息相关配置。
    routeConfig V2NIMMessageRouteConfig - 消息事件抄送相关配置。
    pushConfig V2NIMMessagePushConfig - 消息第三方推送相关配置。
    第三方推送功能需要在 网易云信控制台配置
    antispamConfig V2NIMMessageAntispamConfig - 消息反垃圾相关配置,包括本地反垃圾或安全通配置,均需要在 网易云信控制台开通
    robotConfig V2NIMMessageRobotConfig - 消息机器人相关配置。
    该参数信息需要与控制台机器人配置信息一致。
    clientAntispamEnabled boolean false 是否启用本地反垃圾。
  • 仅对文本消息生效
  • 如果开启本地发垃圾,发送消息时会进行本地反垃圾检测,完成后返回检测结果 V2NIMClientAntispamOperatorType
    • 0:检测通过,可以发送该消息。
    • 1:发送替换后的文本消息。
    • 2:检测不通过,消息发送失败,返回本地错误码。
    • 3:消息发送后,由服务端拦截
  • clientAntispamReplace String clientAntispamEnabled 为 true 则必填 "" 反垃圾命中后替换的文本。
    aiConfig V2NIMMessageAIConfigParams - 数字人请求 LLM 大模型的相关参数。
    targetConfig V2NIMMessageTargetConfig - 发送群消息时,需要指定接收者的定向消息配置参数。

    V2NIMMessageTargetConfig

    群定向消息数据结构。

    Android
    Javapublic class V2NIMMessageTargetConfig implements Serializable {
    
      private boolean      inclusive        = true;
      private List<String> receiverIds;
      private boolean      newMemberVisible = false;
      public V2NIMMessageTargetConfig() {
      }
    
      public V2NIMMessageTargetConfig(List<String> receiverIds) {
       setReceiverIds(receiverIds);
      }
    
      public V2NIMMessageTargetConfig(boolean inclusive, List<String> receiverIds, boolean newMemberVisible) {
       this(receiverIds);
       this.inclusive = inclusive;
       this.newMemberVisible = newMemberVisible;
      }
    
      public boolean isInclusive() {
       return this.inclusive;
      }
    
      public void setInclusive(boolean inclusive) {
       this.inclusive = inclusive;
      }
    
      public List<String> getReceiverIds() {
       return this.receiverIds;
      }
    
      public void setReceiverIds(List<String> receiverIds) {
       if(CollectionUtil.isEmpty(receiverIds)) {
        this.receiverIds = null;
       }else{
        this.receiverIds = new ArrayList<>(receiverIds.size());
        for(String id : receiverIds){
         if(id != null && !id.isEmpty() && !id.equals(SDKCacheUI.getAccount())){
          this.receiverIds.add(id);
         }
        }
       }
      }
    
      public boolean isNewMemberVisible() {
       return this.newMemberVisible;
      }
    
      public void setNewMemberVisible(boolean newMemberVisible) {
       this.newMemberVisible = newMemberVisible;
      }
    
      public boolean isValid() {
       // receiverIds 不能为空
       if(CollectionUtil.isEmpty(receiverIds)){
        return false;
       }
       return true;
      }
    }
    
    iOS
    Objective-C@interface V2NIMMessageTargetConfig : NSObject<NSCopying>
    
    @property(nonatomic,assign,readwrite) BOOL inclusive;
    
    @property(nonatomic,strong,readwrite) NSArray<NSString *> *receiverIds;
    
    @property(nonatomic,assign,readwrite) BOOL newMemberVisible;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageTargetConfig {
        bool inclusive{true};
        nstd::vector<nstd::string> receiverIds;
        bool newMemberVisible{false};
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMMessageTargetConfig {
    
      receiverIds: string[]
    
      inclusive: boolean
    
      newMemberVisible?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    inclusive Boolean true 群定向消息成员列表是否为可见列表。默认为 true,即 receiver_account_ids 为可见(接收)列表;receiver_account_ids 之外的成员为不可见列表。若设置为 false,则相反。发送超大群消息时,不能将 inclusive 设置为 false。
    receiverIds List<String> - 群定向消息成员列表,即指定接收群消息的群成员列表。
  • inclusive 为 true,当前列表为可见(接收)列表。
  • inclusive 为 false,当前列表为不可见(不接收)列表。
  • 列表中不能包含消息发送者,消息发送者默认为可见。
  • 列表中不能包含非法账号、非群成员账号,也不能为空。
  • 列表中最多可以传入 100 个用户账号。
  • newMemberVisible Boolean false 新进群成员是否可见该消息。默认为 false,即新进群成员不可以查看该群定向消息。若设置为 true,则新进群成员若可以查询该定向消息,可以通过云端历史相关接口查询到该消息。
  • inclusive 为 true 时,不能同时设置 visible_to_new_member 为 true。即发送定向列表为可见的定向消息时,只能由定向列表中成员接收和查看。
  • 发送超大群消息时,不能将 visible_to_new_member 设置为 true。
  • V2NIMModifyMessageParams

    消息更新参数配置。

    Android
    Javapublic class V2NIMModifyMessageParams {
      private Integer subType;
      private String text;
      private V2NIMMessageAttachment attachment;
      private String serverExtension;
      private V2NIMMessageAntispamConfig antispamConfig;
      private V2NIMMessageRouteConfig routeConfig;
      private V2NIMMessagePushConfig pushConfig;
      private boolean clientAntispamEnabled = false;
      private String clientAntispamReplace = "";
      public Integer getSubType() {
       return this.subType;
      }
      public void setSubType(Integer subType) {
       this.subType = subType;
      }
      public String getText() {
       return this.text;
      }
      public void setText(String text) {
       this.text = text;
      }
      public V2NIMMessageAttachment getAttachment() {
       return this.attachment;
      }
      public void setAttachment(V2NIMMessageAttachment attachment) {
       this.attachment = attachment;
      }
      public String getServerExtension() {
       return this.serverExtension;
      }
      public void setServerExtension(String serverExtension) {
       this.serverExtension = serverExtension;
      }
      public V2NIMMessageAntispamConfig getAntispamConfig() {
       if (this.antispamConfig == null) {
        return V2NIMMessageAntispamConfig.V2NIMMessageAntispamConfigBuilder.builder().build();
       } else {
        return this.antispamConfig;
       }
      }
      public void setAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
       this.antispamConfig = antispamConfig;
      }
      public V2NIMMessageRouteConfig getRouteConfig() {
       if (this.routeConfig == null) {
        return V2NIMMessageRouteConfig.V2NIMMessageRouteConfigBuilder.builder().build();
       } else {
        return this.routeConfig;
       }
      }
      public void setRouteConfig(V2NIMMessageRouteConfig routeConfig) {
       this.routeConfig = routeConfig;
      }
      public V2NIMMessagePushConfig getPushConfig() {
       if (this.pushConfig == null) {
        return V2NIMMessagePushConfig.V2NIMMessagePushConfigBuilder.builder().build();
       } else {
        return this.pushConfig;
       }
      }
      public void setPushConfig(V2NIMMessagePushConfig pushConfig) {
       this.pushConfig = pushConfig;
      }
      public boolean isClientAntispamEnabled() {
       return this.clientAntispamEnabled;
      }
      public void setClientAntispamEnabled(boolean clientAntispamEnabled) {
       this.clientAntispamEnabled = clientAntispamEnabled;
      }
      public String getClientAntispamReplace() {
       return this.clientAntispamReplace;
      }
      public void setClientAntispamReplace(String clientAntispamReplace) {
       this.clientAntispamReplace = clientAntispamReplace;
      }
    
      public boolean isValid(){
       if(subType != null && subType < 0){
        return false;
       }
       if(subType != null){
        return true;
       }
       if(text != null){
        return true;
       }
       if(attachment != null){
        return true;
       }
       if(serverExtension != null){
        return true;
       }
       return false;
      }
    
      /**
       * V2NIMModifyMessageParams 构造器
       */
      public static final class V2NIMModifyMessageParamsBuilder {
    
       private Integer subType;
    
       private String text;
    
       private V2NIMMessageAttachment attachment;
    
       private String serverExtension;
    
       private V2NIMMessageAntispamConfig antispamConfig;
    
       private V2NIMMessageRouteConfig routeConfig;
    
       private V2NIMMessagePushConfig pushConfig;
    
       private boolean clientAntispamEnabled;
    
       private String clientAntispamReplace;
    
       private V2NIMModifyMessageParamsBuilder() {
       }
    
       /**
        * V2NIMModifyMessageParams 构造器
        * @return V2NIMModifyMessageParamsBuilder
        */
       public static V2NIMModifyMessageParamsBuilder builder() {
        return new V2NIMModifyMessageParamsBuilder();
       }
    
       /**
        * 设置消息子类型
        * @param subType 消息子类型
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withSubType(int subType) {
        this.subType = subType;
        return this;
       }
    
       /**
        * 设置消息内容
        * @param text 消息内容
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withText(String text) {
        this.text = text;
        return this;
       }
    
       /**
        * 设置消息附属附件
        * @param attachment 消息附属附件
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withAttachment(V2NIMMessageAttachment attachment) {
        this.attachment = attachment;
        return this;
       }
    
       /**
        * 设置消息服务端扩展
        * @param serverExtension 消息服务端扩展
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withServerExtension(String serverExtension) {
        this.serverExtension = serverExtension;
        return this;
       }
    
       /**
        * 设置反垃圾相关配置
        * @param antispamConfig 反垃圾相关配置
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
        this.antispamConfig = antispamConfig;
        return this;
       }
    
       /**
        * 设置路由抄送相关配置
        * @param routeConfig 路由抄送相关配置
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withRouteConfig(V2NIMMessageRouteConfig routeConfig) {
        this.routeConfig = routeConfig;
        return this;
       }
    
       /**
        * 设置推送相关配置
        * @param pushConfig 推送相关配置
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withPushConfig(V2NIMMessagePushConfig pushConfig) {
        this.pushConfig = pushConfig;
        return this;
       }
    
       /**
        * 设置是否启用本地反垃圾
        * @param clientAntispamEnabled 是否启用本地反垃圾
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withClientAntispamEnabled(boolean clientAntispamEnabled) {
        this.clientAntispamEnabled = clientAntispamEnabled;
        return this;
       }
    
       /**
        * 设置反垃圾命中后替换的文本
        * @param clientAntispamReplace 反垃圾命中后替换的文本
        * @return V2NIMModifyMessageParamsBuilder
        */
       public V2NIMModifyMessageParamsBuilder withClientAntispamReplace(String clientAntispamReplace) {
        this.clientAntispamReplace = clientAntispamReplace;
        return this;
       }
    
       /**
        * 构建 V2NIMModifyMessageParams 对象
        * @return V2NIMModifyMessageParams
        */
       public V2NIMModifyMessageParams build() {
        V2NIMModifyMessageParams params = new V2NIMModifyMessageParams();
        params.setSubType(subType);
        params.setText(text);
        params.setAttachment(attachment);
        params.setServerExtension(serverExtension);
        params.setAntispamConfig(antispamConfig);
        params.setRouteConfig(routeConfig);
        params.setPushConfig(pushConfig);
        params.setClientAntispamEnabled(clientAntispamEnabled);
        params.setClientAntispamReplace(clientAntispamReplace);
        return params;
       }
      }
    }
    
    iOS
    Objective-C@interface V2NIMModifyMessageParams : NSObject
    @property (nonatomic, assign) NSInteger subType;
    @property (nonatomic, copy) NSString *text;
    @property (nonatomic, strong) V2NIMMessageAttachment *attachment;
    @property (nonatomic, copy) NSString *serverExtension;
    @property (nonatomic, strong) V2NIMMessageAntispamConfig *antispamConfig;
    @property (nonatomic, strong) V2NIMMessageRouteConfig *routeConfig;
    @end
    
    macOS/Windows
    C++struct V2NIMModifyMessageParams {
        nstd::optional<uint32_t> subType;
        nstd::optional<nstd::string> text;
        nstd::shared_ptr<V2NIMMessageAttachment> attachment;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<V2NIMMessageAntispamConfig> antispamConfig;
        nstd::optional<V2NIMMessageRouteConfig> routeConfig;
        nstd::optional<V2NIMMessagePushConfig> pushConfig;
        bool clientAntispamEnabled{false};
        nstd::optional<nstd::string> clientAntispamReplace;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMModifyMessageParams = {
    
      subType?: number
      text?: string
      /**
       * 消息附属附件。注: 仅允许定位、tip、自定义消息更新附件信息
       */
      attachment?: V2NIMMessageAttachment
      serverExtension?: string
      antispamConfig?: V2NIMMessageAntispamConfig
      routeConfig?: V2NIMMessageRouteConfig
      pushConfig?: V2NIMMessagePushConfig
      clientAntispamEnabled?: boolean
      clientAntispamReplace?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    subType int/undefined - 自定义消息子类型,0 表示无消息子类型。
    text String - 消息文本内容,仅文本类型的消息有该字段。
    attachment V2NIMMessageAttachment - 消息附件,仅图片、语音、视频、文件类型消息有该字段。根据消息类型继承实现。
    serverExtension String - 消息服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    routeConfig V2NIMMessageRouteConfig - 消息事件抄送相关配置。
    pushConfig V2NIMMessagePushConfig - 消息第三方推送相关配置。
    第三方推送功能需要在 网易云信控制台配置
    antispamConfig V2NIMMessageAntispamConfig - 消息反垃圾相关配置,包括本地反垃圾或安全通配置,均需要在 网易云信控制台开通
    clientAntispamEnabled boolean false 是否启用本地反垃圾。
  • 仅对文本消息生效
  • 如果开启本地发垃圾,发送消息时会进行本地反垃圾检测,完成后返回检测结果 V2NIMClientAntispamOperatorType
    • 0:检测通过,可以发送该消息。
    • 1:发送替换后的文本消息。
    • 2:检测不通过,消息发送失败,返回本地错误码。
    • 3:消息发送后,由服务端拦截
  • clientAntispamReplace String clientAntispamEnabled 为 true 则必填 "" 反垃圾命中后替换的文本。

    V2NIMMessageRefer

    消息参考信息。

    Android
    Javapublic interface V2NIMMessageRefer extends Serializable {
    
        String getSenderId();
    
        String getReceiverId();
    
        String getMessageClientId();
    
        String getMessageServerId();
    
        V2NIMConversationType getConversationType();
    
        String getConversationId();
    
        long getCreateTime();
    }
    
    iOS
    Objective-C@interface V2NIMMessageRefer : NSObject
    
    @property (nullable,nonatomic,strong) NSString *senderId;
    
    @property (nullable,nonatomic,strong) NSString *receiverId;
    
    @property (nullable,nonatomic,strong) NSString *messageClientId;
    
    @property (nullable,nonatomic,strong) NSString *messageServerId;
    
    @property (nonatomic,assign) V2NIMConversationType conversationType;
    
    @property (nullable,nonatomic,strong) NSString *conversationId;
    
    @property (nonatomic,assign) NSTimeInterval createTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageRefer {
    
        nstd::string senderId;
    
        nstd::string receiverId;
    
        nstd::string messageClientId;
    
        nstd::string messageServerId;
    
        V2NIMConversationType conversationType{V2NIM_CONVERSATION_TYPE_UNKNOWN};
    
        nstd::string conversationId;
    
        uint64_t createTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageRefer {
    
      senderId: string
    
      receiverId: string
    
      messageClientId: string
    
      messageServerId: string
    
      createTime: number
    
      conversationType: V2NIMConversationType
    
      conversationId: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageRefer {
    
      senderId: string
      receiverId: string
      messageClientId: string
      messageServerId: string
      createTime: number
      conversationType: V2NIMConversationType
      conversationId: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    senderId String 消息发送方账号(accountId)
    receiverId String 消息接收方账号
  • 如果消息所属会话类型为单聊,该字段为聊天对象账号。
  • 如果消息所属会话类型为群组,该字段为群组 ID。
  • messageClientId String 客户端消息 ID,不多端同步。
    messageServerId String 服务端消息 ID,多端同步。
    conversationType V2NIMConversationType 会话类型。
    conversationId String 会话 ID
    createTime long 消息时间戳,单位毫秒。

    V2NIMMessageAttachment

    消息附件对象。

    Android
    Javapublic interface V2NIMMessageAttachment extends Serializable {
        String getRaw();
    }
    
    iOS
    Objective-C@interface V2NIMMessageAttachment: NSObject
    
    @property(nonnull,nonatomic,strong) NSString *raw;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageAttachment {
        nstd::string raw;
        virtual ~V2NIMMessageAttachment() = default;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageAttachment {
      raw: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageAttachment {
    
      raw: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    raw String - 消息附件,建议为 JSON 格式。

    V2NIMDownloadMessageAttachmentParams

    下载消息附件的请求配置参数。

    Android
    Javapublic class V2NIMDownloadMessageAttachmentParams {
    
        private final V2NIMMessageAttachment attachment;
    
        private final V2NIMDownloadAttachmentType type;
    
        private final V2NIMSize thumbSize;
    
        private final String messageClientId;
    
        private final String saveAs;
    
        private V2NIMDownloadMessageAttachmentParams(@NonNull V2NIMMessageAttachment attachment, @Nullable V2NIMDownloadAttachmentType type,
                                                     @Nullable V2NIMSize thumbSize, @Nullable String messageClientId,
                                                     @Nullable String saveAs) {
            this.attachment = attachment;
            this.type = type == null ? V2NIMDownloadAttachmentType.V2NIM_DOWNLOAD_ATTACHMENT_TYPE_SOURCE : type;
            this.thumbSize = thumbSize;
            this.messageClientId = messageClientId;
            this.saveAs = saveAs;
        }
    
        public V2NIMMessageAttachment getAttachment() {
            return attachment;
        }
    
        public V2NIMDownloadAttachmentType getType() {
            return type;
        }
    
        public V2NIMSize getThumbSize() {
            return thumbSize;
        }
    
        public String getMessageClientId() {
            return messageClientId;
        }
    
        public String getSaveAs() {
            return saveAs;
        }
    
        @Override
        public String toString() {
            return "V2NIMDownloadMessageAttachmentParams{" +
                    "attachment=" + attachment +
                    ", type=" + type +
                    ", thumbSize=" + thumbSize +
                    ", messageClientId='" + messageClientId + '\'' +
                    ", saveAs='" + saveAs + '\'' +
                    '}';
        }
    
        public static final class V2NIMDownloadMessageAttachmentParamsBuilder {
            private V2NIMMessageAttachment attachment;
            private V2NIMDownloadAttachmentType type;
            private V2NIMSize thumbSize;
            private String messageClientId;
            private String saveAs;
    
            public V2NIMDownloadMessageAttachmentParamsBuilder(@NonNull V2NIMMessageAttachment attachment) {
                this.attachment = attachment;
            }
    
            public V2NIMDownloadMessageAttachmentParamsBuilder type(V2NIMDownloadAttachmentType type) {
                this.type = type;
                return this;
            }
    
            public V2NIMDownloadMessageAttachmentParamsBuilder thumbSize(V2NIMSize thumbSize) {
                this.thumbSize = thumbSize;
                return this;
            }
    
            public V2NIMDownloadMessageAttachmentParamsBuilder messageClientId(String messageClientId) {
                this.messageClientId = messageClientId;
                return this;
            }
    
            public V2NIMDownloadMessageAttachmentParamsBuilder saveAs(String saveAs) {
                this.saveAs = saveAs;
                return this;
            }
    
            public V2NIMDownloadMessageAttachmentParams build() {
                return new V2NIMDownloadMessageAttachmentParams(attachment, type, thumbSize, messageClientId, saveAs);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMDownloadMessageAttachmentParams : NSObject
    
    @property (nonatomic,strong,nonnull) V2NIMMessageAttachment *attachment;
    
    @property (nonatomic,assign) V2NIMDownloadAttachmentType type;
    
    @property (nonatomic,strong,nullable) V2NIMSize *thumbSize;
    
    @property (nonatomic,copy,nullable) NSString *messageClientId;
    
    @property (nonatomic,copy,nullable) NSString *saveAs;
    
    - (instancetype)initWithAttachment:(V2NIMMessageAttachment *)attachment;
    @end
    
    macOS/Windows
    C++struct V2NIMDownloadMessageAttachmentParams {
        nstd::shared_ptr<V2NIMMessageAttachment> attachment;
        V2NIMDownloadAttachmentType type{V2NIM_DOWNLOAD_ATTACHMENT_TYPE_SOURCE};
        nstd::optional<V2NIMSize> thumbSize;
        nstd::optional<nstd::string> messageClientId;
        nstd::optional<nstd::string> saveAs;
    };
    

    成员参数

    名称 类型 是否必填 默认值 说明
    attachment V2NIMMessageAttachment - 需要下载的附件。
    type V2NIMDownloadAttachmentType V2NIM_DOWNLOAD_ATTACHMENT_TYPE_SOURCE(原始文件) 下载附件的类型。包括原始文件、缩略图、视频封面。
    thumbSize V2NIMSize {150,0}
    内置默认值,不是在声明时指定的,而是运行时根据用户情况判断
    若下载的是缩略图或者视频封面,通过该参数指定缩略图大小或视频封面大小。
    messageClientId String - 若指定该参数并且下载的是原始文件,则 SDK 会将下载完成后的本地附件保存路径更新到消息数据库中,下一次查询时将直接返回对应的路径。
    saveAs String - 附件保存路径,如未指定 SDK 将下载到登录用户缓存目录,如指定该参数则以指定的路径为准。

    V2NIMGetMediaResourceInfoResult

    下载消息附件的返回结果。

    Android
    Javapublic interface V2NIMGetMediaResourceInfoResult {
    
        String getUrl();
    
        Map<String, String> getAuthHeaders();
    }
    
    iOS
    Objective-C@interface V2NIMGetMediaResourceInfoResult : NSObject
    
    @property(nonatomic,copy,readonly)NSString *url;
    
    @property(nonatomic,strong,readonly)NSDictionary *authHeaders;
    @end
    
    macOS/Windows
    C++struct V2NIMGetMediaResourceInfoResult {
        nstd::string url;
        nstd::map<nstd::string, nstd::string> authHeaders;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMGetMediaResourceInfoResult = {
    
      url: string
    }
    

    成员参数

    名称 类型 是否必填 是否只读 说明
    url String 附件资源完整下载地址。
    authHeaders Map<String, String> 下载该资源所需的鉴权信息,当列表为空时则代表不需要鉴权,若不为空则需要将该列表添加到请求时的 Header 中。

    V2NIMSize

    二维平面大小。

    Android
    Javapublic class V2NIMSize {
    
        private long width;
    
        private long height;
    
        public long getWidth() {
            return width;
        }
    
        public void setWidth(long width) {
            this.width = width;
        }
    
        public long getHeight() {
            return height;
        }
    
        public void setHeight(long height) {
            this.height = height;
        }
    
        @Override
        public String toString() {
            return "V2NIMSize{" +
                    "width=" + width +
                    ", height=" + height +
                    '}';
        }
    
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            V2NIMSize v2NIMSize = (V2NIMSize) o;
            return width == v2NIMSize.width && height == v2NIMSize.height;
        }
    
        @Override
        public int hashCode() {
            return Objects.hash(width, height);
        }
    }
    
    iOS
    Objective-C@interface V2NIMSize : NSObject
    
    @property (nonatomic,assign,readonly) NSInteger width;
    
    @property (nonatomic,assign,readonly) NSInteger height;
    
    - (instancetype)initWithWidth:(NSInteger)width height:(NSInteger)height;
    @end
    
    macOS/Windows
    C++struct V2NIMSize {
        int32_t width{0};
        int32_t height{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMSize = { height?: number; width?: number }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    width long 0 二维平面宽度。
    height long 0 二维平面高度。

    V2NIMMessageFileAttachment

    文件类型消息的附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMMessageFileAttachment extends V2NIMMessageAttachment {
    
        String getPath();
    
        long getSize();
    
        String getMd5();
    
        String getUrl();
    
        String getExt();
    
        String getName();
    
        @NonNull
        String getSceneName();
    
        V2NIMMessageAttachmentUploadState getUploadState();
    
    }
    
    iOS
    Objective-C@interface V2NIMMessageFileAttachment : V2NIMMessageAttachment
    
    @property(nullable,nonatomic,strong) NSString *path;
    
    @property(nonatomic,assign) NSUInteger size;
    
    @property(nonnull,nonatomic,strong) NSString *md5;
    
    @property(nullable,nonatomic,strong,readonly) NSString *url;
    
    @property(nullable,nonatomic,strong) NSString *ext;
    
    @property(nonnull,nonatomic,copy) NSString *name;
    
    @property(nullable,nonatomic,strong) NSString *sceneName;
    
    @property(nonatomic,assign) V2NIMMessageAttachmentUploadState uploadState;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageFileAttachment : public V2NIMMessageAttachment {
    
        uint64_t size{0};
    
        nstd::string md5;
    
        nstd::string url;
    
        nstd::string name;
    
        nstd::string path;
    
        nstd::string ext;
    
        nstd::string sceneName{V2NIM_STORAGE_SCENE_NAME_DEFAULT_IM};
    
        V2NIMMessageAttachmentUploadState uploadState{V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UNKNOWN};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageFileAttachment extends V2NIMMessageAttachment {
    
      file?: File
    
      path?: string
    
      size: number
    
      url: string
    
      md5?: string
    
      ext: string
    
      name: string
    
      sceneName: string
    
      uploadState: V2NIMMessageAttachmentUploadState
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageFileAttachment extends V2NIMMessageAttachment {
    
      path?: string
      size: number
      url: string
      md5?: string
      ext: string
      name: string
      sceneName: string
      uploadState: V2NIMMessageAttachmentUploadState
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    path String 除 Web 端外,其他端均为必填。 - 附件本地路径。
    请确保该路径存在且可用,SDK 会根据该字段判断附件是否存在。
    file Web File null Web File 对象。
  • Web 小程序不支持该字段。
  • 必须和 path 选其一设置。
  • size long - 文件大小。
    md5 String - 文件内容 MD5 值。
    url String - - 文件服务器路径。
    ext String null 文件扩展名,例如:.png.txt 等。
    name String - 文件显示名。包含扩展名,例如:1.png2.txt 等。
    sceneName String - V2NIMStorageSceneConfig.DEFAULT_IM 对应的场景名 网易对象存储 NOS 文件存储场景名。若使用自定义的存储场景,需要先调用 V2NIMStorageService.addCustomStorageScene 添加自定义存储场景。
    uploadState V2NIMMessageAttachmentUploadState - - 消息附件上传状态。

    V2NIMMessageImageAttachment

    图片附件对象,继承自 V2NIMMessageFileAttachment

    Android
    Javapublic interface V2NIMMessageImageAttachment extends V2NIMMessageFileAttachment {
    
        int getWidth();
    
        int getHeight();
    }
    
    iOS
    Objective-C@interface V2NIMMessageImageAttachment : V2NIMMessageFileAttachment
    
    @property(nonatomic,assign,readonly) int width;
    
    @property(nonatomic,assign,readonly) int height;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageImageAttachment : public V2NIMMessageFileAttachment {
    
        uint32_t width{0};
    
        uint32_t height{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessagImageAttachment extends V2NIMMessageFileAttachment {
    
      width: number
    
      height: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessagImageAttachment extends V2NIMMessageFileAttachment {
    
      width: number
      height: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    width int - 图片宽度,单位像素。
    height int - 图片高度,单位像素。

    V2NIMMessageAudioAttachment

    语音附件对象,继承自 V2NIMMessageFileAttachment

    Android
    Javapublic interface V2NIMMessageAudioAttachment extends V2NIMMessageFileAttachment {
    
        int getDuration();
    }
    
    iOS
    Objective-C@interface V2NIMMessageAudioAttachment : V2NIMMessageFileAttachment
    
    @property(nonatomic,assign,readwrite) NSUInteger duration;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageAudioAttachment : public V2NIMMessageFileAttachment {
    
        uint32_t duration{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageAudioAttachment extends V2NIMMessageFileAttachment {
    
      duration: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageAudioAttachment extends V2NIMMessageFileAttachment {
    
      duration: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    duration int - 语音文件时长,单位为毫秒。

    V2NIMMessageVideoAttachment

    视频附件对象,继承自 V2NIMMessageFileAttachment

    Android
    Javapublic interface V2NIMMessageVideoAttachment extends V2NIMMessageFileAttachment {
    
        int getDuration();
    
        int getWidth();
    
        int getHeight();
    }
    
    iOS
    Objective-C@interface V2NIMMessageVideoAttachment : V2NIMMessageFileAttachment
    
    @property(nonatomic,assign) NSUInteger duration;
    
    @property(nonatomic,assign) NSInteger width;
    
    @property(nonatomic,assign) NSInteger height;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageVideoAttachment : public V2NIMMessageFileAttachment {
    
        uint32_t duration{0};
    
        uint32_t width{0};
    
        uint32_t height{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageVideoAttachment extends V2NIMMessageFileAttachment {
    
      duration: number
    
      width: number
    
      height: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageVideoAttachment extends V2NIMMessageFileAttachment {
    
      duration: number
      width: number
      height: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    duration int - 视频文件时长,单位为毫秒。
    width int - 视频宽度,单位像素。
    height int - 视频高度,单位像素。

    V2NIMMessageCallAttachment

    话单消息附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMMessageCallAttachment extends V2NIMMessageAttachment {
    
        int getType();
    
        String getChannelId();
    
        int getStatus();
    
        List<V2NIMMessageCallDuration> getDurations();
    }
    
    iOS
    Objective-C@interface V2NIMMessageCallAttachment : V2NIMMessageAttachment
    
    @property (nonatomic, assign) NSInteger type;
    
    @property (nonatomic, copy) NSString *channelId;
    
    @property (nonatomic, assign) NSInteger status;
    
    @property (nonatomic, copy) NSArray<V2NIMMessageCallDuration *>*durations;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageCallAttachment : V2NIMMessageAttachment {
        V2NIMMessageCallAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CALL; }
        int32_t type{0};
        nstd::string channelId;
        int32_t status{0};
        nstd::vector<V2NIMMessageCallDuration> durations;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMMessageCallAttachment extends V2NIMMessageAttachment {
    
      type: number
    
      channelId: string
    
      status: number
    
      durations: V2NIMMessageCallDuration[]
    
      text: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    type Integer - 话单类型,业务侧可自定义,网易云信不校验内容。建议设置为:
  • 1:音频
  • 2:视频
  • channelId String - 话单频道 ID,网易云信不校验内容。
    status Integer - 通话状态,业务侧可自定义状态,网易云信不校验内容。建议设置为:
  • 1:通话完成
  • 2:通话取消
  • 3:通话拒绝
  • 4:超时未接听
  • 5:对方忙。
  • duration List<V2NIMMessageCallDuration> - 通话成员时长列表,网易云信不校验内容。

    V2NIMMessageCallDuration

    话单消息单人通话时长数据结构。

    Android
    Javapublic class V2NIMMessageCallDuration implements Serializable {
    
        private String accountId;
    
        private int duration;
    
        public V2NIMMessageCallDuration() {
        }
    
        public V2NIMMessageCallDuration(String accountId, int duration) {
            this.accountId = accountId;
            this.duration = duration;
        }
    
        public void setAccountId(String accountId) {
            this.accountId = accountId;
        }
    
        public void setDuration(int duration) {
            this.duration = duration;
        }
    
        public String getAccountId() {
            return accountId;
        }
    
        public int getDuration() {
            return duration;
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageCallDuration : NSObject
    
    @property(nullable,nonatomic,strong) NSString *accountId;
    
    @property(nonatomic,assign) NSInteger duration;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageCallDuration {
        nstd::string accountId;
        uint32_t duration;
    };
    
    Web/uni-app/小程序
    TypeScripttype V2NIMMessageCallDuration = {
      accountId: string
      duration: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    accountId string - 话单对应成员的账号 ID。
    duration Integer - 通话时长。

    V2NIMMessageLocationAttachment

    地理位置附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMMessageLocationAttachment extends V2NIMMessageAttachment {
    
        double getLatitude();
    
        double getLongitude();
    
        String getAddress();
    }
    
    iOS
    Objective-C@interface V2NIMMessageLocationAttachment : V2NIMMessageAttachment
    
    @property(nonatomic,assign) double longitude;
    
    @property(nonatomic,assign) double latitude;
    
    @property(nonnull,nonatomic,strong) NSString *address;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageLocationAttachment : public V2NIMMessageAttachment {
    
        double latitude{0};
    
        double longitude{0};
    
        nstd::string address;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageLocationAttachment extends V2NIMMessageAttachment {
    
      latitude: number
    
      longitude: number
    
      address: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageLocationAttachment extends V2NIMMessageAttachment {
    
      latitude: number
      longitude: number
      address: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    latitude Double - 地理位置纬度。
    longitude Double - 地理位置经度。
    address String - 地理位置描述。

    V2NIMMessageNotificationAttachment

    通知附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMMessageNotificationAttachment extends V2NIMMessageAttachment {
    
        V2NIMMessageNotificationType getType();
    
        String getServerExtension();
    
        List<String> getTargetIds();
    
        boolean isChatBanned();
    
        V2NIMUpdatedTeamInfo getUpdatedTeamInfo();
    }
    
    iOS
    Objective-C@interface V2NIMMessageNotificationAttachment : V2NIMMessageAttachment
    
    @property(nonatomic,assign) V2NIMMessageNotificationType type;
    
    @property(nullable,nonatomic,strong) NSString *serverExtension;
    
    @property(nullable,nonatomic,strong) NSArray<NSString *> *targetIds;
    
    @property(nonatomic,assign) BOOL chatBanned;
    
    @property(nullable,nonatomic,strong) V2NIMUpdatedTeamInfo *updatedTeamInfo;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageTeamNotificationAttachment : public V2NIMMessageAttachment {
        V2NIMMessageTeamNotificationAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_TEAM_NOTIFICATION; }
    
        V2NIMMessageNotificationType type{V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE};
    
        nstd::optional<nstd::string> serverExtension;
    
        nstd::vector<nstd::string> targetIds;
    
        bool chatBanned{false};
    
        nstd::optional<V2NIMUpdatedTeamInfo> updatedTeamInfo;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageNotificationAttachment extends V2NIMMessageAttachment {
      type: V2NIMMessageNotificationType
      serverExtension?: string
      targetIds?: string[]
      chatBanned?: boolean
      updatedTeamInfo?: V2NIMUpdatedTeamInfo
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageNotificationAttachment extends V2NIMMessageAttachment {
    
      type: V2NIMMessageNotificationType
      serverExtension?: string
      targetIds?: string[]
      chatBanned?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    type V2NIMMessageNotificationType - 通知类型。
    serverExtension String null 服务端扩展字段。必须为 JSON 格式封装,多端同步。
    targetIds List<String> null 被操作者用户账号(accountId)列表。
    chatBanned Boolean null 群成员是否被禁言。
    updatedTeamInfo V2NIMUpdatedTeamInfo null 群信息更新字段。
    如有字段信息,则表示对应字段被修改。

    V2NIMSendMessageResult

    消息发送成功结果回包。

    Android
    Javapublic interface V2NIMSendMessageResult {
    
        V2NIMMessage getMessage();
    
        String getAntispamResult();
    
        V2NIMClientAntispamResult getClientAntispamResult();
    }
    
    iOS
    Objective-C@interface V2NIMSendMessageResult : NSObject
    
    @property(nullable,nonatomic,strong,readonly) V2NIMMessage *message;
    
    @property(nullable,nonatomic,strong,readonly) NSString *antispamResult;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMClientAntispamResult *clientAntispamResult;
    @end
    
    macOS/Windows
    C++struct V2NIMSendMessageResult {
    
        V2NIMMessage message;
    
        nstd::optional<nstd::string> antispamResult;
    
        nstd::optional<V2NIMClientAntispamResult> clientAntispamResult;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMSendMessageResult {
      message: V2NIMMessage
    
      callbackExtension?: string
    
      antispamResult?: string
    
      clientAntispamResult?: V2NIMClientAntispamResult
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMSendMessageResult {
      message: V2NIMMessage
      callbackExtension?: string
      antispamResult?: string
      clientAntispamResult?: V2NIMClientAntispamResult
    }
    

    成员参数

    名称 类型 是否只读 说明
    message V2NIMMessage 消息对象。
    antispamResult String 安全通反垃圾检测结果。
    clientAntispamResult V2NIMClientAntispamResult 本地反垃圾结果。

    V2NIMModifyMessageResult

    消息更新成功结果回包。

    Android
    Javapublic interface V2NIMModifyMessageResult {
    
        V2NIMMessage getMessage();
    
        int getErrorCode();
    
        String getAntispamResult();
    
        V2NIMClientAntispamResult getClientAntispamResult();
    }
    
    iOS
    Objective-C@interface V2NIMModifyMessageResult: NSObject
    
    @property (nonatomic,readonly,strong) V2NIMMessage *message;
    
    @property (nonatomic,readonly,copy) NSString *antispamResult;
    
    @property (nonatomic,readonly,strong) V2NIMClientAntispamResult *clientAntispamResult;
    
    @end
    
    macOS/Windows
    C++struct V2NIMModifyMessageResult {
    
        V2NIMMessage message;
    
        int32_t errorCode{V2NIM_ERROR_CODE_SUCCESS};
    
        nstd::string antispamResult;
    
        V2NIMClientAntispamResult clientAntispamResult;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMModifyMessageResult = {
    
      errorCode: number
    
      message?: V2NIMMessage
    
      antispamResult?: string
    
      clientAntispamResult?: V2NIMClientAntispamResult
    }
    

    成员参数

    名称 类型 是否只读 说明
    message V2NIMMessage 更新成功后的消息对象。
    errorCode Int 默认为 200。如果此错误码为非 200,表示修改消息失败(比如触发云端反垃圾),此时修改成功后的消息体返回为 null。
    antispamResult String 安全通反垃圾检测结果。
    clientAntispamResult V2NIMClientAntispamResult 客户端本地反垃圾结果。

    V2NIMMessageListOption

    消息分页查询选项。

    Android
    Javapublic class V2NIMMessageListOption {
    
        public String getConversationId() {
            return conversationId;
        }
        public List<V2NIMMessageType> getMessageTypes() {
            return messageTypes;
        }
        public long getBeginTime() {
            return beginTime;
        }
        public long getEndTime() {
            return endTime;
        }
        public int getLimit() {
            return limit;
        }
        public V2NIMMessage getAnchorMessage() {
            return anchorMessage;
        }
        public V2NIMMessageQueryDirection getDirection() {
            if (direction == null) {
                return DEFAULT_DIRECTION;
            } else {
                return direction;
            }
        }
        public boolean isStrictMode() {
            return strictMode;
        }
    
            public static V2NIMMessageListOptionBuilder builder(final String conversationId) {
                return new V2NIMMessageListOptionBuilder(conversationId);
            }
            public V2NIMMessageListOptionBuilder withMessageTypes(List<V2NIMMessageType> messageTypes) {
                this.messageTypes = messageTypes;
                return this;
            }
            public V2NIMMessageListOptionBuilder withBeginTime(long beginTime) {
                this.beginTime = beginTime;
                return this;
            }
            public V2NIMMessageListOptionBuilder withEndTime(long endTime) {
                this.endTime = endTime;
                return this;
            }
            public V2NIMMessageListOptionBuilder withLimit(int limit) {
                this.limit = limit;
                return this;
            }
            public V2NIMMessageListOptionBuilder withAnchorMessage(V2NIMMessage anchorMessage) {
                this.anchorMessage = anchorMessage;
                return this;
            }
            public V2NIMMessageListOptionBuilder withDirection(V2NIMMessageQueryDirection direction) {
                this.direction = direction;
                return this;
            }
            public V2NIMMessageListOptionBuilder withStrictMode(boolean strictMode) {
                this.strictMode = strictMode;
                return this;
            }
            public V2NIMMessageListOption build() {
                return new V2NIMMessageListOption(conversationId, messageTypes, beginTime, endTime, limit, anchorMessage, direction, strictMode);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageListOption : NSObject<NSCopying>
    @property(nonatomic,strong) NSString *conversationId;
    @property(nullable,nonatomic,strong,readwrite) NSArray *messageTypes;
    @property(nonatomic,assign) NSTimeInterval beginTime;
    @property(nonatomic,assign) NSTimeInterval endTime;
    @property(nonatomic,assign) NSUInteger limit;
    @property(nullable,nonatomic,strong) V2NIMMessage *anchorMessage;
    @property(nonatomic,assign) V2NIMQueryDirection direction;
    @property (nonatomic, assign) BOOL strictMode;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageListOption {
        nstd::vector<V2NIMMessageType> messageTypes;
        nstd::string conversationId;
        uint64_t beginTime{0};
        uint64_t endTime{0};
        uint32_t limit{V2NIM_DEFAULT_MESSAGE_LIST_LIMIT};
        nstd::optional<V2NIMMessage> anchorMessage;
        bool reverse{false};
        V2NIMQueryDirection direction{V2NIM_QUERY_DIRECTION_DESC};
        bool strictMode{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageListOption {
      conversationId: string
      messageTypes?: V2NIMMessageType[]
      beginTime?: number
      endTime?: number
      limit?: number
      anchorMessage?: V2NIMMessage
      reverse?: boolean
      direction?: V2NIMQueryDirection
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageListOption {
      conversationId: string
      messageTypes?: V2NIMMessageType[]
      beginTime?: number
      endTime?: number
      limit?: number
      anchorMessage?: V2NIMMessage
      reverse?: boolean
      direction?: V2NIMQueryDirection
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    conversationId String - 消息所属的会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    messageTypes List<V2NIMMessageType> null 消息类型,为 null 或空列表则表示查询所有消息类型。
    beginTime long 0 查询开始时间,该字段必须小于等于 endTime
    endTime long 0 查询结束时间,字段必须大于等于 beginTime,默认为系统当前时间。
    limit int 50 本次查询条数上限,取值范围为 [0,100]。传入小于 0 则默认为 50。
    anchorMessage V2NIMMessage - 查询的消息锚点。查询结果不包含该锚点消息。
  • 该字段为空,则以 [beginTime,endTime] 为查询范围。
  • 该字段不为空:
    • directionDESC,如果 endTime 为 0,则以 anchorMessage 对应的时间戳为准。如果 endTime 不为 0,则必须与 anchorMessage 时间相同,否则返回 191004 参数错误。
    • directionASC,如果 beginTime 为 0,则以 anchorMessage 的时间戳为准。如果 beiginTime 不为 0,则必须与 anchorMessage 时间相同,否则返回 191004 参数错误。
  • direction V2NIMQueryDirection V2NIM_QUERY_DIRECTION_DESC 查询方向:按照时间升序或降序。
    strictmode boolean false 严格模式
  • true:如果无法确定消息完整性,则查询失败返回错误码,错误码由失败原因决定。
  • false:如果无法确定消息完整性,则从本地数据库中查询。
  • V2NIMThreadMessageListOption

    Thread 消息分页查询选项。

    Android
    Javapublic class V2NIMThreadMessageListOption implements Serializable {
    
     private V2NIMMessageRefer messageRefer;
    
     private long beginTime = 0L;
    
     private long endTime = 0L;
    
     private String excludeMessageServerId = null;
    
     private Integer limit = 50;
    
     private V2NIMQueryDirection direction = V2NIMQueryDirection.V2NIM_QUERY_DIRECTION_DESC;
    
     public V2NIMMessageRefer getMessageRefer() {
      return messageRefer;
     }
    
     public void setMessageRefer(V2NIMMessageRefer messageRefer) {
      this.messageRefer = messageRefer;
     }
    
     public long getBeginTime() {
      return beginTime;
     }
    
     public void setBeginTime(long beginTime) {
      this.beginTime = beginTime;
     }
    
     public long getEndTime() {
      return endTime;
     }
    
     public void setEndTime(long endTime) {
      this.endTime = endTime;
     }
    
     public String getExcludeMessageServerId() {
      return excludeMessageServerId;
     }
    
     public void setExcludeMessageServerId(String excludeMessageServerId) {
      this.excludeMessageServerId = excludeMessageServerId;
     }
    
     public Integer getLimit() {
      return limit;
     }
    
     public void setLimit(Integer limit) {
      this.limit = limit;
     }
    
     public V2NIMQueryDirection getDirection() {
      return direction;
     }
    
     public void setDirection(V2NIMQueryDirection direction) {
      this.direction = direction;
     }
    
     public boolean isValid() {
      if(!V2NIMMessageReferImpl.isValid(messageRefer)) {
       return false;
      }
      if(limit <= 0) {
       return false;
      }
    
      if(beginTime != 0L && endTime != 0L && beginTime > endTime) {
       return false;
      }
      return true;
     }
    }
    
    iOS
    Objective-C@interface V2NIMThreadMessageListOption: NSObject
    
    @property (nonnull,nonatomic,strong) V2NIMMessageRefer *messageRefer;
    
    @property(nonatomic,assign) NSTimeInterval beginTime;
    
    @property(nonatomic,assign) NSTimeInterval endTime;
    
    @property (nullable,nonatomic,copy) NSString *excludeMessageServerId;
    
    @property(nonatomic,assign) NSInteger limit;
    
    @property(nonatomic,assign) V2NIMQueryDirection direction;
    @end
    
    macOS/Windows
    C++struct V2NIMThreadMessageListOption {
        V2NIMMessageRefer messageRefer;
        nstd::optional<uint64_t> beginTime;
        nstd::optional<uint64_t> endTime;
        nstd::optional<nstd::string> excludeMessageServerId;
        nstd::optional<uint32_t> limit;
        nstd::optional<V2NIMQueryDirection> direction{V2NIM_QUERY_DIRECTION_DESC};
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMThreadMessageListOption {
    
      messageRefer: V2NIMMessageRefer
    
      beginTime?: number
    
      endTime?: number
    
      limit?: number
    
      direction?: V2NIMQueryDirection
    
      excludeMessageServerId?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    messageRefer V2NIMMessageRefer> - Thread 消息参考信息,支持根据 Thread 根消息的参考信息查询本地子消息。
    beginTime long 0 查询开始时间,该字段必须小于等于 endTime
    endTime long 0 查询结束时间,字段必须大于等于 beginTime,默认为系统当前时间。
    limit Integer 50 本次查询条数上限,取值范围为 [0,100]。传入小于 0 则默认为 50。
    excludeMessageServerId String - 锚点消息的 ServerId。该消息必须处于端点,即消息时间必须等于 beginTimeendTime。如果是合法的消息 ID 则表示排除该消息,否则不排除。
    direction V2NIMQueryDirection V2NIM_QUERY_DIRECTION_DESC 消息查询方向:按照时间升序(ASC)或降序(DESC)。

    V2NIMThreadMessageListResult

    Thread 消息查询结果。

    Android
    Javapublic interface V2NIMThreadMessageListResult {
    
     V2NIMMessage getMessage();
    
     long getTimestamp();
    
     int getReplyCount();
    
     List<V2NIMMessage> getReplyList();
    }
    
    iOS
    Objective-C@interface V2NIMThreadMessageListResult: NSObject
    
    @property (nonatomic,readonly,strong) V2NIMMessage *message;
    
    @property (nonatomic,readonly,assign) NSTimeInterval timestamp;
    
    @property (nonatomic,readonly,assign) NSInteger replyCount;
    
    @property (nonatomic,readonly,strong) NSArray<V2NIMMessage *> *replyList;
    
    @end
    
    macOS/Windows
    C++struct V2NIMThreadMessageListResult {
        V2NIMMessage message;
        uint64_t timestamp{0};
        uint32_t replyCount{0};
        nstd::vector<V2NIMMessage> replyList;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMThreadMessageListResult {
    
      message: V2NIMMessage
    
      timestamp: number
    
      replyCount: number
    
      replyList: V2NIMMessage[]
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    message V2NIMMessage - Thread 消息根消息。
    timestamp long - 获取 Thread 消息中最后一条消息的时间戳。
    replyCount Integer - 获取 Thread 消息中的总回复数,Thread 消息不计入总数。
    replyList List<V2NIMMessage> - 消息回复列表。

    V2NIMP2PMessageReadReceipt

    单聊消息已读回执对象。

    Android
    Javapublic interface V2NIMP2PMessageReadReceipt {
        String getConversationId();
        long getTimestamp();
    }
    
    iOS
    Objective-C@interface V2NIMP2PMessageReadReceipt : NSObject
    @property(nullable,nonatomic,strong,readonly) NSString *conversationId;
    @property(nonatomic,assign,readonly) NSTimeInterval timestamp;
    @end
    
    macOS/Windows
    C++struct V2NIMP2PMessageReadReceipt {
        nstd::string conversationId;
        uint64_t timestamp{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMP2PMessageReadReceipt {
      conversationId: string
      timestamp: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMP2PMessageReadReceipt {
    
      conversationId: string
      timestamp: number
    }
    

    成员参数

    名称 类型 是否只读 说明
    conversationId String 消息所属的会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    timestamp long 最后一条已读消息的时间戳,早于该消息都判定为已读消息。

    V2NIMTeamMessageReadReceipt

    群组消息已读回执对象。

    Android
    Javapublic interface V2NIMTeamMessageReadReceipt {
        String getConversationId();
        String getMessageClientId();
        String getMessageServerId();
        int getReadCount();
        int getUnreadCount();
        String getLatestReadAccount();
    }
    
    iOS
    Objective-C@interface V2NIMTeamMessageReadReceipt : NSObject
    @property (nullable,nonatomic,strong,readonly) NSString *conversationId;
    @property (nullable,nonatomic,strong,readonly) NSString *messageServerId;
    @property (nullable,nonatomic,strong,readonly) NSString *messageClientId;
    @property (nonatomic,assign,readonly) NSInteger readCount;
    @property (nonatomic,assign,readonly) NSInteger unreadCount;
    @property (nonatomic,strong,readonly) NSString *latestReadAccount;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamMessageReadReceipt {
        nstd::string conversationId;
        nstd::string messageServerId;
        nstd::string messageClientId;
        uint32_t readCount{0};
        uint32_t unreadCount{0};
        nstd::optional<nstd::string> latestReadAccount;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMTeamMessageReadReceipt {
      conversationId: string
      messageServerId: string
      messageClientId: string
      readCount: number
      unreadCount: number
      latestReadAccount?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMTeamMessageReadReceipt {
    
      conversationId: string
      messageServerId: string
      messageClientId: string
      readCount: number
      unreadCount: number
      latestReadAccount?: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    conversationId String 消息所属的会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    messageServerId String 已读的服务端消息 ID。
    messageClientId String 已读的客户端消息 ID。
    readCount int 该群组消息已读人数。
    unreadCount int 该群组消息未读人数。
    latestReadAccount String 该群消息最新已读账号(accountId)。

    V2NIMTeamMessageReadReceiptDetail

    群组消息已读回执详情。

    Android
    Javapublic interface V2NIMTeamMessageReadReceiptDetail {
        V2NIMTeamMessageReadReceipt getReadReceipt();
        List<String> getReadAccountList();
        List<String> getUnreadAccountList();
    }
    
    iOS
    Objective-C@interface V2NIMTeamMessageReadReceiptDetail : NSObject
    @property (nonatomic,strong,readonly) V2NIMTeamMessageReadReceipt *readReceipt;
    @property (nonatomic,strong,readonly) NSArray<NSString *> *readAccountList;
    @property (nonatomic,strong,readonly) NSArray<NSString *> *unreadAccountList;
    @end
    
    macOS/Windows
    C++struct V2NIMTeamMessageReadReceiptDetail {
        V2NIMTeamMessageReadReceipt readReceipt;
        nstd::vector<nstd::string> readAccountList;
        nstd::vector<nstd::string> unreadAccountList;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMTeamMessageReadReceiptDetail {
      readReceipt: V2NIMTeamMessageReadReceipt
      readAccountList: string[]
      unreadAccountList: string[]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMTeamMessageReadReceiptDetail {
    
      readReceipt: V2NIMTeamMessageReadReceipt
      readAccountList: string[]
      unreadAccountList: string[]
    }
    

    成员参数

    名称 类型 是否只读 说明
    readReceipt V2NIMTeamMessageReadReceipt 群组消息已读回执对象。
    readAccountList List<String> 群组消息已读账号列表。
    unreadAccountList List<String> 群组消息未读账号列表。

    V2NIMMessageRevokeParams

    消息撤回配置参数。

    Android
    Javapublic class V2NIMMessageRevokeParams {
    
        public String getPostscript() {
            return postscript;
        }
        public String getServerExtension() {
            return serverExtension;
        }
        public String getPushContent() {
            return pushContent;
        }
        public String getPushPayload() {
            return pushPayload;
        }
        public String getEnv() {
            return env;
        }
        public static final class V2NIMMessageRevokeParamsBuilder {
    
            public static V2NIMMessageRevokeParamsBuilder builder() {
                return new V2NIMMessageRevokeParamsBuilder();
            }
            public V2NIMMessageRevokeParamsBuilder withPostscript(String postscript) {
                this.postscript = postscript;
                return this;
            }
            public V2NIMMessageRevokeParamsBuilder withExtension(String extension) {
                this.extension = extension;
                return this;
            }
            public V2NIMMessageRevokeParamsBuilder withPushContent(String pushContent) {
                this.pushContent = pushContent;
                return this;
            }
            public V2NIMMessageRevokeParamsBuilder withPushPayload(String pushPayload) {
                this.pushPayload = pushPayload;
                return this;
            }
            public V2NIMMessageRevokeParamsBuilder withEnv(String env) {
                this.env = env;
                return this;
            }
            public V2NIMMessageRevokeParams build() {
                return new V2NIMMessageRevokeParams(postscript, extension, pushContent, pushPayload, env);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageRevokeParams : NSObject
    @property(nullable, nonatomic, strong) NSString *postscript;
    @property(nullable, nonatomic, strong) NSString *serverExtension;
    @property (nullable, nonatomic, strong) NSString *pushContent;
    @property (nullable, nonatomic, strong) NSString *pushPayload;
    @property (nullable, nonatomic, strong) NSString *env;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageRevokeParams {
        nstd::optional<nstd::string> postscript;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<nstd::string> pushContent;
        nstd::optional<nstd::string> pushPayload;
        nstd::optional<nstd::string> env;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageRevokeParams {
      postscript?: string
      serverExtension?: string
      pushContent?: string
      pushPayload?: string
      env?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageRevokeParams {
    
      postscript?: string
      serverExtension?: string
      pushContent?: string
      pushPayload?: string
      env?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    postscript String null 附言。
    serverExtension String null 服务端扩展字段。必须为 JSON 格式封装,多端同步,长度上限为 1024 字节。
    pushContent String null 推送文案。
    pushPayload String null 推送 Payload
    env String null 消息抄送地址,必须与网易云信控制台 开通配置 的消息抄送地址一致。

    V2NIMMessageRevokeNotification

    消息撤回通知。

    Android
    Javapublic interface V2NIMMessageRevokeNotification extends Serializable {
    
        V2NIMMessageRefer getMessageRefer();
        String getServerExtension();
        String getRevokeAccountId();
        String getPostscript();
        V2NIMMessageRevokeType getRevokeType();
        String getCallbackExtension();
    }
    
    iOS
    @interface V2NIMMessageRevokeNotification : NSObject
    
    @property (nullable,nonatomic,strong,readonly) V2NIMMessageRefer *messageRefer;
    
    @property (nullable,nonatomic,strong,readonly) NSString *serverExtension;
    
    @property (nullable,nonatomic,strong,readonly) NSString *revokeAccountId;
    
    @property (nullable,nonatomic,strong,readonly) NSString *postscript;
    
    @property (nonatomic,assign,readonly) V2NIMMessageRevokeType revokeType;
    
    @property (nonatomic,strong,readonly) NSString *callbackExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageRevokeNotification {
        V2NIMMessageRefer messageRefer;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<nstd::string> postscript;
        nstd::string revokeAccountId;
        V2NIMMessageRevokeType revokeType{V2NIM_MESSAGE_REOKE_TYPE_UNDEFINED};
        nstd::optional<nstd::string> callbackExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageRevokeNotification {
      messageRefer: V2NIMMessageRefer
      serverExtension?: string
      revokeAccountId: string
      postscript?: string
      revokeType: V2NIMMessageRevokeType
      callbackExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageRevokeNotification {
    
      messageRefer: V2NIMMessageRefer
      serverExtension?: string
      revokeAccountId: string
      postscript?: string
      revokeType: V2NIMMessageRevokeType
      callbackExtension?: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    messageRefer V2NIMMessageRefer 撤回消息的参考信息。
    serverExtension String 服务端扩展字段,多端同步。
    revokeAccountId String 推送文案。
    postscript String 附言。
    revokeType V2NIMMessageRevokeType 消息撤回类型。
    callbackExtension String 第三方回调透传的自定义扩展字段。
    第三方回调功能需要在 网易云信控制台开通

    V2NIMMessageDeletedNotification

    消息删除通知。

    Android
    Javapublic interface V2NIMMessageDeletedNotification {
    
        V2NIMMessageRefer getMessageRefer();
    
        long getDeleteTime();
    
        String getServerExtension();
    }
    
    iOS
    Objective-C@interface V2NIMMessageDeletedNotification : NSObject
    
    @property(nonatomic,strong,readonly) V2NIMMessageRefer *messageRefer;
    
    @property(nonatomic,assign,readonly) NSTimeInterval deleteTime;
    
    @property(nonatomic,strong,readonly) NSString *serverExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageDeletedNotification {
    
        V2NIMMessageRefer messageRefer;
    
        uint64_t deleteTime{0};
    
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageDeletedNotification {
    
      messageRefer: V2NIMMessageRefer
    
      deleteTime: number
    
      serverExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageDeletedNotification {
    
      messageRefer: V2NIMMessageRefer
      deleteTime: number
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    messageRefer V2NIMMessageRefer 被删除消息的参考信息。
    deleteTime long 删除时间戳。
    serverExtension String 删除时传入的服务端扩展字段,多端同步。

    V2NIMMessageQuickCommentNotification

    消息快捷评论操作通知。

    Android
    Javapublic interface V2NIMMessageQuickCommentNotification {
        V2NIMMessageQuickCommentType getOperationType();
    
        V2NIMMessageQuickComment getQuickComment();
    }
    
    iOS
    Objective-C@interface V2NIMMessageQuickCommentNotification : NSObject
    
    @property(nonatomic,assign) V2NIMMessageQuickCommentType operationType;
    
    @property(nonatomic,strong) V2NIMMessageQuickComment *quickComment;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageQuickCommentNotification {
    
        V2NIMMessageQuickCommentType operationType{V2NIM_MESSAGE_QUICK_COMMENT_TYPE_ADD};
    
        V2NIMMessageQuickComment quickComment;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageQuickCommentNotification {
    
      operationType: V2NIMMessageQuickCommentType
    
      quickComment: V2NIMMessageQuickComment
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageQuickCommentNotification {
    
      operationType: V2NIMMessageQuickCommentType
      quickComment: V2NIMMessageQuickComment
    }
    

    成员参数

    名称 类型 是否只读 说明
    operatorType V2NIMMessageQuickCommentType 快捷评论操作类型。
    quickComment V2NIMMessageQuickComment 消息快捷评论信息。

    V2NIMMessagePinNotification

    Pin 消息通知。

    Android
    Javapublic interface V2NIMMessagePinNotification {
        V2NIMMessagePinState getPinState();
    
        V2NIMMessagePin getPin();
    }
    
    iOS
    Objective-C@interface V2NIMMessagePinNotification : NSObject
    
    @property (nullable,nonatomic,strong, readonly) V2NIMMessagePin *pin;
    
    @property (nonatomic,assign, readonly) V2NIMMessagePinState pinState;
    @end
    
    macOS/Windows
    C++struct V2NIMMessagePinNotification {
    
        V2NIMMessagePinState pinState{V2NIM_MESSAGE_PIN_STEATE_NOT_PINNED};
    
        V2NIMMessagePin pin;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessagePinNotification {
      pinState: V2NIMMessagePinState
      pin: {
    
        messageRefer: V2NIMMessageRefer
    
        operatorId: string
    
        serverExtension: string
    
        createTime?: number
    
        updateTime: number
      }
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessagePinNotification {
      pinState: V2NIMMessagePinState
      pin: {
        messageRefer: V2NIMMessageRefer
        operatorId: string
        serverExtension: string
        createTime?: number
        updateTime: number
      }
    }
    

    成员参数

    名称 类型 是否只读 说明
    pinState V2NIMMessagePinState Pin 消息状态。
    pin V2NIMMessagePin Pin 消息信息。

    V2NIMClearHistoryMessageOption

    历史消息清空选项。

    Android
    Javapublic class V2NIMClearHistoryMessageOption {
        @NonNull
        public String getConversationId() {
            return conversationId;
        }
        public boolean isDeleteRoam() {
            return deleteRoam;
        }
        public boolean isOnlineSync() {
            return onlineSync;
        }
        public String getServerExtension() {
            return serverExtension;
        }
        public static final class V2NIMClearHistoryMessageOptionBuilder {
    
            public static V2NIMClearHistoryMessageOptionBuilder builder(@NonNull String conversationId) {
                return new V2NIMClearHistoryMessageOptionBuilder(conversationId);
            }
            public V2NIMClearHistoryMessageOptionBuilder withDeleteRoam(boolean deleteRoam) {
                this.deleteRoam = deleteRoam;
                return this;
            }
            public V2NIMClearHistoryMessageOptionBuilder withOnlineSync(boolean onlineSync) {
                this.onlineSync = onlineSync;
                return this;
            }
            public V2NIMClearHistoryMessageOptionBuilder withExtension(String extension) {
                this.extension = extension;
                return this;
            }
            public V2NIMClearHistoryMessageOption build() {
                return new V2NIMClearHistoryMessageOption(conversationId, deleteRoam, onlineSync, extension);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMClearHistoryMessageOption : NSObject<NSCopying>
    @property(nonatomic,strong,readwrite) NSString *conversationId;
    @property(nonatomic,assign,readwrite) BOOL deleteRoam;
    @property(nonatomic,assign,readwrite) BOOL onlineSync;
    @property(nonatomic,strong,readwrite) NSString *serverExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMClearHistoryMessageOption {
        nstd::string conversationId;
        bool deleteRoam{true};
        bool onlineSync{false};
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMClearHistoryMessageOption {
      conversationId: string
      deleteRoam?: boolean
      onlineSync?: boolean
      serverExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMClearHistoryMessageOption {
      conversationId: string
      deleteRoam?: boolean
      onlineSync?: boolean
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    conversationId String - 历史消息所属的会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    deleteRoam boolean true 是否同步删除漫游消息:
  • true:删除漫游消息
  • false:保留漫游消息。
  • onlineSync boolean false 是否多端同步。
    serverExtension String null 服务端扩展字段。必须为 JSON 格式封装,多端同步。

    V2NIMClearHistoryNotification

    会话历史消息清空通知。

    Android
    Javapublic interface V2NIMClearHistoryNotification {
        String getConversationId();
    
        long getDeleteTime();
    
        String getServerExtension();
    }
    
    iOS
    Objective-C@interface V2NIMClearHistoryNotification : NSObject
    
    @property(nonatomic,strong,readonly) NSString *conversationId;
    
    @property(nonatomic,assign,readonly) NSTimeInterval deleteTime;
    
    @property(nonatomic,strong,readonly) NSString *serverExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMClearHistoryNotification {
    
        nstd::string conversationId;
    
        uint64_t deleteTime{0};
    
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMClearHistoryNotification {
      conversationId: string
      deleteTime: number
      serverExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMClearHistoryNotification {
      conversationId: string
      deleteTime: number
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    conversationId String 会话 ID
    deleteTime long 清空的时间戳。
    serverExtension String 清空时传入的服务端扩展字段,多端同步。

    V2NIMMessageSearchParams

    历史消息全文检索查询参数。

    超大群不支持历史消息全文检索功能。

    Android
    Javapublic class V2NIMMessageSearchParams {
        public String getKeyword() {
            return keyword;
        }
        public long getBeginTime() {
            return beginTime;
        }
        public long getEndTime() {
            return endTime;
        }
        public int getConversationLimit() {
            return conversationLimit;
        }
        public int getMessageLimit() {
            return messageLimit;
        }
        public V2NIMSortOrder getSortOrder() {
            if (sortOrder == null) {
                return V2NIMSortOrder.V2NIM_SORT_ORDER_DESC;
            } else {
                return sortOrder;
            }
        }
        public List<String> getP2pAccountIds() {
            return p2pAccountIds;
        }
        public List<String> getTeamIds() {
            return teamIds;
        }
        public List<String> getSenderAccountIds() {
            return senderAccountIds;
        }
        public List<V2NIMMessageType> getMessageTypes() {
            return messageTypes;
        }
        public List<Integer> getMessageSubtypes() {
            return messageSubtypes;
        }
        @Override
        public String toString() {
            return "V2NIMMessageSearchParams{" +
                    "keyword='" + keyword + '\'' +
                    ", beginTime=" + beginTime +
                    ", endTime=" + endTime +
                    ", conversationLimit=" + conversationLimit +
                    ", messageLimit=" + messageLimit +
                    ", sortOrder=" + sortOrder +
                    ", p2pAccountIds=" + p2pAccountIds +
                    ", teamIds=" + teamIds +
                    ", senderAccountIds=" + senderAccountIds +
                    ", messageTypes=" + messageTypes +
                    ", messageSubtypes=" + messageSubtypes +
                    '}';
        }
    
        public static final class V2NIMMessageSearchParamsBuilder {
            public static V2NIMMessageSearchParamsBuilder builder(String keyword) {
                return new V2NIMMessageSearchParamsBuilder(keyword);
            }
            public V2NIMMessageSearchParamsBuilder withBeginTime(long beginTime) {
                this.beginTime = beginTime;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withEndTime(long endTime) {
                this.endTime = endTime;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withConversationLimit(int conversationLimit) {
                this.conversationLimit = conversationLimit;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withMessageLimit(int messageLimit) {
                this.messageLimit = messageLimit;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withSortOrder(V2NIMSortOrder sortOrder) {
                this.sortOrder = sortOrder;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withP2pAccountIds(List<String> p2pAccountIds) {
                this.p2pAccountIds = p2pAccountIds;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withTeamIds(List<String> teamIds) {
                this.teamIds = teamIds;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withSenderAccountIds(List<String> senderAccountIds) {
                this.senderAccountIds = senderAccountIds;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withMessageTypes(List<V2NIMMessageType> messageTypes) {
                this.messageTypes = messageTypes;
                return this;
            }
            public V2NIMMessageSearchParamsBuilder withMessageSubtypes(List<Integer> messageSubtypes) {
                this.messageSubtypes = messageSubtypes;
                return this;
            }
            public V2NIMMessageSearchParams build() {
                return new V2NIMMessageSearchParams(keyword, beginTime, endTime, conversationLimit, messageLimit, sortOrder, p2pAccountIds, teamIds, senderAccountIds, messageTypes, messageSubtypes);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMMessageSearchParams : NSObject
    @property (nonatomic,strong) NSString *keyword;
    @property (nonatomic,assign) NSTimeInterval beginTime;
    @property (nonatomic,assign) NSTimeInterval endTime;
    @property (nonatomic,assign) NSUInteger conversationLimit;
    @property (nonatomic,assign) NSUInteger messageLimit;
    @property (nonatomic,assign) V2NIMSortOrder sortOrder;
    @property (nonatomic,strong) NSArray <NSString *> *p2pAccountIds;
    @property (nonatomic,strong) NSArray <NSString *> *teamIds;
    @property (nonatomic,strong) NSArray <NSString *> *senderAccountIds;
    @property (nonatomic,strong) NSArray *messageTypes;
    @property (nonatomic,strong) NSArray *messageSubtypes;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageSearchParams {
        nstd::string keyword;
        uint64_t beginTime{0};
        uint64_t endTime{0};
        uint32_t conversationLimit{0};
        uint32_t messageLimit{V2NIM_DEFAULT_SEARCH_MESSAGE_LIST_LIMIT};
        V2NIMSortOrder sortOrder{V2NIM_SORT_ORDER_DESC};
        nstd::vector<nstd::string> p2pAccountIds;
        nstd::vector<nstd::string> teamIds;
        nstd::vector<nstd::string> senderAccountIds;
        nstd::vector<V2NIMMessageType> messageTypes;
        nstd::vector<uint32_t> messageSubTypes;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMMessageSearchParams {
      keyword: string
      beginTime?: number
      endTime?: number
      conversationLimit?: number
      messageLimit?: number
      sortOrder?: V2NIMSortOrder
      p2pAccountIds?: string[]
      teamIds?: string[]
      senderAccountIds: string[]
      messageTypes?: V2NIMMessageType[]
      messageSubtypes?: number[]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMMessageSearchParams {
    
      keyword: string
      beginTime?: number
      endTime?: number
      conversationLimit?: number
      messageLimit?: number
      sortOrder?: V2NIMSortOrder
      p2pAccountIds?: string[]
      teamIds?: string[]
      senderAccountIds: string[]
      messageTypes?: V2NIMMessageType[]
      messageSubtypes?: number[]
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    keyword String - 检索关键字。
    beginTime long 0 查询开始时间。该字段必须小于等于 endTime
    endTime long 0,即系统当前时间。 查询结束时间。该字段必须大于等于 beginTime
    conversationLimit int 0 本次检索的会话条数上限:
  • 设置为大于 0:查询结果按照会话分组显示。
  • 设置为小于或等于 0:查询结果按照时间排序。
  • messageLimit int 10 本次检索返回的消息条数上限,0 表示无限制。
    sortOrder V2NIMSortOrder V2NIM_SORT_ORDER_DESC 检索结果的排序规则,按照消息时间戳升序或降序排序。
    p2pAccountIds List<String> null 单聊账号列表。最多传入 20 个账号,否则返回 191004 参数错误。
    teamIds List<String> null 高级群账号列表。最多传入 20 个账号,否则返回 191004 参数错误。
    senderAccountIds List<String> null 发送方账号列表。最多传入 20 个账号,否则返回 191004 参数错误。
    messageTypes List<V2NIMMessageType> null 或空,即查询所有消息类型。 消息类型。
    messageSubtypes List<int> null 或空,即查询所有消息子类型。 自定义消息子类型。

    V2NIMClientAntispamResult

    文本消息客户端本地反垃圾结果。

    Android
    Javapublic interface V2NIMClientAntispamResult {
        V2NIMClientAntispamOperateType getOperateType();
        String getReplacedText();
    }
    
    iOS
    Objective-C@interface V2NIMClientAntispamResult : NSObject
    @property (nonatomic, assign) V2NIMClientAntispamOperateType operateType;
    @property (nonatomic, copy) NSString *replacedText;
    
    @end
    
    macOS/Windows
    C++struct V2NIMClientAntispamResult {
        V2NIMClientAntispamOperateType operateType{V2NIM_CLIENT_ANTISPAM_OPERATE_NONE};
        nstd::string replacedText;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMClientAntispamResult {
      operateType: V2NIMClientAntispamOperatorType
      replacedText: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMClientAntispamResult {
    
      operateType: V2NIMClientAntispamOperatorType
      replacedText: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    operateType V2NIMClientAntispamOperateType 反垃圾命中后的操作类型。
    replacedText String 替换处理后的文本内容。

    V2NIMVoiceToTextParams

    语音转文字配置参数。

    Android
    Javapublic class V2NIMVoiceToTextParams {
    
        public String getVoicePath() {
            return voicePath;
        }
    
        public String getVoiceUrl() {
            return voiceUrl;
        }
    
        public String getMimeType() {
            return mimeType;
        }
    
        public String getSampleRate() {
            return sampleRate;
        }
    
        public long getDuration() {
            return duration;
        }
    
        public String getSceneName() {
            if (TextUtils.isEmpty(sceneName)) {
                return V2NIMStorageSceneConfig.DEFAULT_IM.getSceneName();
            } else {
                return sceneName;
            }
        }
    
        @Override
        public String toString() {
            return "V2NIMVoiceToTextParams{" +
                    "voicePath='" + voicePath + '\'' +
                    ", voiceUrl='" + voiceUrl + '\'' +
                    ", mimeType='" + mimeType + '\'' +
                    ", sampleRate='" + sampleRate + '\'' +
                    ", duration=" + duration +
                    ", sceneName='" + sceneName + '\'' +
                    '}';
        }
    
        public static final class V2NIMVoiceToTextParamsBuilder {
    
            public static V2NIMVoiceToTextParamsBuilder builder(final long duration) {
                return new V2NIMVoiceToTextParamsBuilder(duration);
            }
    
            public V2NIMVoiceToTextParamsBuilder withVoicePath(String voicePath) {
                this.voicePath = voicePath;
                return this;
            }
    
            public V2NIMVoiceToTextParamsBuilder withVoiceUrl(String voiceUrl) {
                this.voiceUrl = voiceUrl;
                return this;
            }
    
            public V2NIMVoiceToTextParamsBuilder withMimeType(String mimeType) {
                this.mimeType = mimeType;
                return this;
            }
    
            public V2NIMVoiceToTextParamsBuilder withSampleRate(String sampleRate) {
                this.sampleRate = sampleRate;
                return this;
            }
    
            public V2NIMVoiceToTextParamsBuilder withSceneName(String sceneName) {
                this.sceneName = sceneName;
                return this;
            }
    
            public V2NIMVoiceToTextParams build() {
                return new V2NIMVoiceToTextParams(voicePath, voiceUrl, mimeType, sampleRate, duration, sceneName);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMVoiceToTextParams : NSObject
    
    @property (nonatomic, strong) NSString *voicePath;
    
    @property (nonatomic, strong) NSString *voiceUrl;
    
    @property (nonatomic, strong) NSString *mimeType;
    
    @property (nonatomic, strong) NSString *sampleRate;
    
    @property (nonatomic, assign) NSTimeInterval duration;
    
    @property (nonatomic, strong) NSString *sceneName;
    @end
    
    macOS/Windows
    C++struct V2NIMVoiceToTextParams {
    
        nstd::string voicePath;
    
        nstd::string voiceUrl;
    
        nstd::string mimeType;
    
        nstd::string sampleRate;
    
        uint64_t duration{0};
    
        nstd::string sceneName;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMVoiceToTextParams {
    
      voicePath?: string
    
      file?: File
    
      voiceUrl?: string
    
      duration: number
    
      mimeType?: string
    
      sampleRate?: string
    
      sceneName?: string
    }
    
    
    HarmonyOS
    TypeScriptexport interface V2NIMVoiceToTextParams {
    
      voicePath?: string
      voiceUrl?: string
      duration: number
      mimeType?: string
      sampleRate?: string
      sceneName?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    voicePath String voiceUrl 必须设置其一 - 语音文件本地路径。
    请确保该路径存在且可用。
    file Web File
  • Web 端(除小程序):与 voicePath/voiceUrl 必须设置其一
  • 其他端不设置该字段
  • - Web File 对象。
    voiceUrl String voicePath 必须设置其一 - 语音文件 URL 地址。
    mimeType String null 音频类型,例如 aac, wav, mp3, amr 等。
    sampleRate String null 音频采样率,单位为 kHz。
    duration long - 语音文件时长,单位为毫秒。
    sceneName String V2NIMStorageSceneConfig.DEFAULT_IM 对应的场景名 网易对象存储 NOS 文件存储场景名。若使用自定义的存储场景,需要先调用 V2NIMStorageService.addCustomStorageScene 添加自定义存储场景。

    V2NIMStorageScene

    网易对象存储 NOS 文件存储场景信息。

    Android
    Javapublic interface V2NIMStorageScene {
    
        String getSceneName();
    
        long getExpireTime();
    
    }
    
    iOS
    Objective-C@interface V2NIMStorageScene : NSObject
    @property (nullable,nonatomic,strong) NSString *sceneName;
    @property (nonatomic,assign) NSUInteger expireTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMStorageScene {
        nstd::string sceneName;
        uint64_t expireTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMStorageScene {
      sceneName: string
      expireTime?: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMStorageScene {
    
      sceneName: string
      expireTime?: number
    }
    

    成员参数

    名称 类型 是否只读 说明
    sceneName String 网易对象存储 NOS 文件存储场景名称。
    expireTime long 该场景下文件资源的过期时间,单位秒。必须大于等于 0,0 表示永不过期。

    V2NIMStorageSceneConfig

    网易对象存储 NOS 文件存储场景配置。

    Android
    Javapublic interface V2NIMStorageSceneConfig {
    
        V2NIMStorageScene DEFAULT_PROFILE = new V2NIMStorageSceneImpl("nim_default_profile_icon", 0);
    
        V2NIMStorageScene DEFAULT_IM = new V2NIMStorageSceneImpl("nim_default_im", 0);
    
        V2NIMStorageScene DEFAULT_SYSTEM = new V2NIMStorageSceneImpl("nim_system_nos_scene", 0);
    
        V2NIMStorageScene SECURITY_LINK = new V2NIMStorageSceneImpl("nim_security", 0);
    
    }
    
    iOS
    Objective-C@interface V2NIMStorageSceneConfig : NSObject
    
    + (V2NIMStorageScene *)DEFAULT_PROFILE;
    + (V2NIMStorageScene *)DEFAULT_IM;
    + (V2NIMStorageScene *)DEFAULT_SYSTEM;
    + (V2NIMStorageScene *)SECURITY_LINK;
    @end
    
    macOS/Windows
    C++static const char* V2NIM_STORAGE_SCENE_NAME_DEFAULT_PROFILE{"nim_default_profile_icon"};
    static const char* V2NIM_STORAGE_SCENE_NAME_DEFAULT_IM{"nim_default_im"};
    static const char* V2NIM_STORAGE_SCENE_NAME_DEFAULT_SYSTEM{"nim_system_nos_scene"};
    static const char* V2NIM_STORAGE_SCENE_NAME_SECURITY_LINK{"nim_security"};
    
    Web/uni-app/小程序
    TypeScriptexport class V2NIMStorageSceneConfig {
    
      static DEFAULT_PROFILE(): V2NIMStorageScene {
        return {
          sceneName: 'nim_default_profile_icon',
          expireTime: 0
        }
      }
    
      static DEFAULT_IM(): V2NIMStorageScene {
        return {
          sceneName: 'nim_default_im',
          expireTime: 0
        }
      }
    
      static DEFAULT_SYSTEM():V2NIMStorageScene {
        return {
          sceneName: 'nim_system_nos_scene',
          expireTime: 0
        }
      }
    
      static SECURITY_LINK():V2NIMStorageScene {
        return {
          sceneName: 'nim_security',
          expireTime: 0
        }
      }
    }
    
    HarmonyOS
    TypeScriptexport class V2NIMStorageSceneConfig {
    
      static DEFAULT_PROFILE(): V2NIMStorageScene {
        return {
          sceneName: 'nim_default_profile_icon',
          expireTime: 0
        }
      }
    
      static DEFAULT_IM(): V2NIMStorageScene {
        return {
          sceneName: 'nim_default_im',
          expireTime: 0
        }
      }
    
      static DEFAULT_SYSTEM():V2NIMStorageScene {
        return {
          sceneName: 'nim_system_nos_scene',
          expireTime: 0
        }
      }
    
      static SECURITY_LINK():V2NIMStorageScene {
        return {
          sceneName: 'nim_security',
          expireTime: 0
        }
      }
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    DEFAULT_PROFILE V2NIMStorageScene
  • sceneName:nim_default_profile_icon
  • expireTime:0
  • 默认场景,用于用户、群组资料的上传场景。
    DEFAULT_IM V2NIMStorageScene
  • nim_default_im
  • expireTime:0
  • IM 场景,用于文件的上传场景。
    DEFAULT_SYSTEM V2NIMStorageScene
  • nim_system_nos_scene
  • expireTime:0
  • 系统场景,用于 SDK 内部文件的上传场景。
    SECURITY_LINK V2NIMStorageScene
  • nim_security
  • expireTime:0
  • 安全链接场景,查看该场景的上传文件需要密钥。

    V2NIMCustomNotification

    自定义通知。

    Android
    Javapublic interface V2NIMCustomNotification {
        String getSenderId();
    
        String getReceiverId();
    
        V2NIMConversationType getConversationType();
    
        long getTimestamp();
    
        String getContent();
    
        V2NIMNotificationConfig getNotificationConfig();
    
        V2NIMNotificationPushConfig getPushConfig();
    
        V2NIMNotificationAntispamConfig getAntispamConfig();
    
        V2NIMNotificationRouteConfig getRouteConfig();
    }
    
    iOS
    Objective-C@interface V2NIMCustomNotification : NSObject
    
    @property(nullable,nonatomic,strong,readonly) NSString *senderId;
    
    @property(nullable,nonatomic,strong,readonly) NSString *receiverId;
    
    @property(nonatomic,assign,readonly) V2NIMConversationType conversationType;
    
    @property(nonatomic,assign,readonly) NSTimeInterval timestamp;
    
    @property(nullable,nonatomic,strong,readonly) NSString *content;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMNotificationConfig *notificationConfig;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMNotificationPushConfig *pushConfig;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMNotificationAntispamConfig *antispamConfig;
    
    @property(nullable,nonatomic,strong,readonly) V2NIMNotificationRouteConfig *routeConfig;
    @end
    
    macOS/Windows
    C++struct V2NIMCustomNotification {
    
        nstd::string senderId;
    
        nstd::string receiverId;
    
        V2NIMConversationType conversationType{V2NIM_CONVERSATION_TYPE_UNKNOWN};
    
        uint64_t timestamp{0};
    
        nstd::string content;
    
        V2NIMNotificationConfig notificationConfig;
    
        V2NIMNotificationPushConfig pushConfig;
    
        V2NIMNotificationAntispamConfig antispamConfig;
    
        V2NIMNotificationRouteConfig routeConfig;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMCustomNotification {
    
      senderId: string
    
      receiverId: string
    
      conversationType: V2NIMConversationType
    
      timestamp: number
    
      content: string
    
      notificationConfig?: V2NIMNotificationConfig
    
      pushConfig?: V2NIMNotificationPushConfig
    
      antispamConfig?: V2NIMNotificationAntispamConfig
    
      routeConfig?: V2NIMNotificationRouteConfig
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMCustomNotification {
    
      senderId: string
      receiverId: string
      conversationType: V2NIMConversationType
      timestamp: number
      content: string
      notificationConfig?: V2NIMNotificationConfig
      pushConfig?: V2NIMNotificationPushConfig
      antispamConfig?: V2NIMNotificationAntispamConfig
      routeConfig?: V2NIMNotificationRouteConfig
    }
    

    成员参数

    名称 类型 是否只读 说明
    senderId String 自定义通知发送方账号(accountId)
    receiverId String 自定义通知发送方账号(accountId)
  • 如果会话类型为单聊,该字段为聊天对象账号 accountId。
  • 如果会话类型为群组,该字段为群组 ID。
  • conversationType V2NIMConversationType 消息所属会话类型:单聊/高级群/超大群。
    timestamp long 自定义通知时间戳。
    content String 自定义通知内容,必须封装为 JSON 格式,长度上限为 4096 字节。
    notificationConfig V2NIMNotificationConfig 通知相关配置。
    pushConfig V2NIMNotificationPushConfig 第三方推送相关配置。
    第三方推送功能需要在 网易云信控制台配置
    antispamConfig V2NIMNotificationAntispamConfig 反垃圾相关配置。
    反垃圾功能包括客户端反垃圾和安全通,均需要在 网易云信控制台开通
    routeConfig V2NIMNotificationRouteConfig 系统通知事件抄送相关配置。
    消息抄送功能需要在 网易云信控制台开通

    V2NIMNotificationConfig

    系统通知相关配置。

    Android
    Javapublic class V2NIMNotificationConfig {
    
        public boolean isOfflineEnabled() {
            return offlineEnabled;
        }
    
        public boolean isUnreadEnabled() {
            return unreadEnabled;
        }
    
        public static final boolean DEFAULT_OFFLINE_ENABLED = true;
        public static final boolean DEFAULT_UNREAD_ENABLED = true;
    
        public static final class V2NIMNotificationConfigBuilder {
    
            public static V2NIMNotificationConfigBuilder builder() {
                return new V2NIMNotificationConfigBuilder();
            }
    
            public V2NIMNotificationConfigBuilder withOfflineEnabled(boolean offlineEnabled) {
                this.offlineEnabled = offlineEnabled;
                return this;
            }
    
            public V2NIMNotificationConfigBuilder withUnreadEnabled(boolean unreadEnabled) {
                this.unreadEnabled = unreadEnabled;
                return this;
            }
    
            public V2NIMNotificationConfig build() {
                return new V2NIMNotificationConfig(offlineEnabled, unreadEnabled);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMNotificationConfig : NSObject
    
    @property(nonatomic,assign,readwrite) BOOL offlineEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL unreadEnabled;
    
    @end
    
    macOS/Windows
    C++struct V2NIMNotificationConfig {
    
        bool offlineEnabled{true};
    
        bool unreadEnabled{true};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMNotificationConfig {
    
      offlineEnabled: boolean
    
      unreadEnabled: boolean
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMNotificationConfig {
    
      offlineEnabled: boolean
      unreadEnabled: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    offlineEnabled boolean true 是否需要保存离线通知:
  • true:需要保存。
  • false:不需要保存,仅在线用户接收通知。
  • unreadEnabled boolean true 是否需要计入通知未读数。

    V2NIMNotificationPushConfig

    系统通知第三方推送相关配置。

    Android
    Javapublic class V2NIMNotificationPushConfig {
    
            public boolean isPushEnabled() {
                return pushEnabled;
            }
    
            public boolean isPushNickEnabled() {
                return pushNickEnabled;
            }
    
            public String getPushContent() {
                return pushContent;
            }
    
            public String getPushPayload() {
                return pushPayload;
            }
    
            public boolean isForcePush() {
                return forcePush;
            }
    
            public String getForcePushContent() {
                return forcePushContent;
            }
    
            public List<String> getForcePushAccountIds() {
                return forcePushAccountIds;
            }
    
            public static final boolean DEFAULT_PUSH_ENABLE = V2NIMMessagePushConfig.DEFAULT_PUSH_ENABLE;
            public static final boolean DEFAULT_PUSH_NICK_ENABLE = V2NIMMessagePushConfig.DEFAULT_PUSH_NICK_ENABLE;
    
            public static final class V2NIMNotificationPushConfigBuilder {
    
                public static V2NIMNotificationPushConfigBuilder builder() {
                    return new V2NIMNotificationPushConfigBuilder();
                }
    
                public V2NIMNotificationPushConfigBuilder withPushEnabled(boolean pushEnabled) {
                    this.pushEnabled = pushEnabled;
                    return this;
                }
    
                public V2NIMNotificationPushConfigBuilder withPushNickEnabled(boolean pushNickEnabled) {
                    this.pushNickEnabled = pushNickEnabled;
                    return this;
                }
    
                public V2NIMNotificationPushConfigBuilder withPushContent(String pushContent) {
                    this.pushContent = pushContent;
                    return this;
                }
    
                public V2NIMNotificationPushConfigBuilder withPushPayload(String pushPayload) {
                    this.pushPayload = pushPayload;
                    return this;
                }
    
                public V2NIMNotificationPushConfigBuilder withForcePush(boolean forcePush) {
                    this.forcePush = forcePush;
                    return this;
                }
    
                public V2NIMNotificationPushConfigBuilder withForcePushContent(String forcePushContent) {
                    this.forcePushContent = forcePushContent;
                    return this;
                }
    
                public V2NIMNotificationPushConfigBuilder withForcePushAccountIds(List<String> forcePushAccountIds) {
                    this.forcePushAccountIds = forcePushAccountIds;
                    return this;
                }
    
                public V2NIMNotificationPushConfig build() {
                    return new V2NIMNotificationPushConfig(pushEnabled, pushNickEnabled, pushContent, pushPayload, forcePush, forcePushContent, forcePushAccountIds);
                }
            }
        }
    
    iOS
    Objective-C@interface V2NIMNotificationPushConfig : NSObject
    
    @property(nonatomic,assign,readwrite) BOOL pushEnabled;
    
    @property(nonatomic,assign,readwrite) BOOL pushNickEnabled;
    
    @property(nonatomic,strong,readwrite) NSString *pushContent;
    
    @property(nonatomic,strong,readwrite) NSString *pushPayload;
    
    @property(nonatomic,assign,readwrite) BOOL forcePush;
    
    @property(nonatomic,strong,readwrite) NSString *forcePushContent;
    
    @property(nonatomic,strong,readwrite) NSArray *forcePushAccountIds;
    
    @end
    
    macOS/Windows
    C++struct V2NIMNotificationPushConfig {
    
        bool pushEnabled{true};
    
        bool pushNickEnabled{true};
    
        nstd::string pushContent;
    
        nstd::string pushPayload;
    
        bool forcePush{false};
    
        nstd::string forcePushContent;
    
        nstd::vector<nstd::string> forcePushAccountIds;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMNotificationPushConfig {
    
      pushEnabled: boolean
    
      pushNickEnabled: boolean
    
      pushContent: string
    
      pushPayload: string
    
      forcePush: boolean
    
      forcePushContent: string
    
      forcePushAccounts: string[]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMNotificationPushConfig {
    
      pushEnabled: boolean
      pushNickEnabled: boolean
      pushContent: string
      pushPayload: string
      forcePush: boolean
      forcePushContent: string
      forcePushAccounts: string[]
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    pushEnabled boolean true 是否需要推送通知。
    pushNickEnabled boolean true 是否需要推送通知发送方昵称。
    pushContent String 云信内置的推送文案 推送文案。
    pushPayload String - 推送 Payload
    forcePush boolean false 是否忽略用户通知提醒相关设置,强制推送。
    forcePushContent String - 强制推送文案。
    forcePushAccountIds List<String> - 强制推送目标账号列表。

    V2NIMNotificationRouteConfig

    系统通知事件抄送相关配置。

    Android
    Javapublic class V2NIMNotificationRouteConfig implements Serializable {
    
            public boolean isRouteEnabled() {
                return routeEnabled;
            }
    
            public String getRouteEnvironment() {
                return routeEnvironment;
            }
    
            @Override
            public String toString() {
                return "V2NIMMessageRouteConfig{" +
                        "routeEnabled=" + routeEnabled +
                        ", routeEnvironment='" + routeEnvironment + '\'' +
                        '}';
            }
    
            public static final boolean DEFAULT_ROUTE_ENABLE = true;
    
            public static final class V2NIMNotificationRouteConfigBuilder {
    
                public static V2NIMNotificationRouteConfigBuilder builder() {
                    return new V2NIMNotificationRouteConfigBuilder();
                }
    
                public V2NIMNotificationRouteConfigBuilder withRouteEnabled(boolean routeEnabled) {
                    this.routeEnabled = routeEnabled;
                    return this;
                }
    
                public V2NIMNotificationRouteConfigBuilder withRouteEnvironment(String routeEnvironment) {
                    this.routeEnvironment = routeEnvironment;
                    return this;
                }
    
                public V2NIMNotificationRouteConfig build() {
                    return new V2NIMNotificationRouteConfig(routeEnabled, routeEnvironment);
                }
            }
        }
    
    iOS
    Objective-C@interface V2NIMNotificationRouteConfig : NSObject
    
    @property(nonatomic,assign,readwrite) BOOL routeEnabled;
    
    @property(nonatomic,strong,readwrite) NSString *routeEnvironment;
    @end
    
    macOS/Windows
    C++struct V2NIMNotificationRouteConfig {
    
        bool routeEnabled{true};
    
        nstd::optional<nstd::string> routeEnvironment;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMNotificationRouteConfig {
    
      routeEnabled: boolean
    
      routeEnvironment: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMNotificationRouteConfig {
    
      routeEnabled: boolean
      routeEnvironment: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    routeEnabled boolean true 是否需要系统通知事件抄送。
    routeEnvironment String routeEnabled 为 true 则为必填 - 环境变量,用于指向不同系统通知事件抄送、第三方回调等配置。

    V2NIMNotificationAntispamConfig

    系统通知反垃圾配置,包括本地反垃圾和安全通的相关配置。

    Android
    Javapublic class V2NIMNotificationAntispamConfig {
    
            public V2NIMNotificationAntispamConfig() {
                this(DEFAULT_ANTISPAM_ENABLED, null);
            }
    
            public V2NIMNotificationAntispamConfig(boolean antispamEnabled, String antispamCustomNotification) {
                this.antispamEnabled = antispamEnabled;
                this.antispamCustomNotification = antispamCustomNotification;
            }
    
            public boolean isAntispamEnabled() {
                return antispamEnabled;
            }
    
            public String getAntispamCustomNotification() {
                return antispamCustomNotification;
            }
    
            public static final boolean DEFAULT_ANTISPAM_ENABLED = true;
    
            public static final class V2NIMNotificationAntispamConfigBuilder {
    
                public static V2NIMNotificationAntispamConfigBuilder builder() {
                    return new V2NIMNotificationAntispamConfigBuilder();
                }
    
                public V2NIMNotificationAntispamConfigBuilder withAntispamEnabled(boolean antispamEnabled) {
                    this.antispamEnabled = antispamEnabled;
                    return this;
                }
    
                public V2NIMNotificationAntispamConfigBuilder withAntispamCustomNotification(String antispamCustomNotification) {
                    this.antispamCustomNotification = antispamCustomNotification;
                    return this;
                }
    
                public V2NIMNotificationAntispamConfig build() {
                    return new V2NIMNotificationAntispamConfig(antispamEnabled, antispamCustomNotification);
                }
            }
        }
    
    iOS
    Objective-C@interface V2NIMNotificationAntispamConfig : NSObject
    
    @property(nonatomic,assign,readwrite) BOOL antispamEnabled;
    
    @property(nonatomic,strong,readwrite) NSString *antispamCustomNotification;
    @end
    
    macOS/Windows
    C++struct V2NIMNotificationAntispamConfig {
    
        nstd::optional<bool> antispamEnabled;
    
        nstd::optional<nstd::string> antispamCustomMessage;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMNotificationAntispamConfig {
    
      antispamEnabled: boolean
    
      antispamCustomNotification: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMNotificationAntispamConfig {
    
      antispamEnabled: boolean
      antispamCustomNotification: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    antispamEnabled boolean true 是否对该系统通知启用安全通检测。
    antispamCustomNotification String antispamEnabled 为 true 时必填 - 系统通知中需要反垃圾的内容,必须是 JSON 格式,长度不超过 5000 字节。格式如下 { "type": 1, //1:文本,2:图片,3 视频 "data": "" //文本内容 or 图片地址 or 视频地址 }

    V2NIMSendCustomNotificationParams

    自定义通知发送参数。

    Android
    Javapublic class V2NIMSendCustomNotificationParams {
    
            public V2NIMNotificationConfig getNotificationConfig() {
                return notificationConfig;
            }
    
            public V2NIMNotificationPushConfig getPushConfig() {
                return pushConfig;
            }
    
            public V2NIMNotificationAntispamConfig getAntispamConfig() {
                return antispamConfig;
            }
    
            public V2NIMNotificationRouteConfig getRouteConfig() {
                return routeConfig;
            }
    
            public static final class V2NIMSendCustomNotificationParamsBuilder {
    
                public static V2NIMSendCustomNotificationParamsBuilder builder() {
                    return new V2NIMSendCustomNotificationParamsBuilder();
                }
    
                public V2NIMSendCustomNotificationParamsBuilder withNotificationConfig(V2NIMNotificationConfig notificationConfig) {
                    this.notificationConfig = notificationConfig;
                    return this;
                }
    
                public V2NIMSendCustomNotificationParamsBuilder withPushConfig(V2NIMNotificationPushConfig pushConfig) {
                    this.pushConfig = pushConfig;
                    return this;
                }
    
                public V2NIMSendCustomNotificationParamsBuilder withAntispamConfig(V2NIMNotificationAntispamConfig antispamConfig) {
                    this.antispamConfig = antispamConfig;
                    return this;
                }
    
                public V2NIMSendCustomNotificationParamsBuilder withRouteConfig(V2NIMNotificationRouteConfig routeConfig) {
                    this.routeConfig = routeConfig;
                    return this;
                }
    
                public V2NIMSendCustomNotificationParams build() {
                    return new V2NIMSendCustomNotificationParams(notificationConfig, pushConfig, antispamConfig, routeConfig);
                }
            }
        }
    
    iOS
    Objective-C@interface V2NIMSendCustomNotificationParams : NSObject
    
    @property(nonatomic,strong) V2NIMNotificationConfig *notificationConfig;
    
    @property(nonatomic,strong) V2NIMNotificationPushConfig *pushConfig;
    
    @property(nonatomic,strong) V2NIMNotificationAntispamConfig *antispamConfig;
    
    @property(nonatomic,strong) V2NIMNotificationRouteConfig *routeConfig;
    @end
    
    macOS/Windows
    C++struct V2NIMSendCustomNotificationParams {
    
        V2NIMNotificationConfig notificationConfig;
    
        V2NIMNotificationPushConfig pushConfig;
    
        V2NIMNotificationAntispamConfig antispamConfig;
    
        V2NIMNotificationRouteConfig routeConfig;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMSendCustomNotificationParams {
    
      notificationConfig?: V2NIMNotificationConfig
    
      pushConfig?: V2NIMNotificationPushConfig
    
      antispamConfig?: V2NIMNotificationAntispamConfig
    
      routeConfig?: V2NIMNotificationRouteConfig
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMSendCustomNotificationParams {
    
      notificationConfig?: V2NIMNotificationConfig
      pushConfig?: V2NIMNotificationPushConfig
      antispamConfig?: V2NIMNotificationAntispamConfig
      routeConfig?: V2NIMNotificationRouteConfig
    }
    

    成员参数

    名称 类型 是否只读 说明
    notificationConfig V2NIMNotificationConfig 通知相关配置。
    pushConfig V2NIMNotificationPushConfig 第三方推送相关配置。
    第三方推送功能需要在 网易云信控制台配置
    antispamConfig V2NIMNotificationAntispamConfig 反垃圾相关配置。
    反垃圾功能包括客户端反垃圾和安全通,均需要在 网易云信控制台开通
    routeConfig V2NIMNotificationRouteConfig 系统通知事件抄送相关配置。
    消息抄送功能需要在 网易云信控制台开通

    V2NIMBroadcastNotification

    广播通知。

    Android
    Javapublic interface V2NIMBroadcastNotification {
            long getId();
    
            String getSenderId();
    
            long getTimestamp();
    
            String getContent();
    }
    
    iOS
    Objective-C@interface V2NIMBroadcastNotification : NSObject
    
    @property(nonatomic,assign,readonly) NSUInteger id;
    
    @property(nonatomic,strong,readonly) NSString *senderId;
    
    @property(nonatomic,assign,readonly) NSTimeInterval timestamp;
    
    @property(nonatomic,strong,readonly) NSString *content;
    @end
    
    macOS/Windows
    C++struct V2NIMBroadcastNotification {
    
        uint64_t id;
    
        nstd::string senderId;
    
        uint64_t timestamp;
    
        nstd::string content;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMBroadcastNotification {
    
      id: string
    
      senderId: string
    
      time: number
    
      content: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMBroadcastNotification {
    
      id: string
      senderId: string
      time: number
      content: string
    }
    

    成员参数

    名称 类型 是否只读 说明
    id String 广播通知 ID
    senderId String 广播通知发送方账号(accountId)
    timestamp long 广播通知时间戳。
    content String 广播通知内容,必须为 JSON 格式。

    V2NIMNotificationListener

    系统通知相关监听器。

    Android
    Javapublic interface V2NIMNotificationListener {
    
        void onReceiveCustomNotifications(List<V2NIMCustomNotification> customNotifications);
    
        void onReceiveBroadcastNotifications(List<V2NIMBroadcastNotification> broadcastNotifications);
    }
    
    iOS
    Objective-C@protocol V2NIMNotificationListener <NSObject>
    
    - (void)onReceiveCustomNotifications:(NSArray <V2NIMCustomNotification *> *)customNotifications;
    
    - (void)onReceiveBroadcastNotifications:(NSArray <V2NIMBroadcastNotification *> *)boradcastNotifications;
    
    @end
    
    macOS/Windows
    C++cationListener {
    
        nstd::function<void(nstd::vector<V2NIMCustomNotification> customNotification)> onReceiveCustomNotifications;
    
        nstd::function<void(nstd::vector<V2NIMBroadcastNotification> broadcastNotification)> onReceiveBroadcastNotifications;
    };
    

    成员函数

    • onReceiveCustomNotifications

      自定义通知接收回调,本端接收到发送方自定义通知,或其他端同步的自定义通知时会触发该回调。

      参数名称 类型 说明
      customNotifications List<V2NIMCustomNotification> 自定义通知列表
    • onReceiveBroadcastNotifications

      广播通知接收回调。

      本端接收到服务端下发的广播通知时会触发该回调。

      参数名称 类型 说明
      boradcastNotifications List<V2NIMBroadcastNotification> 广播通知列表

    V2NIMTeam

    群组对象。

    Android
    Javapublic interface V2NIMTeam extends Serializable {
        String getTeamId();
    
        V2NIMTeamType getTeamType();
    
        String getName();
    
        String getOwnerAccountId();
    
        int getMemberLimit();
    
        int getMemberCount();
    
        long getCreateTime();
    
        long getUpdateTime();
    
        String getIntro();
    
        String getAnnouncement();
    
        String getAvatar();
    
        String getServerExtension();
    
        String getCustomerExtension();
    
        V2NIMTeamJoinMode getJoinMode();
    
        V2NIMTeamAgreeMode getAgreeMode();
    
        V2NIMTeamInviteMode getInviteMode();
    
        V2NIMTeamUpdateInfoMode getUpdateInfoMode();
    
        V2NIMTeamUpdateExtensionMode getUpdateExtensionMode();
    
        V2NIMTeamChatBannedMode getChatBannedMode();
    
        boolean isValidTeam();
    }
    
    iOS
    Objective-C@interface V2NIMTeam : NSObject <NSCopying>
    
    @property(nonatomic,copy,readonly) NSString *teamId;
    
    @property(nonatomic,assign,readonly) V2NIMTeamType teamType;
    
    @property(nonatomic,copy,readonly) NSString *name;
    
    @property(nonatomic,copy,readonly) NSString *ownerAccountId;
    
    @property(nonatomic,assign,readonly) NSInteger memberLimit;
    
    @property(nonatomic,assign,readonly) NSInteger memberCount;
    
    @property(nonatomic,assign,readonly) NSTimeInterval createTime;
    
    @property(nonatomic,assign,readonly) NSTimeInterval updateTime;
    
    @property(nullable,nonatomic,copy,readonly) NSString *intro;
    
    @property(nullable,nonatomic,copy,readonly) NSString *announcement;
    
    @property(nullable,nonatomic,copy,readonly) NSString *avatar;
    
    @property(nullable,nonatomic,copy,readonly) NSString *serverExtension;
    
    @property(nullable,nonatomic,copy,readonly) NSString *customerExtension;
    
    @property(nonatomic,assign,readonly) V2NIMTeamJoinMode joinMode;
    
    @property(nonatomic,assign,readonly) V2NIMTeamAgreeMode agreeMode;
    
    @property(nonatomic,assign,readonly) V2NIMTeamInviteMode inviteMode;
    
    @property(nonatomic,assign,readonly) V2NIMTeamUpdateInfoMode updateInfoMode;
    
    @property(nonatomic,assign,readonly) V2NIMTeamUpdateExtensionMode updateExtensionMode;
    
    @property(nonatomic,assign,readonly) V2NIMTeamChatBannedMode chatBannedMode;
    
    @property(nonatomic,assign,readonly) BOOL isValidTeam;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeam {
        nstd::string teamId;
        V2NIMTeamType teamType{V2NIM_TEAM_TYPE_NORMAL};
        nstd::string name;
        nstd::string ownerAccountId;
        uint32_t memberLimit{0};
        uint32_t memberCount{0};
        uint64_t createTime{0};
        uint64_t updateTime{0};
        nstd::optional<nstd::string> intro;
        nstd::optional<nstd::string> announcement;
        nstd::optional<nstd::string> avatar;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<nstd::string> customerExtension;
        V2NIMTeamJoinMode joinMode{V2NIM_TEAM_JOIN_MODE_APPLY};
        V2NIMTeamAgreeMode agreeMode{V2NIM_TEAM_AGREE_MODE_AUTH};
        V2NIMTeamInviteMode inviteMode{V2NIM_TEAM_INVITE_MODE_MANAGER};
        V2NIMTeamUpdateInfoMode updateInfoMode{V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER};
        V2NIMTeamUpdateExtensionMode updateExtensionMode{V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER};
        V2NIMTeamChatBannedMode chatBannedMode{V2NIM_TEAM_CHAT_BANNED_MODE_NONE};
        bool isValidTeam{true};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeam = {
      teamId: string
      teamType: V2NIMTeamType
      name: string
      ownerAccountId: string
      memberLimit: number
      memberCount: number
      createTime: number
      updateTime: number
      intro: string
      announcement: string
      avatar: string
      serverExtension?: string
      customerExtension?: string
      joinMode: V2NIMTeamJoinMode
      agreeMode: V2NIMTeamAgreeMode
      inviteMode: V2NIMTeamInviteMode
      updateInfoMode: V2NIMTeamUpdateInfoMode
      updateExtensionMode: V2NIMTeamUpdateExtensionMode
      chatBannedMode: V2NIMTeamChatBannedMode
      isValidTeam: boolean
    
      messageNotifyMode: V2NIMTeamMessageNotifyMode
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMTeam = {
    
      teamId: string
      teamType: V2NIMTeamType
      name: string
      ownerAccountId: string
      memberLimit: number
      memberCount: number
      createTime: number
      updateTime: number
      intro: string
      announcement: string
      avatar: string
      serverExtension?: string
      customerExtension?: string
      joinMode: V2NIMTeamJoinMode
      agreeMode: V2NIMTeamAgreeMode
      inviteMode: V2NIMTeamInviteMode
      updateInfoMode: V2NIMTeamUpdateInfoMode
      updateExtensionMode: V2NIMTeamUpdateExtensionMode
      chatBannedMode: V2NIMTeamChatBannedMode
      isValidTeam: boolean
      messageNotifyMode: V2NIMTeamMessageNotifyMode
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    teamId String - 群组 ID
    teamType V2NIMTeamType V2NIM_TEAM_TYPE_NORMAL 群组类型。
    name String - 群组名称。
    ownerAccountId String - 群主账号。
    memberLimit int - 群组人数上限。必须大于 0,否则返回参数错误。
  • 高级群:默认 200 人/群(免费),可通过 网易云信控制台配置为 500/1000/2000 人/群(计费),最大可扩展至 5000 人/群(联系商务经理或技术支持)。
  • 超大群:默认 2000 人/群,可通过 网易云信控制台 上配置为 2000-10000 人/群。
  • 2000 人以上的群必须由服务端 API 发起创建。
  • memberCount int - 群组当前人数。
    createTime long - 群组创建时间戳。
    updateTime long - 群组更新时间戳。
    intro String - 群组介绍,最大为 255 个字符。
    announcement String - 群组公告,最大为 5000 个字符。
    avatar String - 群组头像。
    serverExtension String - 群组服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    customerExtension String - 客户自定义扩展字段,仅服务器 API 可以设置,SDK 仅负责透传,不解析内容。
    joinMode V2NIMTeamJoinMode V2NIMTeamJoinMode.V2NIM_TEAM_JOIN_MODE_FREE 无需验证 入群验证模式。
    agreeMode V2NIMTeamAgreeMode V2NIMTeamAgreeMode.V2NIM_TEAM_AGREE_MODE_AUTH 需要被邀请人同意 被邀请人同意模式。
    inviteMode V2NIMTeamInviteMode V2NIMTeamInviteMode.V2NIM_TEAM_INVITE_MODE_MANAGER 仅群主或管理员可以邀请其他人入群 群组邀请模式,即群主/管理员或普通成员可以邀请入群。
    updateInfoMode V2NIMTeamUpdateInfoMode V2NIMTeamUpdateInfoMode.V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组资料修改模式。
    updateExtensionMode V2NIMTeamUpdateExtensionMode V2NIMTeamUpdateExtensionMode.V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组扩展字段修改模式。
    chatBannedMode V2NIMTeamChatBannedMode V2NIM_TEAM_CHAT_BANNED_MODE_NONE 不禁言 群组禁言状态。
    isValidTeam boolean true 是否为自己所在且有效的群组。

    V2NIMTeamMember

    群成员对象。

    Android
    Javapublic interface V2NIMTeamMember extends Serializable {
        String getTeamId();
    
        V2NIMTeamType getTeamType();
    
        String getAccountId();
    
        V2NIMTeamMemberRole getMemberRole();
    
        String getTeamNick();
    
        String getServerExtension();
    
        long getJoinTime();
    
        long getUpdateTime();
    
        String getInvitorAccountId();
    
        boolean isInTeam();
    
        boolean isChatBanned();
    }
    
    iOS
    Objective-C@interface V2NIMTeamMember : NSObject <NSCopying>
    
    @property(nonatomic,copy,readonly) NSString *teamId;
    
    @property(nonatomic,assign,readonly) V2NIMTeamType teamType;
    
    @property(nonatomic,copy,readonly) NSString *accountId;
    
    @property(nonatomic,assign,readonly) V2NIMTeamMemberRole memberRole;
    
    @property(nullable,nonatomic,copy,readonly) NSString *teamNick;
    
    @property(nullable,nonatomic,copy,readonly) NSString *serverExtension;
    
    @property(nonatomic,assign,readonly) NSTimeInterval joinTime;
    
    @property(nonatomic,assign,readonly) NSTimeInterval updateTime;
    
    @property(nonatomic,assign,readonly) BOOL inTeam;
    
    @property(nonatomic,assign,readonly) BOOL chatBanned;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamMember {
        nstd::string teamId;
        V2NIMTeamType teamType{V2NIM_TEAM_TYPE_NORMAL};
        nstd::string accountId;
        nstd::optional<V2NIMTeamMemberRole> memberRole;
        nstd::optional<nstd::string> teamNick;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<uint64_t> joinTime;
        nstd::optional<uint64_t> updateTime;
        nstd::optional<nstd::string> invitorAccountId;
        nstd::optional<bool> inTeam;
        nstd::optional<bool> chatBanned;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeamMember = {
      teamId: string
      teamType: V2NIMTeamType
      accountId: string
      memberRole: V2NIMTeamMemberRole
      teamNick?: string
      serverExtension?: string
      joinTime: number
      updateTime?: number
      // invitorAccountId: string
      inTeam: boolean
      chatBanned?: boolean
    }
    
    HarmonyOS
    TypeScriptexport class V2NIMTeamMember {
    
      teamId: string
      teamType: V2NIMTeamType
      accountId: string
      memberRole: V2NIMTeamMemberRole
      teamNick?: string
      serverExtension?: string
      joinTime: number
      updateTime?: number
      invitorAccountId?: string
      inTeam: boolean
      chatBanned?: boolean
    }
    

    成员参数

    名称 类型 是否必填 是否只读 说明
    teamId String 所属群组 ID
    teamType V2NIMTeamType 群组类型。
    accountId String 群成员账号。
    memberRole V2NIMTeamMemberRole 群成员类型。
    teamNick String 群组内昵称。
    serverExtension String 群组服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    joinTime long 加入群组时间戳。
    updateTime long 群成员信息更新时间戳。
    invitorAccountId String 入群邀请人,主动加入群则该字段为空。
    chatBanned boolean 是否被禁言。
    inTeam boolean 是否在群组中。

    V2NIMCreateTeamParams

    群组创建参数。

    Android
    Javapublic class V2NIMCreateTeamParams {
    
        public V2NIMTeamType getTeamType() {
            return this.teamType;
        }
    
        public String getName() {
            return this.name;
        }
    
        public Integer getMemberLimit() {
            return this.memberLimit;
        }
    
        public String getIntro() {
            return this.intro;
        }
    
        public String getAnnouncement() {
            return this.announcement;
        }
    
        public String getAvatar() {
            return this.avatar;
        }
    
        public String getServerExtension() {
            return this.serverExtension;
        }
    
        public V2NIMTeamJoinMode getJoinMode() {
            return this.joinMode;
        }
    
        public V2NIMTeamAgreeMode getAgreeMode() {
            return this.agreeMode;
        }
    
        public V2NIMTeamInviteMode getInviteMode() {
            return this.inviteMode;
        }
    
        public V2NIMTeamUpdateInfoMode getUpdateInfoMode() {
            return this.updateInfoMode;
        }
    
        public V2NIMTeamUpdateExtensionMode getUpdateExtensionMode() {
            return this.updateExtensionMode;
        }
    
        public V2NIMTeamChatBannedMode getChatBannedMode() {
            return this.chatBannedMode;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public void setTeamType(V2NIMTeamType teamType) {
            this.teamType = teamType;
        }
    
        public void setMemberLimit(int memberLimit) {
            this.memberLimit = memberLimit;
        }
    
        public void setIntro(String intro) {
            this.intro = intro;
        }
    
        public void setAnnouncement(String announcement) {
            this.announcement = announcement;
        }
    
        public void setAvatar(String avatar) {
            this.avatar = avatar;
        }
    
        public void setServerExtension(String serverExtension) {
            this.serverExtension = serverExtension;
        }
    
        public void setJoinMode(V2NIMTeamJoinMode joinMode) {
            this.joinMode = joinMode;
        }
    
        public void setAgreeMode(V2NIMTeamAgreeMode agreeMode) {
            this.agreeMode = agreeMode;
        }
    
        public void setInviteMode(V2NIMTeamInviteMode inviteMode) {
            this.inviteMode = inviteMode;
        }
    
        public void setUpdateInfoMode(V2NIMTeamUpdateInfoMode updateInfoMode) {
            this.updateInfoMode = updateInfoMode;
        }
    
        public void setUpdateExtensionMode(V2NIMTeamUpdateExtensionMode updateExtensionMode) {
            this.updateExtensionMode = updateExtensionMode;
        }
    
        public void setChatBannedMode(V2NIMTeamChatBannedMode chatBannedMode) {
            this.chatBannedMode = chatBannedMode;
        }
    
        public boolean isValid() {
            if (teamType == null || teamType == V2NIMTeamType.V2NIM_TEAM_TYPE_INVALID) {
                return false;
            }
            if (memberLimit != null && memberLimit <= 0) {
                return false;
            }
            if (TextUtils.isEmpty(name)) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMCreateTeamParams : NSObject
    
    @property(nonatomic,copy) NSString *name;
    
    @property(nonatomic,assign) V2NIMTeamType teamType;
    
    @property(nonatomic,assign) NSInteger memberLimit;
    
    @property(nullable,nonatomic,copy) NSString *intro;
    
    @property(nullable,nonatomic,copy) NSString *announcement;
    
    @property(nullable,nonatomic,copy) NSString *avatar;
    
    @property(nullable,nonatomic,copy) NSString *serverExtension;
    
    @property(nonatomic,assign) V2NIMTeamJoinMode joinMode;
    
    @property(nonatomic,assign) V2NIMTeamAgreeMode agreeMode;
    
    @property(nonatomic,assign) V2NIMTeamInviteMode inviteMode;
    
    @property(nonatomic,assign) V2NIMTeamUpdateInfoMode updateInfoMode;
    
    @property(nonatomic,assign) V2NIMTeamUpdateExtensionMode updateExtensionMode;
    
    @property(nonatomic,assign) V2NIMTeamChatBannedMode chatBannedMode;
    
    @end
    
    macOS/Windows
    C++struct V2NIMCreateTeamParams {
        nstd::string name;
        V2NIMTeamType teamType{V2NIM_TEAM_TYPE_NORMAL};
        nstd::optional<uint32_t> memberLimit;
        nstd::optional<nstd::string> intro;
        nstd::optional<nstd::string> announcement;
        nstd::optional<nstd::string> avatar;
        nstd::optional<nstd::string> serverExtension;
        V2NIMTeamJoinMode joinMode{V2NIM_TEAM_JOIN_MODE_APPLY};
        V2NIMTeamAgreeMode agreeMode{V2NIM_TEAM_AGREE_MODE_AUTH};
        V2NIMTeamInviteMode inviteMode{V2NIM_TEAM_INVITE_MODE_MANAGER};
        V2NIMTeamUpdateInfoMode updateInfoMode{V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER};
        V2NIMTeamUpdateExtensionMode updateExtensionMode{V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER};
        V2NIMTeamChatBannedMode chatBannedMode{V2NIM_TEAM_CHAT_BANNED_MODE_NONE};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMCreateTeamParams = {
      name: string
      teamType: V2NIMTeamType
      memberLimit?: number
      intro?: string
      announcement?: string
      avatar?: string
      serverExtension?: string
      joinMode?: V2NIMTeamJoinMode
      agreeMode?: V2NIMTeamAgreeMode
      inviteMode?: V2NIMTeamInviteMode
      updateInfoMode?: V2NIMTeamUpdateInfoMode
      updateExtensionMode?: V2NIMTeamUpdateExtensionMode
      chatBannedMode?: V2NIMTeamChatBannedMode
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMCreateTeamParams = {
    
      name: string
      teamType: V2NIMTeamType
      memberLimit?: number
      intro?: string
      announcement?: string
      avatar?: string
      serverExtension?: string
      joinMode?: V2NIMTeamJoinMode
      agreeMode?: V2NIMTeamAgreeMode
      inviteMode?: V2NIMTeamInviteMode
      updateInfoMode?: V2NIMTeamUpdateInfoMode
      updateExtensionMode?: V2NIMTeamUpdateExtensionMode
      chatBannedMode?: V2NIMTeamChatBannedMode
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    name String - 群组名称。
    teamType V2NIMTeamType V2NIM_TEAM_TYPE_NORMAL 群组类型。
    必须为高级群或超大群,否则返回参数错误。
    memberLimit int
  • 高级群:200
  • 超大群:2000
  • 群组人数上限。必须大于 0,否则返回参数错误。
  • 高级群:默认 200 人/群(免费),可通过 网易云信控制台配置为 500/1000/2000 人/群(计费),最大可扩展至 5000 人/群(联系商务经理或技术支持)。
  • 超大群:默认 2000 人/群,可通过网易云信控制台 配置为 2000-10000 人/群。
  • 2000 人以上的群必须由服务端 API 发起创建。
  • intro String null 群组介绍,长度上限为 255 个字符。
    announcement String null 群组公告,长度上限为 1024 个字符。最大可扩展至 5000 个字符(提交工单 联系网易云信技术支持工程师申请)。
    avatar String null 群组头像。
    serverExtension String null 群组服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    joinMode V2NIMTeamJoinMode V2NIMTeamJoinMode.V2NIM_TEAM_JOIN_MODE_FREE 无需验证 入群验证模式。
    agreeMode V2NIMTeamAgreeMode V2NIMTeamAgreeMode.V2NIM_TEAM_AGREE_MODE_AUTH 需要被邀请人同意 被邀请人同意模式。
    inviteMode V2NIMTeamInviteMode V2NIMTeamInviteMode.V2NIM_TEAM_INVITE_MODE_MANAGER 仅群主或管理员可以邀请其他人入群 群组邀请模式,即群主/管理员或普通成员可以邀请入群。
    updateInfoMode V2NIMTeamUpdateInfoMode V2NIMTeamUpdateInfoMode.V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组资料修改模式。
    updateExtensionMode V2NIMTeamUpdateExtensionMode V2NIMTeamUpdateExtensionMode.V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组扩展字段修改模式。
    chatBannedMode V2NIMTeamChatBannedMode V2NIM_TEAM_CHAT_BANNED_MODE_NONE 不禁言 群组禁言状态。

    V2NIMTeamMemberQueryOption

    群成员分页查询选项。

    Android
    Javapublic class V2NIMTeamMemberQueryOption {
    
        public V2NIMTeamMemberQueryOption() {
        }
    
        public V2NIMTeamMemberQueryOption(V2NIMTeamMemberRoleQueryType roleQueryType, boolean onlyChatBanned, V2NIMQueryDirection direction, String nextToken, int limit) {
            this.roleQueryType = roleQueryType;
            this.onlyChatBanned = onlyChatBanned;
            this.direction = direction;
            this.nextToken = nextToken;
            this.limit = limit;
        }
    
        public V2NIMTeamMemberRoleQueryType getRoleQueryType() {
            return roleQueryType;
        }
    
        public void setRoleQueryType(V2NIMTeamMemberRoleQueryType roleQueryType) {
            this.roleQueryType = roleQueryType;
        }
    
        public boolean isOnlyChatBanned() {
            return onlyChatBanned;
        }
    
        public void setOnlyChatBanned(boolean onlyChatBanned) {
            this.onlyChatBanned = onlyChatBanned;
        }
    
        public V2NIMQueryDirection getDirection() {
            return direction;
        }
    
        public void setDirection(V2NIMQueryDirection direction) {
            this.direction = direction;
        }
    
        public String getNextToken() {
            return nextToken;
        }
    
        public void setNextToken(String nextToken) {
            this.nextToken = nextToken;
        }
    
        public Integer getLimit() {
            return limit;
        }
    
        public void setLimit(int limit) {
            this.limit = limit;
        }
    
        public boolean isValid() {
            if (roleQueryType == null) {
                return false;
            }
            if (limit != null && limit <= 0) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMTeamMemberQueryOption : NSObject
    
    @property(nonatomic,assign) V2NIMTeamMemberRoleQueryType roleQueryType;
    
    @property(nonatomic,assign) BOOL onlyChatBanned;
    
    @property(nonatomic,assign) V2NIMQueryDirection direction;
    
    @property(nullable,nonatomic,copy) NSString *nextToken;
    
    @property(nonatomic,assign) NSInteger limit;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamMemberQueryOption {
        nstd::optional<V2NIMTeamMemberRoleQueryType> roleQueryType;
        bool onlyChatBanned{false};
        V2NIMQueryDirection direction{V2NIM_QUERY_DIRECTION_DESC};
        nstd::string nextToken;
        uint32_t limit{V2NIM_DEFAULT_TEAM_MEMBER_LIST_LIMIT};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeamMemberQueryOption = {
      roleQueryType?: V2NIMTeamMemberRoleQueryType
      onlyChatBanned?: boolean
      direction?: V2NIMQueryDirection
      limit?: number
      nextToken?: string
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMTeamMemberQueryOption = {
    
      roleQueryType?: V2NIMTeamMemberRoleQueryType
      onlyChatBanned?: boolean
      direction?: V2NIMQueryDirection
      limit?: number
      nextToken?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    roleQueryType V2NIMTeamMemberRoleQueryType - 群成员查询类型。
    onlyChatBanned boolean false 是否只返回聊天禁言成员列表
  • true:仅聊天禁言成员列表
  • false:全部群成员列表。
  • direction V2NIMQueryDirection V2NIM_QUERY_DIRECTION_DESC 消息查询方向(同时也是查询结果的排序方向):
  • DESC:按时间从大到小(倒序)
  • ASC:按时间从小到大查询(正序)
  • nextToken String "" 分页偏移,首次查询传空,下一次查询传入上一次查询返回值中的 nextToken
    limit int 100 单次查询群成员最大数量。不建议超过 100,设置小于等于 0 则默认为 100。

    V2NIMUpdateTeamInfoParams

    群组信息更新参数。

    Android
    Javapublic class V2NIMUpdateTeamInfoParams {
    
        public String getName() {
            return this.name;
        }
    
        public Integer getMemberLimit() {
            return this.memberLimit;
        }
    
        public String getIntro() {
            return this.intro;
        }
    
        public String getAnnouncement() {
            return this.announcement;
        }
    
        public String getAvatar() {
            return this.avatar;
        }
    
        public String getServerExtension() {
            return this.serverExtension;
        }
    
        public V2NIMTeamJoinMode getJoinMode() {
            return this.joinMode;
        }
    
        public V2NIMTeamAgreeMode getAgreeMode() {
            return this.agreeMode;
        }
    
        public V2NIMTeamInviteMode getInviteMode() {
            return this.inviteMode;
        }
    
        public V2NIMTeamUpdateInfoMode getUpdateInfoMode() {
            return this.updateInfoMode;
        }
    
        public V2NIMTeamUpdateExtensionMode getUpdateExtensionMode() {
            return this.updateExtensionMode;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public void setMemberLimit(int memberLimit) {
            this.memberLimit = memberLimit;
        }
    
        public void setIntro(String intro) {
            this.intro = intro;
        }
    
        public void setAnnouncement(String announcement) {
            this.announcement = announcement;
        }
    
        public void setAvatar(String avatar) {
            this.avatar = avatar;
        }
    
        public void setServerExtension(String serverExtension) {
            this.serverExtension = serverExtension;
        }
    
        public void setJoinMode(V2NIMTeamJoinMode joinMode) {
            this.joinMode = joinMode;
        }
    
        public void setAgreeMode(V2NIMTeamAgreeMode agreeMode) {
            this.agreeMode = agreeMode;
        }
    
        public void setInviteMode(V2NIMTeamInviteMode inviteMode) {
            this.inviteMode = inviteMode;
        }
    
        public void setUpdateInfoMode(V2NIMTeamUpdateInfoMode updateInfoMode) {
            this.updateInfoMode = updateInfoMode;
        }
    
        public void setUpdateExtensionMode(V2NIMTeamUpdateExtensionMode updateExtensionMode) {
            this.updateExtensionMode = updateExtensionMode;
        }
    
        public boolean isValid() {
            if (this.name != null && this.name.isEmpty()) {
                return false;
            }
            if (this.memberLimit != null && this.memberLimit <= 0) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMUpdateTeamInfoParams : NSObject
    
    @property(nullable,nonatomic,copy) NSString *name;
    
    @property(nonatomic,assign) NSInteger memberLimit;
    
    @property(nullable,nonatomic,copy) NSString *intro;
    
    @property(nullable,nonatomic,copy) NSString *announcement;
    
    @property(nullable,nonatomic,copy) NSString *avatar;
    
    @property(nullable,nonatomic,copy) NSString *serverExtension;
    
    @property(nonatomic,assign) V2NIMTeamJoinMode joinMode;
    
    @property(nonatomic,assign) V2NIMTeamAgreeMode agreeMode;
    
    @property(nonatomic,assign) V2NIMTeamInviteMode inviteMode;
    
    @property(nonatomic,assign) V2NIMTeamUpdateInfoMode updateInfoMode;
    
    @property(nonatomic,assign) V2NIMTeamUpdateExtensionMode updateExtensionMode;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUpdateTeamInfoParams {
        nstd::optional<nstd::string> name;
        nstd::optional<uint32_t> memberLimit;
        nstd::optional<nstd::string> intro;
        nstd::optional<nstd::string> announcement;
        nstd::optional<nstd::string> avatar;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<V2NIMTeamJoinMode> joinMode;
        nstd::optional<V2NIMTeamAgreeMode> agreeMode;
        nstd::optional<V2NIMTeamInviteMode> inviteMode;
        nstd::optional<V2NIMTeamUpdateInfoMode> updateInfoMode;
        nstd::optional<V2NIMTeamUpdateExtensionMode> updateExtensionMode;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUpdateTeamInfoParams = {
      name?: string
      memberLimit?: number
      intro?: string
      announcement?: string
      avatar?: string
      serverExtension?: string
      joinMode?: V2NIMTeamJoinMode
      agreeMode?: V2NIMTeamAgreeMode
      inviteMode?: V2NIMTeamInviteMode
      updateInfoMode?: V2NIMTeamUpdateInfoMode
      updateExtensionMode?: V2NIMTeamUpdateExtensionMode
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMUpdateTeamInfoParams = {
    
      name?: string
      memberLimit?: number
      intro?: string
      announcement?: string
      avatar?: string
      serverExtension?: string
      joinMode?: V2NIMTeamJoinMode
      agreeMode?: V2NIMTeamAgreeMode
      inviteMode?: V2NIMTeamInviteMode
      updateInfoMode?: V2NIMTeamUpdateInfoMode
      updateExtensionMode?: V2NIMTeamUpdateExtensionMode
    }
    

    成员参数

    • 如果您的应用平台为 Android,则需要调用对应的成员函数获取对应参数。
    • 若参数均未传入,则返回参数错误。
    名称 类型 是否必填 默认值 说明
    name String null 群组名称。
    设置为 null,表示不修改该字段。设置为 "",则返回参数错误。
    memberLimit int
  • 高级群:200
  • 超大群:2000
  • 群组人数上限。
    必须大于 0,否则返回参数错误。设置为 null,表示不修改该字段。
    intro String null 群组介绍,长度上限为 255 个字符。
    设置为 null,表示不修改该字段。
    announcement String null 群组公告,长度上限为 1024 个字符。最大可扩展至 5000 个字符(提交工单 联系网易云信技术支持工程师申请)。
    设置为 null,表示不修改该字段。
    avatar String null 群组头像。
    设置为 null,表示不修改该字段。
    serverExtension String null 群组服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    设置为 null,表示不修改该字段。
    joinMode V2NIMTeamJoinMode V2NIMTeamJoinMode.V2NIM_TEAM_JOIN_MODE_FREE 无需验证 入群验证模式。
    agreeMode V2NIMTeamAgreeMode V2NIMTeamAgreeMode.V2NIM_TEAM_AGREE_MODE_AUTH 需要被邀请人同意 被邀请人同意模式。
    inviteMode V2NIMTeamInviteMode V2NIMTeamInviteMode.V2NIM_TEAM_INVITE_MODE_MANAGER 仅群主或管理员可以邀请其他人入群 群组邀请模式,即群主/管理员或普通成员可以邀请入群。
    updateInfoMode V2NIMTeamUpdateInfoMode V2NIMTeamUpdateInfoMode.V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组资料修改模式。
    updateExtensionMode V2NIMTeamUpdateExtensionMode V2NIMTeamUpdateExtensionMode.V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组扩展字段修改模式。

    V2NIMCreateTeamResult

    创建群组返回结果。

    Android
    Javapublic interface V2NIMCreateTeamResult {
    
        V2NIMTeam getTeam();
    
        List<String> getFailedList();
    }
    
    iOS
    Objective-C@interface V2NIMCreateTeamResult : NSObject
    
    @property(nullable,nonatomic,copy,readonly) V2NIMTeam *team;
    
    @property(nullable,nonatomic,copy,readonly) NSArray<NSString *> *failedList;
    
    @end
    
    macOS/Windows
    C++struct V2NIMCreateTeamResult {
        V2NIMTeam team;
        nstd::vector<nstd::string> failedList;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMCreateTeamResult = {
      team: V2NIMTeam
      failedList: string[]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMCreateTeamResult = {
    
      team: V2NIMTeam
      failedList: string[]
    }
    

    成员参数

    名称 类型 是否只读 说明
    team V2NIMTeam 已创建的群组对象。
    failedList List<String> 被邀请入群失败的成员列表。

    V2NIMUpdateSelfMemberInfoParams

    修改本人群成员信息参数。

    Android
    Javapublic class V2NIMUpdateSelfMemberInfoParams {
    
        public V2NIMUpdateSelfMemberInfoParams() {
        }
    
        public V2NIMUpdateSelfMemberInfoParams(String teamNick, String serverExtension) {
            this.teamNick = teamNick;
            this.serverExtension = serverExtension;
        }
    
        public String getTeamNick() {
            return teamNick;
        }
    
        public void setTeamNick(String teamNick) {
            this.teamNick = teamNick;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        public void setServerExtension(String serverExtension) {
            this.serverExtension = serverExtension;
        }
    
        public boolean isValid() {
            return teamNick != null || serverExtension != null;
        }
    }
    
    iOS
    Objective-C@interface V2NIMUpdateSelfMemberInfoParams : NSObject
    
    @property(nullable,nonatomic,copy) NSString *teamNick;
    
    @property(nullable,nonatomic,copy) NSString *serverExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUpdateSelfMemberInfoParams {
        nstd::optional<nstd::string> teamNick;
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUpdateSelfMemberInfoParams = {
      teamNick?: string
      serverExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMUpdateSelfMemberInfoParams = {
    
      teamNick?: string
      serverExtension?: string
    }
    

    成员参数

    若参数均未传入,则返回参数错误。

    名称 类型 是否必填 默认值 说明
    teamNick String null 群组内昵称。
    设置为 null,表示不修改该字段。
    serverExtension String null 群成员服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    设置为 null,表示不修改该字段。

    V2NIMTeamMemberListResult

    分页获取群成员列表返回结果。

    Android
    Javapublic interface V2NIMTeamMemberListResult {
    
        String getNextToken();
    
        boolean isFinished();
    
        List<V2NIMTeamMember> getMemberList();
    }
    
    iOS
    Objective-C@interface V2NIMTeamMemberListResult : NSObject
    
    @property(nonatomic,assign,readonly) BOOL finished;
    
    @property(nullable,nonatomic,copy,readonly) NSString *nextToken;
    
    @property(nullable,nonatomic,copy,readonly) NSArray<V2NIMTeamMember *> *memberList;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamMemberListResult {
        bool finished{false};
        nstd::string nextToken;
        nstd::vector<V2NIMTeamMember> memberList;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeamMemberListResult = {
      finished: boolean
      nextToken: string
      memberList: V2NIMTeamMember[]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMTeamMemberListResult = {
    
      finished: boolean
      nextToken: string
      memberList: V2NIMTeamMember[]
    }
    

    成员参数

    名称 类型 是否只读 说明
    nextToken String 分页偏移。
    finished boolean 群成员是否全部获取:
  • true:已全部获取
  • false:未全部获取,可以继续获取。
  • memberList List<V2NIMTeamMember> 分页获取的群成员列表。

    V2NIMTeamJoinActionInfo

    入群操作信息。

    Android
    Javapublic interface V2NIMTeamJoinActionInfo {
        V2NIMTeamJoinActionType getActionType();
        String getTeamId();
        V2NIMTeamType getTeamType();
        String getOperatorAccountId();
        String getPostscript();
        long getTimestamp();
        V2NIMTeamJoinActionStatus getActionStatus();
    }
    
    iOS
    Objective-C@interface V2NIMTeamJoinActionInfo : NSObject
    
    @property(nonatomic,assign,readonly) V2NIMTeamJoinActionType actionType;
    
    @property(nonatomic,copy,readonly) NSString *teamId;
    
    @property(nonatomic,assign,readonly) V2NIMTeamType teamType;
    
    @property(nonatomic,copy,readonly) NSString *operatorAccountId;
    
    @property(nonatomic,copy,readonly) NSString *postscript;
    
    @property(nonatomic,assign,readonly) NSTimeInterval timestamp;
    
    @property(nonatomic,assign,readonly) V2NIMTeamJoinActionStatus actionStatus;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamJoinActionInfo {
        V2NIMTeamJoinActionType actionType{V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION};
        nstd::string teamId;
        V2NIMTeamType teamType{V2NIM_TEAM_TYPE_NORMAL};
        nstd::string operatorAccountId;
        nstd::optional<nstd::string> postscript;
        uint64_t timestamp{0};
        V2NIMTeamJoinActionStatus actionStatus{V2NIM_TEAM_JOIN_ACTION_STATUS_INIT};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeamJoinActionInfo = {
      actionType: V2NIMTeamJoinActionType
      teamId: string
      teamType: V2NIMTeamType
      operatorAccountId: string
      postscript?: string
      timestamp: number
      actionStatus: V2NIMTeamJoinActionStatus
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMTeamJoinActionInfo = {
    
      actionType: V2NIMTeamJoinActionType
      teamId: string
      teamType: V2NIMTeamType
      operatorAccountId: string
      postscript?: string
      timestamp: number
      actionStatus: V2NIMTeamJoinActionStatus
    }
    

    成员参数

    名称 类型 是否只读 说明
    actionType V2NIMTeamJoinActionType 入群操作类型。
    teamId String 群组 ID
    teamType V2NIMTeamType 群组类型。
    operatorAccountId String 入群操作者账号。
    postscript String 操作附言。
    timestamp long 操作时间戳。
    actionStatus V2NIMTeamJoinActionStatus 操作处理状态。

    V2NIMTeamJoinActionInfoQueryOption

    入群操作信息分页查询选项。

    Android
    Javapublic class V2NIMTeamJoinActionInfoQueryOption {
    
        public V2NIMTeamJoinActionInfoQueryOption() {
        }
    
        public List<V2NIMTeamJoinActionType> getTypes() {
            return types;
        }
    
        public void setTypes(List<V2NIMTeamJoinActionType> types) {
            this.types = types;
        }
    
        public long getOffset() {
            if (offset == null) {
                return 0;
            }
            return offset;
        }
    
        public void setOffset(Long offset) {
            this.offset = offset;
        }
    
        public int getLimit() {
            if (limit == null) {
                return 50;
            }
            return limit;
        }
    
        public void setLimit(int limit) {
            this.limit = limit;
        }
    
        public List<V2NIMTeamJoinActionStatus> getStatus() {
            return status;
        }
    
        public void setStatus(List<V2NIMTeamJoinActionStatus> status) {
            this.status = status;
        }
    
        public boolean isValid() {
            if (limit != null && limit <= 0) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMTeamJoinActionInfoQueryOption : NSObject
    
    @property(nullable,nonatomic,copy) NSArray<NSNumber *> *types;
    
    @property(nonatomic,assign) NSInteger offset;
    
    @property(nonatomic,assign) NSInteger limit;
    
    @property(nullable,nonatomic,copy) NSArray<NSNumber *> *status;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamJoinActionInfoQueryOption {
        nstd::vector<V2NIMTeamJoinActionType> types;
        uint64_t offset;
        uint32_t limit{V2NIM_DEFAULT_JOIN_ACTION_QUERY_LIMIT};
        nstd::vector<V2NIMTeamJoinActionStatus> status;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeamJoinActionInfoQueryOption = {
      types?: V2NIMTeamJoinActionType[]
      status?: V2NIMTeamJoinActionStatus[]
      offset?: number
      limit?: number
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMTeamJoinActionInfoQueryOption = {
    
      types?: V2NIMTeamJoinActionType[]
      status?: V2NIMTeamJoinActionStatus[]
      offset?: number
      limit?: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    types List<V2NIMTeamJoinActionType> - 入群操作类型列表。如果列表为空或 size 为 0 则表示查询所有入群操作类型。
    offset long - 分页查询偏移。
    首次查询传 0,下一次查询传入上一次查询返回值中的 offset
    limit int 50 单次查询最大数量。
    status List<V2NIMTeamJoinActionStatus> - 入群操作处理状态类型列表。如果列表为空或 size 为 0 则表示查询所有入群操作处理状态类型。

    V2NIMTeamJoinActionInfoResult

    入群操作信息分页查询结果。

    Android
    Javapublic interface V2NIMTeamJoinActionInfoResult {
        List<V2NIMTeamJoinActionInfo> getInfos();
        long getOffset();
        boolean isFinished();
    }
    
    iOS
    Objective-C@interface V2NIMTeamJoinActionInfoResult : NSObject
    
    @property(nullable,nonatomic,copy,readonly) NSArray<V2NIMTeamJoinActionInfo *> *infos;
    
    @property(nonatomic,assign,readonly) NSInteger offset;
    
    @property(nonatomic,assign,readonly) BOOL finished;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamJoinActionInfoResult {
        nstd::vector<V2NIMTeamJoinActionInfo> infos;
        uint64_t offset{0};
        bool finished{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeamJoinActionInfoResult = {
      infos: V2NIMTeamJoinActionInfo[]
      offset: number
      finished: boolean
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMTeamJoinActionInfoResult = {
    
      infos: V2NIMTeamJoinActionInfo[]
      offset: number
      finished: boolean
    }
    

    成员参数

    名称 类型 是否只读 说明
    infos List<V2NIMTeamJoinActionType> 入群操作信息列表。
    offset long 分页查询偏移。
    下一次查询传入上一次查询返回值中的 offset
    finished bool 数据是否全部获取:
  • true:已全部获取
  • false:未全部获取,可以继续获取。
  • V2NIMTeamMemberSearchOption

    根据关键字搜索群成员信息的配置参数。

    Android
    Javapublic class V2NIMTeamMemberSearchOption {
    
        private final String keyword;
    
        private final V2NIMTeamType teamType;
    
        private final String teamId;
    
        private final String nextToken;
    
        private final V2NIMSortOrder order;
    
        private final int limit;
    
        private V2NIMTeamMemberSearchOption() {
            this(null, null, null, TEAM_MEMBER_SEARCH_OPTION_PAGETOKEN_DEFAULT, TEAM_MEMBER_SEARCH_OPTION_ORDER_DEFAULT, TEAM_MEMBER_SEARCH_OPTION_LIMIT_DEFAULT);
        }
    
        private V2NIMTeamMemberSearchOption(String keyword, V2NIMTeamType teamType, String teamId, String nextToken, V2NIMSortOrder order, int limit) {
            this.keyword = keyword;
            this.teamType = teamType;
            this.teamId = teamId;
            this.nextToken = nextToken;
            this.order = order;
            this.limit = limit;
        }
    
        public String getKeyword() {
            return keyword;
        }
    
        public V2NIMTeamType getTeamType() {
            return teamType;
        }
    
        public String getTeamId() {
            return teamId;
        }
    
        public String getNextToken() {
            return nextToken;
        }
    
        public V2NIMSortOrder getOrder() {
            return order;
        }
    
        public int getLimit() {
            return limit;
        }
    
        @Override
        public String toString() {
            return "V2NIMTeamMemberSearchOption{" +
                    "keyword='" + keyword + '\'' +
                    ", teamType=" + teamType +
                    ", teamId='" + teamId + '\'' +
                    ", nextToken='" + nextToken + '\'' +
                    ", order=" + order +
                    ", limit=" + limit +
                    '}';
        }
    
        private static final V2NIMSortOrder TEAM_MEMBER_SEARCH_OPTION_ORDER_DEFAULT = V2NIMSortOrder.V2NIM_SORT_ORDER_DESC;
        private static final int TEAM_MEMBER_SEARCH_OPTION_LIMIT_DEFAULT = 10;
        private static final String TEAM_MEMBER_SEARCH_OPTION_PAGETOKEN_DEFAULT = "";
    
        public static final class V2NIMTeamMemberSearchOptionBuilder {
            private final String keyword;
            private final V2NIMTeamType teamType;
            private String teamId;
            private final String nextToken;
            private V2NIMSortOrder order = TEAM_MEMBER_SEARCH_OPTION_ORDER_DEFAULT;
            private int limit = TEAM_MEMBER_SEARCH_OPTION_LIMIT_DEFAULT;
    
            public V2NIMTeamMemberSearchOptionBuilder(String keyword, V2NIMTeamType teamType, String nextToken) {
                this.keyword = keyword;
                this.teamType = teamType;
                this.nextToken = nextToken;
            }
    
            public V2NIMTeamMemberSearchOptionBuilder(V2NIMTeamMemberSearchOption other) {
                this.keyword = other.keyword;
                this.teamType = other.teamType;
                this.teamId = other.teamId;
                this.nextToken = other.nextToken;
                this.order = other.order;
                this.limit = other.limit;
            }
    
            public static V2NIMTeamMemberSearchOptionBuilder builder(String keyword, V2NIMTeamType teamType, String nextToken) {
                return new V2NIMTeamMemberSearchOptionBuilder(keyword, teamType, nextToken);
            }
    
            public V2NIMTeamMemberSearchOptionBuilder withTeamId(String teamId) {
                this.teamId = teamId;
                return this;
            }
    
            public V2NIMTeamMemberSearchOptionBuilder withOrder(V2NIMSortOrder order) {
                this.order = order;
                return this;
            }
    
            public V2NIMTeamMemberSearchOptionBuilder withLimit(int limit) {
                this.limit = limit;
                return this;
            }
    
            public V2NIMTeamMemberSearchOption build() {
                return new V2NIMTeamMemberSearchOption(keyword, teamType, teamId, nextToken, order, limit);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMTeamMemberSearchOption : NSObject
    
    @property(nonatomic,strong) NSString *keyword;
    
    @property(nonatomic,assign) V2NIMTeamType teamType;
    
    @property(nullable,nonatomic,strong) NSString *teamId;
    
    @property(nonatomic,strong) NSString *nextToken;
    
    @property(nonatomic,assign) V2NIMSortOrder order;
    
    @property(nonatomic,assign) NSInteger limit;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamMemberSearchOption {
        nstd::string keyword;
        V2NIMTeamType teamType{V2NIM_TEAM_TYPE_NORMAL};
        nstd::optional<nstd::string> teamId;
        // 起始位置,首次传空, 后续传上次返回的 nextToken
        nstd::string nextToken;
        V2NIMSortOrder order{V2NIM_SORT_ORDER_DESC};
        uint32_t limit{V2NIM_DEFAULT_SEARCH_MESSAGE_LIST_LIMIT};
    };
    

    成员参数

    名称 类型 是否必填 默认值 说明
    keyword String - 搜索关键字,默认搜索群成员的昵称。
    teamType V2NIMTeamType - 群组类型。
    teamId String null 群组 ID,如果不传则检索所有群,如果需要检索特定的群,则需要同时传入 teamId+teamType
    nextToken String "" 搜索起始位置,首次传 "",后续传上一次返回的 nextToken
    order V2NIMSortOrder 0 V2NIM_SORT_ORDER_DESC:按 joinTime 降序。V2NIM_SORT_ORDER_ASC:按 joinTime 升序
    limit Integer 10 单次查询返回的成员数量,须为正数。

    V2NIMTeamMemberSearchResult

    根据关键字搜索群成员信息的搜索结果。

    Android
    Javapublic interface V2NIMTeamMemberSearchResult {
    
        List<V2NIMTeamMember> getMemberList();
    
        String getNextToken();
    
        boolean isFinished();
    }
    
    iOS
    Objective-C@interface V2NIMTeamMemberSearchResult : NSObject
    
    @property(nullable,nonatomic,strong,readonly) NSArray<V2NIMTeamMember *> *memberList;
    
    @property(nonatomic,strong,readonly) NSString *nextToken;
    
    @property(nonatomic,assign,readonly) BOOL finished;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamMemberListResult {
        bool finished{false};
        nstd::string nextToken;
        nstd::vector<V2NIMTeamMember> memberList;
    };
    

    成员参数

    名称 类型 是否必填 默认值 说明
    memberList List<V2NIMTeamMember> - 搜索的群成员列表。
    nextToken String - 分页标识,下次搜索的偏移量。当 finished = true 时,nextToken 设为 ""
    finished Bool - 搜索是否结束。

    V2NIMTeamListener

    群组相关监听器。

    调用 addTeamListener 注册群组监听后,当群组相关事件发生时,会返回对应回调。

    Android
    Javapublic interface V2NIMTeamListener {
        void onSyncStarted();
        void onSyncFinished();
        void onSyncFailed(V2NIMError error);
        void onTeamCreated(V2NIMTeam team);
        void onTeamDismissed(V2NIMTeam team);
        void onTeamJoined(V2NIMTeam team);
        void onTeamLeft(V2NIMTeam team, boolean isKicked);
        void onTeamInfoUpdated(V2NIMTeam team);
    
        void onTeamMemberJoined(List<V2NIMTeamMember> teamMembers);
    
        void onTeamMemberKicked(String operatorAccountId, List<V2NIMTeamMember> teamMembers);
    
        void onTeamMemberLeft(List<V2NIMTeamMember> teamMembers);
    
        void onTeamMemberInfoUpdated(List<V2NIMTeamMember> teamMembers);
    
        void onReceiveTeamJoinActionInfo(V2NIMTeamJoinActionInfo joinActionInfo);
    }
    
    iOS
    Objective-C@protocol V2NIMTeamListener <NSObject>
    
    @optional
    
    - (void)onSyncStarted;
    
    - (void)onSyncFinished;
    
    - (void)onSyncFailed:(V2NIMError *)error;
    
    - (void)onTeamCreated:(V2NIMTeam *)team;
    
    - (void)onTeamDismissed:(V2NIMTeam *)team;
    
    - (void)onTeamJoined:(V2NIMTeam *)team;
    
    - (void)onTeamLeft:(V2NIMTeam *)team
              isKicked:(BOOL)isKicked;
    
    - (void)onTeamInfoUpdated:(V2NIMTeam *)team;
    
    - (void)onTeamMemberJoined:(NSArray<V2NIMTeamMember *> *)teamMembers;
    
    - (void)onTeamMemberKicked:(NSString *)operatorAccountId
                   teamMembers:(NSArray<V2NIMTeamMember *> *)teamMembers;
    
    - (void)onTeamMemberLeft:(NSArray<V2NIMTeamMember *> *)teamMembers;
    
    - (void)onTeamMemberInfoUpdated:(NSArray<V2NIMTeamMember *> *)teamMembers;
    
    - (void)onReceiveTeamJoinActionInfo:(V2NIMTeamJoinActionInfo *)joinActionInfo;
    
    @end
    
    macOS/Windows
    C++struct V2NIMTeamListener {
        nstd::function<void()> onSyncStarted;
        nstd::function<void()> onSyncFinished;
        nstd::function<void(V2NIMError error)> onSyncFailed;
        nstd::function<void(V2NIMTeam team)> onTeamCreated;
        nstd::function<void(nstd::vector<V2NIMTeam> teams)> onTeamDismissed;
        nstd::function<void(V2NIMTeam team)> onTeamJoined;
        nstd::function<void(V2NIMTeam team, bool isKicked)> onTeamLeft;
        nstd::function<void(V2NIMTeam team)> onTeamInfoUpdated;
        nstd::function<void(nstd::vector<V2NIMTeamMember> teamMembers)> onTeamMemberJoined;
        nstd::function<void(nstd::string operateAccountId, nstd::vector<V2NIMTeamMember> teamMembers)> onTeamMemberKicked;
        nstd::function<void(nstd::vector<V2NIMTeamMember> teamMembers)> onTeamMemberLeft;
        nstd::function<void(nstd::vector<V2NIMTeamMember> teamMembers)> onTeamMemberInfoUpdated;
        nstd::function<void(V2NIMTeamJoinActionInfo joinActionInfo)> onReceiveTeamJoinActionInfo;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMTeamListener = {
      onSyncStarted: []
      onSyncFinished: []
      onSyncFailed: [error: V2NIMError]
      onTeamCreated: [team: V2NIMTeam]
      onTeamDismissed: [team: V2NIMTeam]
      onTeamJoined: [team: V2NIMTeam]
      onTeamLeft: [team: V2NIMTeam, isKicked: boolean]
      onTeamInfoUpdated: [team: V2NIMTeam]
      onTeamMemberJoined: [teamMembers: V2NIMTeamMember[]]
      onTeamMemberKicked: [operateAccountId: string, teamMembers: V2NIMTeamMember[]]
      onTeamMemberLeft: [teamMembers: V2NIMTeamMember[]]
      onTeamMemberInfoUpdated: [teamMembers: V2NIMTeamMember[]]
      onReceiveTeamJoinActionInfo: [joinActionInfo: V2NIMTeamJoinActionInfo]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMTeamListener = {
    
      onSyncStarted: []
      onSyncFinished: []
      onSyncFailed: [error: V2NIMError]
      onTeamCreated: [team: V2NIMTeam]
      onTeamDismissed: [team: V2NIMTeam]
      onTeamJoined: [team: V2NIMTeam]
      onTeamLeft: [team: V2NIMTeam, isKicked: boolean]
      onTeamInfoUpdated: [team: V2NIMTeam]
      onTeamMemberJoined: [teamMembers: V2NIMTeamMember[]]
      onTeamMemberKicked: [operateAccountId: string, teamMembers: V2NIMTeamMember[]]
      onTeamMemberLeft: [teamMembers: V2NIMTeamMember[]]
      onTeamMemberInfoUpdated: [teamMembers: V2NIMTeamMember[]]
      onReceiveTeamJoinActionInfo: [joinActionInfo: V2NIMTeamJoinActionInfo]
    }
    

    成员函数

    • onSyncStarted

      群组数据同步开始回调。

    • onSyncFinished

      群组数据同步结束回调。

      请在收到该回调之后进行群组相关操作,否则可能导致数据不完整。

    • onSyncFailed

      群组数据同步失败回调。

      如果在收到该回调之后进行群组相关操作,群组数据可能不完整。相关错误恢复后,会逐步按需重建数据。

      参数名称 类型 说明
      error V2NIMError 群组数据同步失败错误码及错误信息
    • onTeamCreated

      群组成功创建回调。
      当本地端或多端同步创建群组成功时会触发该回调。

      参数名称 类型 说明
      team V2NIMTeam 创建的群组对象
    • onTeamDismissed

      群组解散回调。
      当本地端或多端同步解散群组成功时会触发该回调。群组内所有成员均会收到该回调。

      参数名称 类型 说明
      team V2NIMTeam 解散的群组对象
    • onTeamJoined

      加入群组回调。
      当本地端或多端同步加入群组时会触发该回调。

      参数名称 类型 说明
      team V2NIMTeam 加入的群组对象
    • onTeamLeft

      离开群组回调。
      当本地端或多端主动离开群组或被踢出群组时会触发该回调。

      参数名称 类型 说明
      team V2NIMTeam 离开的群组对象
    • onTeamInfoUpdated

      群组信息更新回调。群组内所有成员均会收到该回调。

      参数名称 类型 说明
      team V2NIMTeam 更新后的群组对象
    • onTeamMemberJoined

      成员加入群组回调。群组内所有成员均会收到该回调。

      参数名称 类型 说明
      teamMembers List<V2NIMTeamMember> 加入群的群组成员列表
    • onTeamMemberKicked

      群成员被踢出群组回调。群组内所有成员均会收到该回调。

      参数名称 类型 说明
      operatorAccountId String 操作者账号
      teamMembers List<V2NIMTeamMember> 被踢出的群组成员列表
    • onTeamMemberLeft

      群成员离开群组回调。群组内所有成员均会收到该回调。

      参数名称 类型 说明
      teamMembers List<V2NIMTeamMember> 离开群组的成员列表
    • onTeamMemberInfoUpdated

      群成员信息变更回调。群组内所有成员均会收到该回调。

      参数名称 类型 说明
      teamMembers List<V2NIMTeamMember> 变更后的群成员列表
    • onReceiveTeamJoinActionInfo

      收到入群操作信息回调。包含以下场景:

      • 群主或管理员收到入群申请回调,回调类型:V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION 管理员后续操作: - acceptJoinApplication:接受成员的入群申请,成员入群 - rejectJoinApplication:拒绝成员的入群申请,申请方收到对应回调
      • 申请人收到入群申请被群主或管理员拒绝回调,回调类型:V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION
      • 收到入群邀请回调,回调类型:V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION 成员后续操作: - acceptInvitation:接受邀请入群,调用后进入群组 - rejectInvitation:拒绝接受邀请,管理员收到对应回调
      • 收到入群邀请被拒绝回调,回调类型:V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION
      参数名称 类型 说明
      joinActionInfo V2NIMTeamJoinActionInfo 入群操作信息

    V2NIMDndConfig

    推送全局免打扰配置信息。

    Android
    Javapublic class V2NIMDndConfig {
    
        private final boolean showDetail;
        private final boolean dndOn;
        private final int fromH;
        private final int fromM;
        private final int toH;
        private final int toM;
    
        private V2NIMDndConfig() {
            this(false, false, 0, 0, 0, 0);
        }
    
        private V2NIMDndConfig(boolean showDetail, boolean dndOn, int fromH, int fromM, int toH, int toM) {
            this.showDetail = showDetail;
            this.dndOn = dndOn;
            this.fromH = fromH;
            this.fromM = fromM;
            this.toH = toH;
            this.toM = toM;
        }
    
        public boolean isShowDetail() {
            return showDetail;
        }
    
        public boolean isDndOn() {
            return dndOn;
        }
    
        public int getFromH() {
            return fromH;
        }
    
        public int getFromM() {
            return fromM;
        }
    
        public int getToH() {
            return toH;
        }
    
        public int getToM() {
            return toM;
        }
    
        @Override
        public String toString() {
            return "V2NIMDndConfig{" +
                    "showDetail=" + showDetail +
                    ", dndOn=" + dndOn +
                    ", fromH=" + fromH +
                    ", fromM=" + fromM +
                    ", toH=" + toH +
                    ", toM=" + toM +
                    '}';
        }
    
        public static final class V2NIMDndConfigBuilder {
            private boolean showDetail;
            private boolean dndOn;
            private final int fromH;
            private final int fromM;
            private final int toH;
            private final int toM;
    
            private V2NIMDndConfigBuilder(int fromH, int fromM, int toH, int toM) {
                this.fromH = fromH;
                this.fromM = fromM;
                this.toH = toH;
                this.toM = toM;
            }
    
            public static V2NIMDndConfigBuilder builder(int fromH, int fromM, int toH, int toM) {
                return new V2NIMDndConfigBuilder(fromH, fromM, toH, toM);
            }
    
            public V2NIMDndConfigBuilder withShowDetail(boolean showDetail) {
                this.showDetail = showDetail;
                return this;
            }
    
            public V2NIMDndConfigBuilder withDndOn(boolean dndOn) {
                this.dndOn = dndOn;
                return this;
            }
    
            public V2NIMDndConfig build() {
                return new V2NIMDndConfig(showDetail, dndOn, fromH, fromM, toH, toM);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMDndConfig : NSObject
    @property (nonatomic,assign) BOOL showDetail;
    @property (nonatomic,assign) BOOL dndOn;
    @property (nonatomic,assign) NSInteger fromH;
    @property (nonatomic,assign) NSInteger fromM;
    @property (nonatomic,assign) NSInteger toH;
    @property (nonatomic,assign) NSInteger toM;
    @end
    
    HarmonyOS
    TypeScriptexport interface V2NIMDndConfig {
    
      showDetail: boolean
      dndOn: boolean
      fromH: number
      fromM: number
      toH: number
      toM: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    showDetail boolean false 是否显示推送详情。
    dndOn boolean false APNs 推送全局免打扰是否开启。
    fromH int 如果 dndOntrue(开启免打扰)则必填 - 免打扰开始时间(小时数)
    fromM int 如果 dndOntrue(开启免打扰)则必填 - 免打扰开始时间(分钟数)
    toH int 如果 dndOntrue(开启免打扰)则必填 - 免打扰结束时间(小时数)
    toM int 如果 dndOntrue(开启免打扰)则必填 - 免打扰结束时间(分钟数)

    V2NIMOfflinePushConfig(仅 Web)

    离线推送配置信息。

    TypeScriptexport interface V2NIMOfflinePushConfig {
      apns?: V2NIMManufacturerPushConfig
      hwPush?: V2NIMManufacturerPushConfig
      miPush?: V2NIMManufacturerPushConfig
      vivoPush?: V2NIMManufacturerPushConfig
      oppoPush?: V2NIMManufacturerPushConfig
      honorPush?: V2NIMManufacturerPushConfig
      fcmPush?: V2NIMManufacturerPushConfig
      mzPush?: V2NIMManufacturerPushConfig
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    miPush V2NIMManufacturerPushConfig - 小米推送:appIdappKeycertificateName
    vivoPush V2NIMManufacturerPushConfig - vivo 推送:appIdappKeycertificateName
    oppoPush V2NIMManufacturerPushConfig - OPPO 推送:appIdappKeycertificateNamesecret
    hwPush V2NIMManufacturerPushConfig - 华为推送:appIdappKey
    fcmPush V2NIMManufacturerPushConfig - FCM 推送:certificateName
    honorPush V2NIMManufacturerPushConfig - 荣耀推送:
  • appId:在 AndroidManifest.xml 中配置。
  • certificateName
  • mzPush V2NIMManufacturerPushConfig - 魅族推送:appIdappKeycertificateName
    apns V2NIMManufacturerPushConfig - APNs 推送:certificateName

    V2NIMManufacturerPushConfig(仅 Web)

    离线推送第三方厂商配置信息。

    TypeScriptexport interface V2NIMManufacturerPushConfig {
      appId?: string
      appKey?: string
      certificateName: string
      secret?: string
    }
    

    成员参数

    以下参数需要在 网易云信控制台 应用管理 > 应用配置 > 证书管理 添加证书时配置完成,具体含义请参考 各厂商集成文档

    名称 类型 说明
    appId string 应用 ID
    appKey string 应用 Key
    certificateName string 应用证书名称。
    secret string 应用密钥。

    V2NIMSettingListener

    系统设置相关监听器。

    调用 addSettingListener 注册系统设置监听后,当系统设置相关事件发生时,会返回对应回调。

    Android
    Javapublic interface V2NIMSettingListener {
    
        void onTeamMessageMuteModeChanged(String teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode);
    
        void onP2PMessageMuteModeChanged(String accountId, V2NIMP2PMessageMuteMode muteMode);
    }
    
    iOS
    Objective-C- (void)onTeamMessageMuteModeChanged:(NSString *)teamId
                                teamType:(V2NIMTeamType)teamType
                                muteMode:(V2NIMTeamMessageMuteMode)muteMode;
    
    - (void)onP2PMessageMuteModeChanged:(NSString *)accountId
                               muteMode:(V2NIMP2PMessageMuteMode)muteMode;
    
    macOS/Windows
    C++struct V2NIMSettingListener {
        nstd::function<void(nstd::string teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode)> onTeamMessageMuteModeChanged;
        nstd::function<void(nstd::string accountId, V2NIMP2PMessageMuteMode muteMode)> onP2PMessageMuteModeChanged;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMSettingListener = {
      onTeamMessageMuteModeChanged: [teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode]
      onP2PMessageMuteModeChanged: [accountId: string, muteMode: V2NIMP2PMessageMuteMode]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMSettingListener = {
    
      onTeamMessageMuteModeChanged: [teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode]
      onP2PMessageMuteModeChanged: [accountId: string, muteMode: V2NIMP2PMessageMuteMode]
    }
    

    成员函数

    • onTeamMessageMuteModeChanged

      群组消息免打扰模式变更回调。

      参数名称 类型 说明
      teamId String 群组 ID
      teamType V2NIMTeamType 群组类型,包括高级群和超大群。
      muteMode V2NIMTeamMessageMuteMode 群消息免打扰模式:免打扰开启或免打扰关闭
    • onP2PMessageMuteModeChanged

      单聊(点对点)消息免打扰模式变更回调。

      参数名称 类型 说明
      accountId String 聊天对象用户账号
      muteMode V2NIMP2PMessageMuteMode 单聊消息免打扰模式:免打扰开启或免打扰关闭

    V2NIMUser

    用户资料对象。

    Android
    Javapublic interface V2NIMUser {
    
        String getAccountId();
    
        String getName();
    
        String getAvatar();
    
        String getSign();
    
        String getEmail();
    
        String getBirthday();
    
        String getMobile();
    
        int getGender();
    
        String getServerExtension();
    
        long getCreateTime();
    
        long getUpdateTime();
    }
    
    iOS
    Objective-C@interface V2NIMUser : NSObject
    
    @property (nullable,nonatomic,strong) NSString *accountId;
    
    @property (nullable,nonatomic,strong) NSString *name;
    
    @property (nullable,nonatomic,strong)   NSString *avatar;
    
    @property (nullable,nonatomic,strong)   NSString *sign;
    
    @property (nullable,nonatomic,strong)   NSString *email;
    
    @property (nullable,nonatomic,strong)   NSString *birthday;
    
    @property (nullable,nonatomic,strong)   NSString *mobile;
    
    @property (nonatomic, assign)   NSInteger gender;
    
    @property (nullable,nonatomic,strong) NSString *serverExtension;
    
    @property (nonatomic, assign)   NSTimeInterval createTime;
    
    @property (nonatomic, assign)   NSTimeInterval updateTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUser {
    
        std::string accountId;
    
        std::optional<std::string> name;
    
        std::optional<std::string> avatar;
    
        std::optional<std::string> sign;
    
        std::optional<std::string> email;
    
        std::optional<std::string> birthday;
    
        std::optional<std::string> mobile;
    
        std::optional<uint32_t> gender;
    
        std::optional<std::string> serverExtension;
    
        uint64_t createTime{0};
    
        uint64_t updateTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUser = {
    
      accountId: string;
    
      name: string;
    
      avatar?: string;
    
      sign?: string;
    
      email?: string;
    
      birthday?: string;
    
      mobile?: string;
    
      gender?: number;
    
      serverExtension?: string;
    
      createTime: number;
    
      updateTime?: number;
    };
    
    HarmonyOS
    TypeScriptexport type V2NIMUser = {
    
      accountId: string
      name: string
      avatar?: string
      sign?: string
      email?: string
      birthday?: string
      mobile?: string
      gender?: number
      serverExtension?: string
      createTime: number
      updateTime?: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    accountId String - 用户账号 ID
    name String - 用户昵称,长度上限 64 字符。
    avatar String "" 用户头像的 URL 地址,例如 "https://netease/xxx.png",长度上限 1024 字符,可设置为空字符串。
    sign String "" 用户签名,长度上限 256 字符,可设置为空字符串。
    email String "" 用户邮箱地址,需符合邮箱字符规则,例如 "zhangsan@xx.com",长度上限 64 字符,可设置为空字符串。
    birthday String "" 用户生日,例如 "xxxx-xx-xx",长度上限 16 字符,可设置为空字符串。
    mobile String "" 用户手机号,长度上限 32 字符,可设置为空字符串
    非中国大陆手机号码需要填写国家代码(如美国:+1-xxxxxxxxxx)或地区代码(如香港:+852-xxxxxxxx)
    gender Integer 0 用户性别,0:未知。1:男。2:女。
    serverExtension String - 用户资料扩展字段,建议使用 JSON 格式,长度上限为 1024 字符。
    createTime long - 用户资料创建时间。
    updateTime long 0 用户资料更新时间。

    V2NIMAIUser

    数字人配置的 LLM(Large Language Models)模型类型及相关配置。

    Android
    Javapublic interface V2NIMAIUser extends V2NIMUser {
    
      /**
       * 获取大模型类型
       * @return 大模型类型
       */
      V2NIMAIModelType getModelType();
    
      /**
       * 获取大模型配置
       * @return
       */
      V2NIMAIModelConfig getModelConfig();
    }
    
    iOS
    Objective-C@interface V2NIMAIUser : V2NIMUser
    
    /// 大模型类型
    @property(nonatomic,assign) V2NIMAIModelType modelType;
    
    /// 模型相关配置信息
    @property(nullable,nonatomic) V2NIMAIModelConfig *modelConfig;
    
    @end
    
    macOS/Windows
    C++struct V2NIMAIUser : public V2NIMUser {
        /// 模型选择
        V2NIMAIModelType modelType;
        /// 模型相关配置文件
        V2NIMAIModelConfig modelConfig;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMAIUser extends V2NIMUser {
      /**
       * 大模型的类型
       */
      modelType: V2NIMAIModelType
      /**
       * 模型相关配置信息
       */
      modelConfig?: V2NIMAIModelConfig
    }
    

    成员参数

    除以下参数外,V2NIMAIUser 还继承了 V2NIMUser 的成员参数。

    名称 类型 是否必填 默认值 说明

    modelType

    V2NIMAIModelType

    数字人配置的 LLM(Large Language Models)模型类型:

    • 1:表示阿里云通义千问。
    • 2:表示微软 Azure OpenAI。
    • 3:网易云信定制私有化本地大模型。
    modelConfig V2NIMAIModelConfig - 模型相关配置信息,参考 模型可配置字段

    阿里云通义千问
    JSON{
        "apiKey": "Bearer d1**2a", //必填
        "model": "qwen-turbo", //必填
        "workspace": "ws_QTggmeAxxxxx", //可选
        "prompt": "xxx",//必填
        "max_tokens": 2000//可选
        "top_p": 0.85//可选
        "repetition_penalty": 1.1,//可选
        ///....
    }
    
    微软 Azure OpenAI
    JSON{
        "apiKey": "xxxx",//必填
        "apiVersion": "2023-06-01-preview",//必填
        "deploymentId": "gpt_35_turbo",//必填
        "resourceName": "yunxintest",//必填
        "prompt": "xxx",//必填
        "max_tokens": 16,//可选
        "temperature": 1,//可选
        "top_p": 1,//可选
        "logit_bias": {},//可选
        "user": "xx",//可选
        "presence_penalty": 0,//可选
        "frequency_penalty": 0,//可选
        "best_of": 1,//可选
        ///....
    }
    
    定制本地大模型
    JSON{
        "model": "xxxx",//必填
        "url": "xxx",//必填
        "prompt": "xxx",//必填
        "mirostat": 1,//可选
        "mirostat_eta": 1//可选
        "temperature": 0.8//可选
        "top_p": 1,//可选
        ///....
    }
    

    V2NIMAIModelConfig

    数字人配置的 LLM(Large Language Models)模型的配置。

    Android
    Java/**
     * 用于配置 V2 模型的参数类
     */
    public class V2NIMAIModelConfig implements Serializable {
    
      /**
       * 具体大模型版本模型名
       */
      private String model;
    
      /**
       * 提示词
       */
      private String       prompt;
      /**
       * 提示词对应的 key 列表
       */
      private List<String> promptKeys;
      /**
       * 模型最大 tokens 数量
       */
      private int          maxTokens = 0;
    
      /**
       * 在服务器端是 double 类型,在端测需要作为 string 取值范围(0,1),生成时,核采样方法的概率阈值。例如,取值为 0.8 时,仅保留累计概率之和大于等于 0.8 的概率分布中的 token,作为随机采样的候选集。
       * 取值范围为(0,1.0),取值越大,生成的随机性越高。取值越低,生成的随机性越低。默认值 0.5。注意,取值不要大于等于 1
       */
      private double topP = 0.5;
    
      /**
       * 在服务器端是 double 类型的,在端测需要作为 string 取值范围(0,2),用于控制随机性和多样性的程度。具体来说,temperature 值控制了生成文本时对每个候选词的概率分布进行平滑的程度。
       * 较高的 temperature 值会降低概率分布的峰值,使得更多的低概率词被选择,生成结果更加多样化。而较低的 temperature 值则会增强概率分布的峰值,使得高概率词更容易被选择,生成结果更加确定。
       */
      private double temperature = 1;
    
      /**
       * 获取具体大模型版本模型名
       *
       * @return 具体大模型版本模型名
       */
      public String getModel() {
       return model;
      }
    
      /**
       * 设置具体大模型版本模型名
       *
       * @param model 具体大模型版本模型名
       */
      public void setModel(String model) {
       this.model = model;
      }
    
      /**
       * 获取提示词
       *
       * @return 提示词
       */
      public String getPrompt() {
       return prompt;
      }
    
      /**
       * 设置提示词
       *
       * @param prompt 提示词
       */
      public void setPrompt(String prompt) {
       this.prompt = prompt;
      }
    
      /**
       * 获取提示词对应的 key 列表
       *
       * @return 提示词对应的 key 列表
       */
      public List<String> getPromptKeys() {
       return promptKeys;
      }
    
      /**
       * 设置提示词对应的 key 列表
       *
       * @param promptKeys 提示词对应的 key 列表
       */
      public void setPromptKeys(List<String> promptKeys) {
       this.promptKeys = promptKeys;
      }
    
      /**
       * 获取模型最大 tokens 数量
       *
       * @return 模型最大 tokens 数量
       */
      public int getMaxTokens() {
       return maxTokens;
      }
    
      /**
       * 设置模型最大 tokens 数量
       *
       * @param maxTokens 模型最大 tokens 数量
       */
      public void setMaxTokens(int maxTokens) {
       this.maxTokens = maxTokens;
      }
    
      /**
       * 获取 topP
       *
       * @return topP
       */
      public double getTopP() {
       return topP;
      }
    
      /**
       * 设置 topP
       *
       * @param topP topP
       */
      public void setTopP(double topP) {
       this.topP = topP;
      }
    
      /**
       * 获取 temperature
       *
       * @return temperature
       */
      public double getTemperature() {
       return temperature;
      }
    
      /**
       * 设置 temperature
       *
       * @param temperature temperature
       */
      public void setTemperature(double temperature) {
       this.temperature = temperature;
      }
    }
    
    iOS
    Objective-C@interface V2NIMAIModelConfig : NSObject
    
    /// 具体大模型版本模型名
    @property(nonatomic,copy) NSString *model;
    
    /// 提示词
    @property(nonatomic,copy) NSString *prompt;
    
    /// 模型最大 tokens 数量
    @property(nonatomic,assign) NSInteger maxTokens;
    
    /**
     * 取值范围(0,1),生成时,核采样方法的概率阈值。
     * 例如,取值为 0.8 时,仅保留累计概率之和大于等于 0.8 的概率分布中的 token,作为随机采样的候选集。取值范围为(0,1.0),取值越大,生成的随机性越高。取值越低,生成的随机性越低。
     * 默认值 0.5。注意,取值不要大于等于 1
     */
    
    @property(nonatomic,assign) CGFloat topP;
    
    /**
     * 取值范围(0,2),用于控制随机性和多样性的程度。
     * 具体来说,temperature 值控制了生成文本时对每个候选词的概率分布进行平滑的程度。较高的 temperature 值会降低概率分布的峰值,使得更多的低概率词被选择,生成结果更加多样化。而较低的 temperature 值则会增强概率分布的峰值,使得高概率词更容易被选择,生成结果更加确定。
     */
    @property(nonatomic,assign) CGFloat temperature;
    
    @end
    
    macOS/Windows
    C++struct V2NIMAIModelConfig {
        /// 具体大模型版本模型名
        nstd::string model;
        /// 提示词
        nstd::string prompt;
        /// 提示词对应的变量
        nstd::optional<nstd::vector<nstd::string>> promptKeys;
        /// 模型最大 tokens 数量
        nstd::optional<uint32_t> maxTokens;
        /// 取值范围(0, 1), 生成时,核采样方法的概率阈值。
        nstd::optional<nstd::string> topP;
        /// 取值范围(0, 2), 用于控制随机性和多样性的程度。
        nstd::optional<nstd::string> temperature;
    };
    
    Web/uni-app/小程序
    TypeScripttype V2NIMAIModelConfig = {
      /**
       * 具体大模型版本模型名称
       */
      model: string
      /**
       * 提示词
       */
      prompt: string
      /**
       * 提示词相关的变量
       */
      promptKeys?: string[]
      /**
       * 模型最大 tokens 数量
       */
      maxTokens?: number
      /**
       * 核采样方法的概率阈值
       */
      topP?: string
      /**
       * 随机性和多样性的程度值
       */
      temperature?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    model String - LLM 模型供应商提供的具体大模型版本模型名。
    prompt String - 提示词。
    promptKeys Array<String> - 提示词对应的变量,格式如: ["country", "suchAsChina"]。
    maxTokens Int 0 模型最大 token 数量。

    topP

    double

    0.5

    一种称为核(Nucleus)抽样的策略,用来限制考虑用于生成的最高概率 token 的集合。

    • 设置一个较低的 top_p 值(例如 0.1),意味着只有概率最高的那些 token(这些 token 的累积概率达到或超过 0.1)会被考虑用于生成,这有助于排除那些非常低概率但可能引入噪声或不连贯性的 token。
    • 相反,如果 top_p 设得较高(如 0.75),则模型会在更广泛的概率分布中选择 token,这增加了多样性和创造性,但同时也可能降低生成文本的整体质量和连贯性。

    temperature

    double

    1

    用于调整模型输出的随机性,取值范围为 [0,2)。

    • 当 Temperature 较低(接近 0,不建议取值为 0)时,模型倾向于生成概率最高的 token,输出较为确定,重复性较高,接近训练数据中的常见模式。
    • 当 Temperature 较高时,模型会更加随机地选择 token,即使那些概率相对较低的 token 也可能被选中,导致生成的文本更加多样、新颖,但也可能更偏离常规或事实。

    V2NIMProxyAIModelCallParams

    数字人发起 LLM(Large Language Models)模型请求的配置参数。

    Android
    Javaimport android.text.TextUtils;
    import com.netease.nimlib.sdk.v2.ai.config.V2NIMProxyAICallAntispamConfig;
    import java.util.List;
    
    /**
    *AI 数字人代理请求参数
     */
    public class V2NIMProxyAIModelCallParams {
    
      /**
       * 机器人账号 ID,AIUser 对应的账号 ID
       */
      private final String accountId;
    
      /**
       * 请求 ID
       */
      private final String requestId;
    
      /**
       * 请求大模型的内容
       */
      private final V2NIMAIModelCallContent content;
    
      /**
       * 上下文内容
       */
      private List<V2NIMAIModelCallMessage> messages;
    
      /**
       * 提示词变量占位符替换,JSON 格式的字符串用于填充 prompt 中的变量
       */
      private String promptVariables;
    
      /**
       * 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置
       */
      private V2NIMAIModelConfigParams modelConfigParams;
    
      /**
       * 反垃圾配置, 复用消息体里的部分反垃圾字段
       */
      private V2NIMProxyAICallAntispamConfig antispamConfig;
    
      private V2NIMProxyAIModelCallParams() {
       this(null, null, null);
      }
    
      /**
       * 构造函数
       *
       * @param accountId 机器人账号 ID
       * @param requestId 请求 ID
       * @param content 请求大模型的内容
       */
      public V2NIMProxyAIModelCallParams(String accountId, String requestId, V2NIMAIModelCallContent content) {
       this.accountId = accountId;
       this.requestId = requestId;
       this.content = content;
    
      }
    
      /**
       * 获取机器人账号 ID
       *
       * @return 机器人账号 ID
       */
      public String getAccountId() {
       return accountId;
      }
    
      /**
       * 获取请求 ID
       *
       * @return 请求 ID
       */
      public String getRequestId() {
       return requestId;
      }
    
      /**
       * 获取请求大模型的内容
       *
       * @return 请求大模型的内容
       */
      public V2NIMAIModelCallContent getContent() {
       return content;
      }
    
      /**
       * 获取上下文内容
       *
       * @return 上下文内容
       */
      public List<V2NIMAIModelCallMessage> getMessages() {
       return messages;
      }
    
      /**
       * 设置上下文内容
       *
       * @param messages 上下文内容
       */
      public void setMessages(List<V2NIMAIModelCallMessage> messages) {
       this.messages = messages;
      }
    
      /**
       * 获取提示词变量占位符替换
       *
       * @return 提示词变量占位符替换
       */
      public String getPromptVariables() {
       return promptVariables;
      }
    
      /**
       * 设置提示词变量占位符替换
       *
       * @param promptVariables 提示词变量占位符替换
       */
      public void setPromptVariables(String promptVariables) {
       this.promptVariables = promptVariables;
      }
    
      /**
       * 获取请求接口模型相关参数配置
       *
       * @return 请求接口模型相关参数配置
       */
      public V2NIMAIModelConfigParams getModelConfigParams() {
       return modelConfigParams;
      }
    
      /**
       * 设置请求接口模型相关参数配置
       *
       * @param modelConfigParams 请求接口模型相关参数配置
       */
      public void setModelConfigParams(V2NIMAIModelConfigParams modelConfigParams) {
       this.modelConfigParams = modelConfigParams;
      }
    
      /**
       * 获取反垃圾配置
       *
       * @return 反垃圾配置
       */
      public V2NIMProxyAICallAntispamConfig getAntispamConfig() {
       return antispamConfig;
      }
    
      /**
       * 设置反垃圾配置
       *
       * @param antispamConfig 反垃圾配置
       */
      public void setAntispamConfig(V2NIMProxyAICallAntispamConfig antispamConfig) {
       this.antispamConfig = antispamConfig;
      }
    
      /**
       * 是否有效
       * @return 是否有效
       */
      public boolean isValid(){
       if(TextUtils.isEmpty(accountId)){
        return false;
       }
    
       if(TextUtils.isEmpty(requestId)){
        return false;
       }
    
       if(content == null || !content.isValid()){
        return false;
       }
    
       return true;
      }
    
      /**
       * 构造器
       */
      public static class Builder {
       private String accountId;
       private String requestId;
       private V2NIMAIModelCallContent content;
       private List<V2NIMAIModelCallMessage> messages;
       private String promptVariables;
       private V2NIMAIModelConfigParams modelConfigParams;
       private V2NIMProxyAICallAntispamConfig antispamConfig;
    
       /**
        * 设置机器人账号 ID
        * @param accountId 机器人账号 ID
        * @return Builder
        */
       public Builder accountId(String accountId) {
        this.accountId = accountId;
        return this;
       }
    
       /**
        * 设置请求 ID
        * @param requestId 请求 ID
        * @return Builder
        */
       public Builder requestId(String requestId) {
        this.requestId = requestId;
        return this;
       }
    
       /**
        * 设置请求大模型的内容
        * @param content 请求大模型的内容
        * @return Builder
        */
       public Builder content(V2NIMAIModelCallContent content) {
        this.content = content;
        return this;
       }
    
       /**
        * 设置上下文内容
        * @param messages 上下文内容
        * @return Builder
        */
       public Builder messages(List<V2NIMAIModelCallMessage> messages) {
        this.messages = messages;
        return this;
       }
    
       /**
        * 设置提示词变量占位符替换
        * @param promptVariables 提示词变量占位符替换
        * @return Builder
        */
       public Builder promptVariables(String promptVariables) {
        this.promptVariables = promptVariables;
        return this;
       }
    
       /**
        * 设置请求接口模型相关参数配置
        * @param modelConfigParams 请求接口模型相关参数配置
        * @return Builder
        */
       public Builder modelConfigParams(V2NIMAIModelConfigParams modelConfigParams) {
        this.modelConfigParams = modelConfigParams;
        return this;
       }
    
       public Builder antispamConfig(V2NIMProxyAICallAntispamConfig antispamConfig) {
        this.antispamConfig = antispamConfig;
        return this;
       }
    
       /**
        * 构建 V2NIMProxyAIModelCallParams
        * @return V2NIMProxyAIModelCallParams
        */
       public V2NIMProxyAIModelCallParams build() {
        V2NIMProxyAIModelCallParams params = new V2NIMProxyAIModelCallParams(accountId, requestId, content);
        params.messages = messages;
        params.promptVariables = promptVariables;
        params.modelConfigParams = modelConfigParams;
        params.antispamConfig = antispamConfig;
        return params;
       }
      }
    }
    
    iOS
    Objective-C@interface V2NIMProxyAIModelCallParams : NSObject
    
    /// 机器人账号 ID
    @property(nonatomic,copy) NSString *accountId;
    
    /// 请求 ID
    @property(nonatomic,copy) NSString *requestId;
    
    /// 请求大模型的内容
    @property(nonatomic,strong) V2NIMAIModelCallContent *content;
    
    /// 上下文内容
    @property(nullable,nonatomic,strong) NSArray<V2NIMAIModelCallMessage *> *messages;
    
    /// 提示词变量占位符替换
    /// JSON 格式的字符串
    /// 用于填充 prompt 中的变量
    @property(nullable,nonatomic,copy) NSString *promptVariables;
    
    /// 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置
    @property(nullable,nonatomic,strong) V2NIMAIModelConfigParams *modelConfigParams;
    
    /// AI 透传接口的反垃圾配置
    @property(nullable,nonatomic,strong) V2NIMProxyAICallAntispamConfig *antispamConfig;
    @end
    
    macOS/Windows
    C++/// AI 数字人代理请求参数
    struct V2NIMProxyAIModelCallParams {
        /// 机器人账号 ID
        nstd::string accountId;
        /// 请求 ID
        nstd::string requestId;
        /// 请求大模型的内容
        V2NIMAIModelCallContent content;
        /// 上下文内容
        nstd::optional<nstd::vector<V2NIMAIModelCallMessage>> messages;
        /// 提示词变量占位符替换, 如果 V2NIMAIUser 中的 modelConfig.prompt 定义了变量,则必填. 端测不校验
        nstd::optional<nstd::string> promptVariables;
        /// 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置
        nstd::optional<V2NIMAIModelConfigParams> modelConfigParams;
        /// 反垃圾配置, 复用消息体里的部分反垃圾字段
        nstd::optional<V2NIMProxyAICallAntispamConfig> antispamConfig;
    };
    
    Web/uni-app/小程序
    TypeScripttype V2NIMProxyAIModelCallParams = {
      /**
       * 机器人账号 ID
       */
      accountId: string
      /**
       * 请求 ID
       *
       * 注: 需要用请求 ID 将整个串联应答流程, 建议采用 uuid 算法避免重复
       */
      requestId: string
      /**
       * 请求大模型的内容
       */
      content: V2NIMAIModelCallContent
      /**
       * 请求调用上下文内容
       */
      messages?: V2NIMAIModelCallMessage[]
      /**
       * 提示词变量占位符替换. JSON 序列化的字符串, 用于填充 prompt 中的变量
       *
       * 注: 如果 V2NIMAIUser 中的 modelConfig.promptKeys 存在且数组长度不为 0,则必填.
       */
      promptVariables?: string
      /**
       * 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置
       */
      modelConfigParams?: V2NIMAIModelConfigParams
      /**
       * 反垃圾配置
       */
      antispamConfig?: V2NIMProxyAICallAntispamConfig
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    accountId String - 数字人(AIUser)对应的账号 ID。
    requestId String - 请求 ID。
    content V2NIMAIModelCallContent - 数字人请求 LLM 模型的具体内容。
    messages List<V2NIMAIModelCallMessage> - 数字人请求 LLM 模型的上下文内容。

    promptVariables

    String

    提示词变量占位符替换内容,用于填充 prompt 中的变量。

    • 替换内容为一个 JSON 格式的字符串。
    • JSON 键来自于 V2NIMAIModelConfig 里的 promptKeys 属性。
    • 如果 V2NIMAIUser 中的 modelConfig.prompt 定义了变量,则服务端校验时必填。
    • 示例
      {
      "career":"teacher"
      }
    modelConfigParams V2NIMAIModelConfigParams - 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置。
    antispamConfig V2NIMProxyAICallAntispamConfig - 反垃圾配置,可复用消息体里的部分反垃圾字段。

    V2NIMProxyAICallAntispamConfig

    数字人收发消息,是否需要经过安全通校验,即透传反垃圾内容配置。

    Android
    Java/**
     * AI 透传接口的反垃圾配置
     */
    public class V2NIMProxyAICallAntispamConfig {
    
      /**
       * 指定消息是否需要经过安全通。默认为 true
       */
      private boolean antispamEnabled = true;
    
      /**
       * 指定易盾业务 ID
       */
      private String antispamBusinessId;
    
      /**
       * 获取指定消息是否需要经过安全通
       *
       * @return 指定消息是否需要经过安全通
       */
      public boolean isAntispamEnabled() {
       return antispamEnabled;
      }
    
      /**
       * 设置指定消息是否需要经过安全通
       *
       * @param antispamEnabled 指定消息是否需要经过安全通
       */
      public void setAntispamEnabled(boolean antispamEnabled) {
       this.antispamEnabled = antispamEnabled;
      }
    
      /**
       * 获取指定易盾业务 ID
       *
       * @return 指定易盾业务 ID
       */
      public String getAntispamBusinessId() {
       return antispamBusinessId;
      }
    
      /**
       * 设置指定易盾业务 ID
       *
       * @param antispamBusinessId 指定易盾业务 ID
       */
      public void setAntispamBusinessId(String antispamBusinessId) {
       this.antispamBusinessId = antispamBusinessId;
      }
    }
    
    iOS
    Objective-C@interface V2NIMProxyAICallAntispamConfig : NSObject
    /// 指定消息是否需要经过安全通。默认为 true
    /// 对于已开通安全通的用户有效,默认消息都会走安全通,如果对单条消息设置 enable 为 false,则此消息不会走安全通
    @property(nonatomic,assign) BOOL antispamEnabled;
    
    /// 指定易盾业务 ID
    @property(nullable,nonatomic,copy) NSString *antispamBusinessId;
    @end
    
    macOS/Windows
    C++struct V2NIMProxyAICallAntispamConfig {
        /// 指定消息是否需要经过安全通。默认为 true
        nstd::optional<bool> antispamEnabled{true};
        /// 指定易盾业务 ID
        nstd::optional<nstd::string> antispamBusinessId;
    };
    
    Web/uni-app/小程序
    TypeScripttype V2NIMProxyAICallAntispamConfig = {
      /**
       * 指定消息是否需要经过安全通。默认为 true
       *
       * 对于已开通安全通的用户有效,默认消息都会走安全通,如果对单条消息设置 enable 为 false,则此消息不会走安全通
       */
      antispamEnabled?: boolean
      /**
       * 指定易盾业务 ID
       */
      antispamBusinessId?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明

    antispamEnabled

    Boolean

    指定消息是否需要经过安全通校验。

    • 默认为 true,对于已开通安全通的用户有效,默认消息都会经过安全通校验。
    • 如果对单条消息设置为 false,则此消息不会经过安全通校验。
    antispamBusinessId String - 指定网易易盾业务 ID。

    V2NIMAIModelCallContent

    数字人请求大模型或者大模型响应的消息内容。

    Android
    Java/**
     * 调用大模型的请求内容
     */
    public class V2NIMAIModelCallContent implements Serializable {
    
      private static final String TAG = "V2NIMAIModelCallContent";
      /**
       * 请求/响应的文本内容
       */
      private String msg;
    
      /**
       * 类型, 暂时只有 0, 代表文本,预留扩展能力
       */
      private Integer type;
    
      public V2NIMAIModelCallContent() {
       this(null, null);
      }
    
      public V2NIMAIModelCallContent(String msg, Integer type) {
       this.msg = msg;
       this.type = type;
      }
    
      /**
       * 获取请求/响应的文本内容
       *
       * @return 请求/响应的文本内容
       */
      public String getMsg() {
       return msg;
      }
    
      /**
       * 设置请求/响应的文本内容
       *
       * @param msg 请求/响应的文本内容
       */
      public void setMsg(String msg) {
       this.msg = msg;
      }
    
      /**
       * 获取类型
       *
       * @return 类型
       */
      public Integer getType() {
       return type;
      }
    
      /**
       * 设置类型
       *
       * @param type 类型
       */
      public void setType(Integer type) {
       this.type = type;
      }
    }
    
    iOS
    Objective-C@interface V2NIMAIModelCallContent : NSObject<NSCopying>
    
    /// 请求/响应的文本内容
    @property(nonatomic,copy) NSString *msg;
    
    /// 类型,暂时只有 0,代表文本,预留扩展能力
    @property(nonatomic,assign) V2NIMAIModelCallContentType type;
    
    @end
    
    macOS/Windows
    C++/// 调用大模型的请求内容
    struct V2NIMAIModelCallContent {
        /// 请求/响应的文本内容
        nstd::string msg;
    
        /// 类型, 暂时只有 0, 代表文本, 预留扩展能力
        int32_t type;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMAIModelCallContent {
      /**
       * 请求/响应的文本内容
       */
      msg: string
      /**
       * 类型, 暂时只有 0, 代表文本
       */
      type: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    msg String - 数字人请求或者响应的内容。
    type Number - 请求或者响应的内容类型。暂时只有 0,代表文本,待后续扩展为其他内容类型。

    V2NIMAIModelCallMessage

    数字人请求大模型或者大模型响应的消息的上下文内容。

    Android
    Java/**
     * 请求调用上下文内容,
     */
    public class V2NIMAIModelCallMessage implements Serializable {
        /** 上下文内容的角色 */
        private V2NIMAIModelRoleType role;
    
        /** 上下文的内容 */
        private String msg;
    
        /** 类型, 暂时只有 0, 代表文本,预留扩展能力 */
        private int type;
    
        /**
         * 获取上下文内容的角色
         * @return 上下文内容的角色
         */
        public V2NIMAIModelRoleType getRole() {
            return role;
        }
    
        /**
         * 设置上下文内容的角色
         * @param role 上下文内容的角色
         */
        public void setRole(V2NIMAIModelRoleType role) {
            this.role = role;
        }
    
        /**
         * 获取上下文的内容
         * @return 上下文的内容
         */
        public String getMsg() {
            return msg;
        }
    
        /**
         * 设置上下文的内容
         * @param msg 上下文的内容
         */
        public void setMsg(String msg) {
            this.msg = msg;
        }
    
        /**
         * 获取类型
         * @return 类型
         */
        public int getType() {
            return type;
        }
    
        /**
         * 设置类型
         * @param type 类型
         */
        public void setType(int type) {
            this.type = type;
        }
    
        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder("V2NIMAIModelCallMessage{");
            sb.append("role=").append(role);
            sb.append(", msg='").append(msg).append('\'');
            sb.append(", type=").append(type);
            sb.append('}');
            return sb.toString();
        }
    }
    
    iOS
    Objective-C/// 请求调用上下文内容
    @interface V2NIMAIModelCallMessage : NSObject
    
    /// 上下文内容的角色
    @property(nonatomic,assign) V2NIMAIModelRoleType role;
    
    /// 上下文内容的内容
    @property(nonatomic,copy) NSString *msg;
    
    /// 类型
    @property(nonatomic,assign) V2NIMAIModelCallContentType type;
    
    @end
    
    macOS/Windows
    C++struct V2NIMAIModelCallMessage {
        /// 上下文内容的角色
        V2NIMAIModelRoleType role;
        /// 上下文的内容
        nstd::string msg;
        /// 类型, 暂时只有 0, 代表文本, 预留扩展能力
        int32_t type;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMAIModelCallMessage {
      /**
       * 上下文内容的角色.
       *
       * 注: 请开发者自行判定自己发的消息选 user, 若是机器人发的消息是选 assistant
       */
      role: V2NIMAIModelRoleType
      /**
       * 请求/响应的文本内容
       */
      msg: string
      /**
       * 类型, 暂时只有 0, 代表文本
       */
      type: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    role V2NIMAIModelRoleType - 上下文内容的角色。
    msg String - 数字人请求或者响应的上下文内容。
    type Number - 请求或者响应的上下文内容类型。暂时只有 0,代表文本,待后续扩展为其他内容类型。

    V2NIMAIModelConfigParams

    数字人请求的 LLM 大模型配置覆盖设置。配置了该字段后,默认覆盖您在网易云信控制台上的相关配置。

    • 如果所有字段均为空,则以您在网易云信控制台上的配置为准,本地不做格式校验。
    • 如果设置参数超过范围,则会主动纠正到正确范围。
    Android
    Java/**
     * Ai 大模型配置参数
     */
    public class V2NIMAIModelConfigParams implements Serializable {
    
      /**
       * 提示词
       */
      private String prompt;
    
      /**
       * 模型最大 tokens 数量
       */
      private Integer maxTokens;
    
      /**
       * 取值范围(0,1),生成时,核采样方法的概率阈值。例如,取值为 0.8 时,仅保留累计概率之和大于等于 0.8 的概率分布中的 token,作为随机采样的候选集。取值范围为(0,1.0),取值越大,生成的随机性越高。取值越低,生成的随机性越低。默认值 0.5。注意,取值不要大于等于 1
       */
      private Double topP;
    
      /**
       * 取值范围(0,2),用于控制随机性和多样性的程度。具体来说,temperature 值控制了生成文本时对每个候选词的概率分布进行平滑的程度。较高的 temperature 值会降低概率分布的峰值,使得更多的低概率词被选择,生成结果更加多样化。而较低的 temperature
       * 值则会增强概率分布的峰值,使得高概率词更容易被选择,生成结果更加确定。
       */
      private Double temperature;
    
      /**
       * 获取提示词
       *
       * @return 提示词
       */
      public String getPrompt() {
       return prompt;
      }
    
      /**
       * 设置提示词
       *
       * @param prompt 提示词
       */
      public void setPrompt(String prompt) {
       this.prompt = prompt;
      }
    
      /**
       * 获取模型最大 tokens 数量
       *
       * @return 模型最大 tokens 数量
       */
      public Integer getMaxTokens() {
       return maxTokens;
      }
    
      /**
       * 设置模型最大 tokens 数量
       *
       * @param maxTokens 模型最大 tokens 数量
       */
      public void setMaxTokens(Integer maxTokens) {
       this.maxTokens = maxTokens;
      }
    
      /**
       * 获取取值范围 topP
       *
       * @return 取值范围 topP
       */
      public Double getTopP() {
       return topP;
      }
    
      /**
       * 设置取值范围 topP
       *
       * @param topP 取值范围 topP
       */
      public void setTopP(Double topP) {
       this.topP = topP;
      }
    
      /**
       * 获取温度 temperature
       *
       * @return 温度 temperature
       */
      public Double getTemperature() {
       return temperature;
      }
    
      /**
       * 设置温度 temperature
       *
       * @param temperature 温度 temperature
       */
      public void setTemperature(Double temperature) {
       this.temperature = temperature;
      }
    }
    
    iOS
    Objective-C
    @interface V2NIMAIModelConfigParams : NSObject<NSCopying>
    
    /// 提示词
    @property(nullable,nonatomic,copy) NSString *prompt;
    
    /// 模型最大 tokens 数量
    @property(nonatomic,assign) NSInteger maxTokens;
    
    /**
     * 取值范围(0,1),生成时,核采样方法的概率阈值。
     * 例如,取值为 0.8 时,仅保留累计概率之和大于等于 0.8 的概率分布中的 token,作为随机采样的候选集。取值范围为(0,1.0),取值越大,生成的随机性越高。取值越低,生成的随机性越低。
     * 默认值 0.5。注意,取值不要大于等于 1
     */
    
    @property(nonatomic,assign) CGFloat topP;
    
    /**
     * 取值范围(0,2),用于控制随机性和多样性的程度。
     * 具体来说,temperature 值控制了生成文本时对每个候选词的概率分布进行平滑的程度。较高的 temperature 值会降低概率分布的峰值,使得更多的低概率词被选择,生成结果更加多样化。而较低的 temperature 值则会增强概率分布的峰值,使得高概率词更容易被选择,生成结果更加确定。
     */
    @property(nonatomic,assign) CGFloat temperature;
    
    @end
    
    macOS/Windows
    C++struct V2NIMAIModelConfigParams {
        /// 提示词
        nstd::optional<nstd::string> prompt;
        /// 模型最大 tokens 数量
        nstd::optional<int32_t> maxTokens;
        /// 取值范围 (0, 1), 生成时, 核采样方法的概率阈值。
        nstd::optional<double> topP;
        /// 取值范围 (0, 2), 用于控制随机性和多样性的程度。
        nstd::optional<double> temperature;
    };
    
    Web/uni-app/小程序
    TypeScripttype V2NIMAIModelConfigParams = {
      /**
       * 提示词
       */
      prompt?: string
      /**
       * 模型最大 tokens 数量
       */
      maxTokens?: number
      /**
       * 核采样方法的概率阈值
       */
      topP?: string
      /**
       * 随机性和多样性的程度值
       */
      temperature?: string
    }
    

    成员参数

    以下参数取值的详细说明,可参考 V2NIMAIModelConfig

    名称 类型 是否必填 默认值 说明
    prompt String - 提示词。
    maxTokens int - 模型最大 token 数量。
    topP double - 采样 P 参数,取值范围 (0,1)。
    temperature double - 温度参数,取值范围 (0,2)。

    V2NIMMessageAIConfigParams

    消息体中数字人配置的 LLM 大模型相关配置字段。

    Android
    Java/**
     * 用于配置 V2NIM 消息 AI 的参数类
     */
    public class V2NIMMessageAIConfigParams implements Serializable {
      /** 数字人的 accountId,发送/响应 都存在 */
      private String accountId;
    
      /** 请求大模型的内容,发送入参 */
      private V2NIMAIModelCallContent content;
    
      /** 上下文内容,当前只支持文本消息,发送入参 */
      private List<V2NIMAIModelCallMessage> messages;
    
      /** 提示词变量占位符替换,JSON 格式的字符串,用于填充 prompt 中的变量。如果 V2NIMAIUser 中的 modelConfig.prompt 定义了变量,则必填. 端测不校验,发送入参 */
      private String promptVariables;
    
      /** 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置,发送入参 */
      private V2NIMAIModelConfigParams modelConfigParams;
    
      /**
       * 获取数字人的 accountId
       * @return 数字人的 accountId
       */
      public String getAccountId() {
       return accountId;
      }
    
      /**
       * 设置数字人的 accountId
       * @param accountId 数字人的 accountId
       */
      public void setAccountId(String accountId) {
       this.accountId = accountId;
      }
    
      /**
       * 获取请求大模型的内容
       * @return 请求大模型的内容
       */
      public V2NIMAIModelCallContent getContent() {
       return content;
      }
    
      /**
       * 设置请求大模型的内容
       * @param content 请求大模型的内容
       */
      public void setContent(V2NIMAIModelCallContent content) {
       this.content = content;
      }
    
      /**
       * 获取上下文内容
       * @return 上下文内容
       */
      public List<V2NIMAIModelCallMessage> getMessages() {
       return messages;
      }
    
      /**
       * 设置上下文内容
       * @param messages 上下文内容
       */
      public void setMessages(List<V2NIMAIModelCallMessage> messages) {
       this.messages = messages;
      }
    
      /**
       * 获取提示词变量占位符替换
       * @return 提示词变量占位符替换
       */
      public String getPromptVariables() {
       return promptVariables;
      }
    
      /**
       * 设置提示词变量占位符替换
       * @param promptVariables 提示词变量占位符替换
       */
      public void setPromptVariables(String promptVariables) {
       this.promptVariables = promptVariables;
      }
    
      /**
       * 获取请求接口模型相关参数配置
       * @return 请求接口模型相关参数配置
       */
      public V2NIMAIModelConfigParams getModelConfigParams() {
       return modelConfigParams;
      }
    
      /**
       * 设置请求接口模型相关参数配置
       * @param modelConfigParams 请求接口模型相关参数配置
       */
      public void setModelConfigParams(V2NIMAIModelConfigParams modelConfigParams) {
       this.modelConfigParams = modelConfigParams;
      }
    }
    
    iOS
    Objective-C@interface V2NIMMessageAIConfigParams : NSObject<NSCopying>
    /// 数字人的 accountId
    @property(nullable,nonatomic,strong,readwrite) NSString *accountId;
    
    /// 请求大模型的内容
    @property(nullable,nonatomic,strong,readwrite) V2NIMAIModelCallContent *content;
    /// 上下文内容
    /// 当前只支持文本消息
    @property(nullable,nonatomic,strong,readwrite) NSArray<V2NIMAIModelCallMessage *> *messages;
    /// 提示词变量占位符替换
    /// JSON 格式的字符串
    /// 用于填充 prompt 中的变量
    @property(nullable,nonatomic,strong,readwrite) NSString *promptVariables;
    /// 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置
    @property(nullable,nonatomic,strong,readwrite) V2NIMAIModelConfigParams *modelConfigParams;
    @end
    
    macOS/Windows
    C++struct V2NIMMessageAIConfigParams {
        /// 数字人账号信息
        nstd::string accountId;
        /// 请求大模型的内容
        nstd::optional<V2NIMAIModelCallContent> content;
        /// 上下文内容
        nstd::optional<nstd::vector<V2NIMAIModelCallMessage>> messages;
        /// 提示词变量占位符替换
        nstd::optional<nstd::string> promptVariables;
        /// 请求接口模型相关参数配置, 如果参数不为空, 则默认覆盖控制相关配置
        nstd::optional<V2NIMAIModelConfigParams> modelConfigParams;
    };
    
    Web/uni-app/小程序
    TypeScripttype V2NIMMessageAIConfigParams = {
      /**
       * AI 数字人的账号
       */
      accountId: string
      /**
       * 请求大模型的内容.
       */
      content?: V2NIMAIModelCallContent
      /**
       * 上下文内容
       *
       * 注: 当前只支持文本消息
       */
      messages?: V2NIMAIModelCallMessage[]
      /**
       * 提示词变量占位符替换. JSON 序列化的字符串
       *
       * 注: 如果 V2NIMAIUser 中的 modelConfig.promptKeys 存在且数组长度不为 0,则必填.
       */
      promptVariables?: string
      /**
       * 请求接口模型相关参数配置
       */
      modelConfigParams?: V2NIMAIModelConfigParams
    }
    

    成员参数

    以下参数取值的详细说明,可参考 V2NIMAIModelConfig

    名称 类型 是否必填 默认值 说明
    accountId String - 数字人(AIUser)对应的账号 ID。
    content V2NIMAIModelCallContent - 数字人请求 LLM 模型的具体内容。
    messages List<V2NIMAIModelCallMessage> - 数字人请求 LLM 模型的上下文内容。

    promptVariables

    String

    提示词变量占位符替换内容,用于填充 prompt 中的变量。

    • 替换内容为一个 JSON 格式的字符串。
    • JSON 键来自于 V2NIMAIModelConfig 里的 promptKeys 属性
    • 如果 V2NIMAIUser 中的 modelConfig.prompt 定义了变量,则服务端校验时必填。
    • 示例
      {
      "职业":"厨师"
      }
    modelConfigParams V2NIMAIModelConfigParams - 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置。

    V2NIMAIModelCallResult

    透传接口下数字人回复消息的的结构体。

    Android
    Java/**
     * 透传接口的 AI 回复的结构体
     */
    public interface V2NIMAIModelCallResult {
        /**
         * 获取 AI 响应的状态码
         * @return 状态码
         */
        int getCode();
    
        /**
         * 获取数字人的 accountId
         * @return accountId
         */
        String getAccountId();
    
        /**
         * 获取本次响应的标识
         * @return requestId
         */
        String getRequestId();
    
        /**
         * 获取请求 AI 的回复
         * @return AI 的回复
         */
        V2NIMAIModelCallContent getContent();
    }
    
    iOS
    Objective-C@interface V2NIMAIModelCallResult : NSObject
    
    /// 数字人的 accountId
    @property(nonatomic,copy) NSString *accountId;
    
    /// 本次响应的标识
    @property(nonatomic,copy) NSString *requestId;
    
    /// 请求 AI 的回复
    @property(nonatomic,strong) V2NIMAIModelCallContent *content;
    
    /// AI 响应的状态码
    @property(nonatomic,assign) NSInteger code;
    
    @end
    
    macOS/Windows
    C++struct V2NIMAIModelCallResult {
        /// AI 响应的状态码
        uint32_t code{V2NIM_ERROR_CODE_SUCCESS};
        /// 机器人账号 ID
        nstd::string accountId;
        /// 请求 ID
        nstd::string requestId;
        /// 请求大模型的内容
        nstd::optional<V2NIMAIModelCallContent> content;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMAIModelCallResult {
      /**
       * 本次响应的状态, 200 为成功, 其他的都是失败
       */
      code: number
      /**
       * 机器人账号 ID
       */
      accountId: string
      /**
       * 请求 ID
       */
      requestId: string
      /**
       * 响应的内容
       */
      content: V2NIMAIModelCallContent
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    code Int 200 数字人响应消息的状态码。
    accountId String - 收发消息的数字人的账号 ID(accountId)。
    requestId String - 本次响应的标识。
    content V2NIMAIModelCallContent - 请求 LLM 模型的回复消息。

    V2NIMAIListener

    AI 透传接口的响应的回调。接口 proxyAIModelCall 调用完毕后,服务端响应以通知的形式下发,客户端需要触发回调提供响应。

    Android
    Java/**
     * AI 消息的响应的回调
     */
    public interface V2NIMAIListener {
    
      /**
       * AI 消息的响应的回调
       * @param result 本次响应的结构体
       */
      void onProxyAIModelCall(V2NIMAIModelCallResult result);
    }
    
    iOS
    Objective-C/**
     * AI 透传接口的响应的回调
     * 接口调用完毕后, 接下来服务器响应以通知的形式下发, 端测需要触发回调提供.
     * @param data 响应内容
     */
    - (void)onProxyAIModelCall:(V2NIMAIModelCallResult *)data{
        // 回调
    }
    
    macOS/Windows
    C++/// @struct AI 相关服务消息监听
    struct V2NIMAIListener {
        /// AI 消息的响应的回调
        nstd::function<void(V2NIMAIModelCallResult response)> onProxyAIModelCall;
    };
    
    Web/uni-app/小程序
    TypeScriptinterface V2NIMAIListener {
      /**
       * AI 透传接口的响应的回调
       *
       * 注: 接口 proxyAIModelCall 调用完毕后, 接下来服务器响应以通知的形式下发, 端测需要触发回调提供
       *
       * @param response 本次响应的结构体
       */
      onProxyAIModelCall: [response: V2NIMAIModelCallResponse]
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    data V2NIMAIModelCallResult - 本次响应的结构体。

    V2NIMMessageAIConfig

    消息体中数字人消息收发相关配置字段。

    Android
    Java/**
     * 用于配置 V2NIM 消息 AI 的参数类
     */
    public class V2NIMMessageAIConfig implements Serializable {
      /** 数字人的 accountId,发送/响应 都存在 */
      private String accountId;
    
      /** 该 AI 消息的询问和应答标识 0 表示普通消息, 1 表示是一个艾特数字人的消息, 2 表示是数字人响应艾特的消息,响应回参 */
      private V2NIMMessageAIStatus aiStatus;
    
      /**
       * 获取数字人的 accountId
       * @return 数字人的 accountId
       */
      public String getAccountId() {
       return accountId;
      }
    
      /**
       * 设置数字人的 accountId
       * @param accountId 数字人的 accountId
       */
      public void setAccountId(String accountId) {
       this.accountId = accountId;
      }
    
      /**
       * 获取该 AI 消息的询问和应答标识
       * @return 该 AI 消息的询问和应答标识
       */
      public V2NIMMessageAIStatus getAIStatus() {
       return aiStatus;
      }
    
      /**
       * 设置该 AI 消息的询问和应答标识
       * @param aiStatus 该 AI 消息的询问和应答标识
       */
      public void setAIStatus(V2NIMMessageAIStatus aiStatus) {
       this.aiStatus = aiStatus;
      }
    }
    
    iOS
    Objective-C@interface V2NIMMessageAIConfig : NSObject<NSCopying>
    /// 数字人的 accountId
    @property(nullable,nonatomic,strong,readwrite) NSString *accountId;
    
    /// 该 AI 消息的询问和应答标识
    /// 0 表示普通消息
    /// 1 表示是一个艾特数字人的消息
    /// 2 表示是数字人响应艾特的消息
    /// 响应回参
    @property(nonatomic,assign,readwrite) V2NIMMessageAIStatus aiStatus;
    
    @end
    
    macOS/Windows
    C++struct V2NIMMessageAIConfig {
        /// 数字人账号信息
        nstd::string accountId;
        /// 缺省表示普通消息
        V2NIMMessageAIStatus aiStatus{V2NIM_MESSAGE_AI_STATUS_UNKNOW};
    };
    
    Web/uni-app/小程序
    TypeScripttype V2NIMMessageAIConfig = {
      /**
       * AI 数字人的账号
       */
      accountId: string
      /**
       * 该 AI 消息的询问和应答标识
       *
       * 0 表示普通消息<br/>
       * 1 表示是一个艾特数字人的消息<br/>
       * 2 表示是数字人响应艾特的消息
       */
      aiStatus?: V2NIMMessageAIStatus
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    accountId String - 收发消息的数字人的账号 ID(accountId)。

    aiStatus

    V2NIMMessageAIStatus

    该数字人收发的消息的询问和应答标识

    • 0 表示普通消息
    • 1 表示是一个艾特数字人的消息
    • 2 表示是数字人响应艾特的消息

    V2NIMUserUpdateParams

    用户资料更新参数。

    Android
    Javapublic class V2NIMUserUpdateParams {
    
        public String getName() {
            return name;
        }
    
        public String getAvatar() {
            return avatar;
        }
    
        public String getSign() {
            return sign;
        }
    
        public String getEmail() {
            return email;
        }
    
        public String getBirthday() {
            return birthday;
        }
    
        public String getMobile() {
            return mobile;
        }
    
        public Integer getGender() {
            return gender;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        @Override
        public String toString() {
            return "V2NIMUserUpdateParams{" +
                    "name='" + name + '\'' +
                    ", avatar='" + avatar + '\'' +
                    ", sign='" + sign + '\'' +
                    ", email='" + email + '\'' +
                    ", birthday='" + birthday + '\'' +
                    ", mobile='" + mobile + '\'' +
                    ", gender=" + gender +
                    ", serverExtension='" + serverExtension + '\'' +
                    '}';
        }
    
        public static final class V2NIMUserUpdateParamsBuilder {
            private String name;
            private String avatar;
            private String sign;
            private String email;
            private String birthday;
            private String mobile;
            private Integer gender;
            private String serverExtension;
    
            private V2NIMUserUpdateParamsBuilder() {
            }
    
            public static V2NIMUserUpdateParamsBuilder builder() {
                return new V2NIMUserUpdateParamsBuilder();
            }
    
            public V2NIMUserUpdateParamsBuilder withName(String name) {
                this.name = name;
                return this;
            }
    
            public V2NIMUserUpdateParamsBuilder withAvatar(String avatar) {
                this.avatar = avatar;
                return this;
            }
    
            public V2NIMUserUpdateParamsBuilder withSign(String sign) {
                this.sign = sign;
                return this;
            }
    
            public V2NIMUserUpdateParamsBuilder withEmail(String email) {
                this.email = email;
                return this;
            }
    
            public V2NIMUserUpdateParamsBuilder withBirthday(String birthday) {
                this.birthday = birthday;
                return this;
            }
    
            public V2NIMUserUpdateParamsBuilder withMobile(String mobile) {
                this.mobile = mobile;
                return this;
            }
    
            public V2NIMUserUpdateParamsBuilder withGender(Integer gender) {
                this.gender = gender;
                return this;
            }
    
            public V2NIMUserUpdateParamsBuilder withServerExtension(String serverExtension) {
                this.serverExtension = serverExtension;
                return this;
            }
    
            public V2NIMUserUpdateParams build() {
                return new V2NIMUserUpdateParams(name, avatar, sign, email, birthday, mobile, gender, serverExtension);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMUserUpdateParams : NSObject
    
    @property (nullable,nonatomic,strong) NSString *name;
    
    @property (nullable,nonatomic,strong) NSString *avatar;
    
    @property (nullable,nonatomic,strong) NSString *sign;
    
    @property (nullable,nonatomic,strong) NSString *email;
    
    @property (nullable,nonatomic,strong) NSString *birthday;
    
    @property (nullable,nonatomic,strong) NSString *mobile;
    
    @property (nonatomic,assign) V2NIMGender gender;
    
    @property (nullable,nonatomic,strong) NSString *serverExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUserUpdateParams {
    
        nstd::optional<nstd::string> name;
    
        nstd::optional<nstd::string> avatar;
    
        nstd::optional<nstd::string> sign;
    
        nstd::optional<nstd::string> email;
    
        nstd::optional<nstd::string> birthday;
    
        nstd::optional<nstd::string> mobile;
    
        nstd::optional<uint32_t> gender;
    
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUserUpdateParams = {
    
      name?: string;
    
      avatar?: string;
    
      sign?: string;
    
      email?: string;
    
      birthday?: string;
    
      mobile?: string;
    
      gender?: number;
    
      serverExtension?: string;
    };
    
    HarmonyOS
    TypeScriptexport type V2NIMUserUpdateParams = {
    
      name?: string
      avatar?: string
      sign?: string
      email?: string
      birthday?: string
      mobile?: string
      gender?: number
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 说明
    name String 用户昵称,长度上限 64 字符
  • 为空(null)表示不修改该字段
  • 为空字符串("")则返回参数错误。
  • avatar String 用户头像的 URL 地址,例如 "https://netease/xxx.png",长度上限 1024 字符
  • 为空(null)表示不修改该字段
  • 可设置为空字符串("")
  • sign String 用户签名,长度上限 256 字符
  • 为空(null)表示不修改该字段
  • 可设置为空字符串("")
  • email String 用户邮箱地址,需符合邮箱字符规则,例如 "zhangsan@xx.com",长度上限 64 字符
  • 为空(null)表示不修改该字段
  • 可设置为空字符串("")串。
  • birthday String 用户生日,例如 "xxxx-xx-xx",长度上限 16 字符
  • 为空(null)表示不修改该字段
  • 可设置为空字符串("")
  • mobile String 用户手机号,长度上限 32 字符
    非中国大陆手机号码需要填写国家代码(如美国:+1-xxxxxxxxxx)或地区代码(如香港:+852-xxxxxxxx)
  • 为空(null)表示不修改该字段
  • 可设置为空字符串("")
  • gender Integer 用户性别,0:未知。1:男。2:女
    设置为其它值会返回参数错误。
    serverExtension String 用户资料扩展字段,建议使用 JSON 格式,长度上限为 1024 字符
  • 为空(null)表示不修改该字段
  • 可设置为空字符串("")
  • V2NIMUserSearchOption

    根据关键字搜索用户信息的配置参数。

    Android
    Javapublic class V2NIMUserSearchOption {
    
        public String getKeyword() {
            return keyword;
        }
    
        public boolean isSearchName() {
            return searchName;
        }
    
        public boolean isSearchAccountId() {
            return searchAccountId;
        }
    
        public boolean isSearchMobile() {
            return searchMobile;
        }
    
        @Override    public String toString() {
            return "V2NIMUserSearchOption{" +
                    "keyword='" + keyword + '\'' +
                    ", searchName=" + searchName +
                    ", searchAccountId=" + searchAccountId +
                    ", searchMobile=" + searchMobile +
                    '}';
        }
    
        public static final class V2NIMUserSearchOptionBuilder {
            private final String keyword;
            private boolean searchName = SEARCH_NAME;
            private boolean searchAccountId = SEARCH_ACCOUNT_ID;
            private boolean searchMobile = SEARCH_MOBILE;
    
            private V2NIMUserSearchOptionBuilder(String keyword) {
                this.keyword = keyword;
            }
    
            public static V2NIMUserSearchOptionBuilder builder(String keyword) {
                return new V2NIMUserSearchOptionBuilder(keyword);
            }
    
            public V2NIMUserSearchOptionBuilder withSearchName(boolean searchName) {
                this.searchName = searchName;
                return this;
            }
    
            public V2NIMUserSearchOptionBuilder withSearchAccountId(boolean searchAccountId) {
                this.searchAccountId = searchAccountId;
                return this;
            }
    
            public V2NIMUserSearchOptionBuilder withSearchMobile(boolean searchMobile) {
                this.searchMobile = searchMobile;
                return this;
            }
    
            public V2NIMUserSearchOption build() {
                return new V2NIMUserSearchOption(keyword, searchName, searchAccountId, searchMobile);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMUserSearchOption : NSObject
    
    @property (nonatomic,copy) NSString *keyword;
    
    @property (nonatomic,assign) BOOL searchName;
    
    @property (nonatomic,assign) BOOL searchAccountId;
    
    @property (nonatomic,assign) BOOL searchMobile;
    
    + (instancetype)optionWithKeyword:(NSString *)keyword;
    
    @end
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUserSearchOption = {
    
      keyword: string
    
      searchName?: boolean
    
      searchAccountId?: boolean
    
      searchMobile?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    keyword String - 搜索关键字,默认搜索用户的昵称,可以指定是否同时搜索用户账号或手机号。
    searchName Boolean true 是否搜索用户的昵称。
    searchAccountId Boolean false 是否搜索用户账号。
    searchMobile Boolean false 是否搜索用户的手机号。

    V2NIMUserListener

    用户资料相关监听器。

    Android
    Javapublic interface V2NIMUserListener {
    
        void onUserProfileChanged(List<V2NIMUser> users);
    
        void onBlockListAdded(V2NIMUser user);
    
        void onBlockListRemoved(String accountId);
    }
    
    iOS
    Objective-C@protocol V2NIMUserListener <NSObject>
    
    - (void)onUserProfileChanged:(NSArray <V2NIMUser *> *)users;
    
    - (void)onBlockListAdded:(V2NIMUser*)user;
    
    - (void)onBlockListRemoved:(NSString *)accountId;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUserListener {
    
        std::function<void(std::vector<V2NIMUser> users)> onUserProfileChanged;
    
        std::function<void(V2NIMUser user)> onBlockListAdded;
    
        std::function<void(std::string accountId)> onBlockListRemoved;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUserListener = {
    
      onUserProfileChanged: [users: V2NIMUser[]]
    
      onBlockListAdded: [user: V2NIMUser]
    
      onBlockListRemoved: [accountId: string]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMUserListener = {
    
      onUserProfileChanged: [users: V2NIMUser[]]
    
      onBlockListAdded: [user: V2NIMUser]
    
      onBlockListRemoved: [accountId: string]
    }
    

    成员函数

    • onUserProfileChanged

      用户资料变更回调。

      参数名称 类型 说明
      users List<V2NIMUser> 用户资料
    • onBlockListAdded

      黑名单新增用户回调。

      当客户端本端添加用户到黑名单,或者其他端同步添加用户到黑名单时触发该回调。

      参数名称 类型 说明
      user V2NIMUser 添加进黑名单的用户资料
    • onBlockListRemoved

      黑名单移除用户回调。

      当客户端本端从黑名单移除用户,或者其他端同步从黑名单移除用户时触发该回调。

      参数名称 类型 说明
      accountId String 移出黑名单的用户账号 ID

    V2NIMFriend

    好友信息对象。

    Android
    Javapublic interface V2NIMFriend {
    
        String getAccountId();
    
        String getAlias();
    
        String getServerExtension();
    
        String getCustomerExtension();
    
        long getCreateTime();
    
        long getUpdateTime();
    
        V2NIMUser getUserProfile();
    }
    
    iOS
    Objective-C@interface V2NIMFriend : NSObject
    
    @property (nullable,nonatomic,strong) NSString *accountId;
    
    @property (nullable,nonatomic,strong) NSString *alias;
    
    @property (nullable,nonatomic,strong) NSString *serverExtension;
    
    @property (nullable,nonatomic,strong) NSString *customerExtension;
    
    @property (nonatomic,assign) NSTimeInterval createTime;
    
    @property (nonatomic,assign) NSTimeInterval updateTime;
    
    @property (nullable,nonatomic,strong,readonly) V2NIMUser *userProfile;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriend {
    
        nstd::string accountId;
    
        nstd::optional<nstd::string> alias;
    
        nstd::optional<nstd::string> serverExtension;
    
        nstd::optional<nstd::string> customerExtension;
    
        nstd::optional<uint64_t> createTime;
    
        nstd::optional<uint64_t> updateTime;
    
        V2NIMUser userProfile;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriend = {
    
      accountId: string;
    
      alias?: string;
    
      serverExtension: string;
    
      customerExtension: string;
    
      createTime?: number;
    
      updateTime?: number;
    };
    
    HarmonyOS
    TypeScriptexport type V2NIMFriend = {
    
      accountId: string
      alias?: string
      serverExtension: string
      customerExtension: string
      createTime?: number
      updateTime?: number
      source?: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 是否只读 说明
    accountId String - - 好友账号 ID
    alias String - - 好友备注,长度上限 128 字符。
    serverExtension String - - 好友信息扩展字段,建议使用 JSON 格式,长度上限为 256 字符
    客户端和服务端都可修改该字段。
    customerExtension String - - 好友信息客户端扩展字段,建议使用 JSON 格式,长度上限为 256 字符
    仅服务端可修改该字段。
    createTime long - - 好友信息创建时间。
    updateTime long 0 - 好友信息更新时间。
    userProfile V2NIMUser - - 好友的用户信息。

    V2NIMFriendAddParams

    添加好友的配置参数。

    Android
    Javapublic class V2NIMFriendAddParams {
    
        public V2NIMFriendAddMode getAddMode() {
            return addMode;
        }
    
        public String getPostscript() {
            return postscript;
        }
    
        public static final class V2NIMFriendAddParamsBuilder {
            private final V2NIMFriendAddMode addMode;
            private String postscript;
    
            private V2NIMFriendAddParamsBuilder(V2NIMFriendAddMode addMode) {
                this.addMode = addMode;
            }
    
            public static V2NIMFriendAddParamsBuilder builder(V2NIMFriendAddMode addMode) {
                return new V2NIMFriendAddParamsBuilder(addMode);
            }
    
            public V2NIMFriendAddParamsBuilder withPostscript(String postscript) {
                this.postscript = postscript;
                return this;
            }
    
            public V2NIMFriendAddParams build() {
                return new V2NIMFriendAddParams(addMode, postscript);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMFriendAddParams : NSObject
    
    @property (nonatomic, assign) V2NIMFriendAddMode addMode;
    
    @property (nullable,nonatomic,strong) NSString *postscript;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriendAddParams {
    
        V2NIMFriendAddMode addMode{V2NIM_FRIEND_MODE_TYPE_ADD};
    
        nstd::optional<nstd::string> postscript;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendAddParams = {
    
      addMode: V2NIMFriendAddMode
    
      postscript: string
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMFriendAddParams = {
    
      addMode: V2NIMFriendAddMode
      postscript: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    addMode V2NIMFriendAddMode V2NIMFriendAddMode.V2NIM_FRIEND_MODE_TYPE_ADD:直接添加为好友,无需验证 添加好友模式。
    postscript String - 添加/申请添加好友的附言。

    V2NIMFriendAddApplication

    申请添加好友相关操作信息。

    Android
    Javapublic interface V2NIMFriendAddApplication {
    
        String getApplicantAccountId();
    
        String getRecipientAccountId();
    
        String getOperatorAccountId();
    
        String getPostscript();
    
        V2NIMFriendAddApplicationStatus getStatus();
    
        long getTimestamp();
    
        boolean isRead();
    }
    
    iOS
    Objective-C@interface V2NIMFriendAddApplication : NSObject
    
    @property (nullable,nonatomic,strong,readonly) NSString *applicantAccountId;
    
    @property (nullable,nonatomic,strong,readonly) NSString *recipientAccountId;
    
    @property (nullable,nonatomic,strong,readonly) NSString *operatorAccountId;
    
    @property (nullable,nonatomic,strong,readonly) NSString *postscript;
    
    @property (nonatomic, assign, readonly) V2NIMFriendAddApplicationStatus status;
    
    @property (nonatomic,assign) NSTimeInterval timestamp;
    
    @property (nonatomic,assign) BOOL read;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriendAddApplication {
        nstd::string applicantAccountId;
        nstd::string recipientAccountId;
        nstd::string operatorAccountId;
        nstd::optional<nstd::string> postscript;
        V2NIMFriendAddApplicationStatus status{V2NIM_FRIEND_ADD_APPLICATION_STATUS_INIT};
        uint64_t timestamp{0};
        bool read{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendAddApplication = {
    
      applicantAccountId: string
    
      recipientAccountIdstring
    
      operatorAccountId: string
    
      postscript?: string
    
      status: V2NIMFriendAddApplicationStatus
    
      timestamp: number
    
      read: boolean
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMFriendAddApplication = {
    
      operatorAccountId: string
      postscript?: string
      status: V2NIMFriendAddApplicationStatus
      timestamp: number
    }
    

    成员参数

    名称 类型 是否必填 是否只读 说明
    applicantAccountId String 好友申请者账号。
    recipientAccountId String 被申请为好友的账号。
    operatorAccountId String 操作者账号 ID
    postscript String 操作时添加的附言。
    status V2NIMFriendAddApplicationStatus 操作的状态。
    timestamp long 操作的时间。
    read Boolean 是否已读。

    V2NIMFriendDeleteParams

    删除好友的配置参数。

    Android
    Javapublic class V2NIMFriendDeleteParams {
    
        public boolean isDeleteAlias() {
            return deleteAlias;
        }
    
        @Override
        public String toString() {
            return "V2NIMFriendDeleteParams{" +
                    "deleteAlias=" + deleteAlias +
                    '}';
        }
    
        public static final class V2NIMFriendDeleteParamsBuilder {
            private boolean deleteAlias;
    
            private V2NIMFriendDeleteParamsBuilder() {
            }
    
            public static V2NIMFriendDeleteParamsBuilder builder() {
                return new V2NIMFriendDeleteParamsBuilder();
            }
    
            public V2NIMFriendDeleteParamsBuilder withDeleteAlias(boolean deleteAlias) {
                this.deleteAlias = deleteAlias;
                return this;
            }
    
            public V2NIMFriendDeleteParams build() {
                return new V2NIMFriendDeleteParams(deleteAlias);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMFriendDeleteParams : NSObject
    
    @property (nonatomic, assign) BOOL deleteAlias;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriendDeleteParams {
    
        bool deleteAlias{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendDeleteParams = {
    
      deleteAlias: boolean;
    
    };
    
    HarmonyOS
    TypeScriptexport type V2NIMFriendDeleteParams = {
    
      deleteAlias: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    deleteAlias boolean false 是否删除备注,false:不删除。true:删除。

    V2NIMFriendSetParams

    设置好友信息的配置参数。

    可以设置别名和扩展字段,两字段都可选,但是不能都不传,都不传回返回参数错误。

    Android
    Javapublic class V2NIMFriendSetParams {
    
        public String getAlias() {
            return alias;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        @Override
        public String toString() {
            return "V2NIMFriendSetParams{" +
                    "alias='" + alias + '\'' +
                    ", serverExtension='" + serverExtension + '\'' +
                    '}';
        }
    
        public static final class V2NIMFriendSetParamsBuilder {
            private String alias;
            private String serverExtension;
    
            private V2NIMFriendSetParamsBuilder() {
            }
    
            public static V2NIMFriendSetParamsBuilder builder() {
                return new V2NIMFriendSetParamsBuilder();
            }
    
            public V2NIMFriendSetParamsBuilder withAlias(String alias) {
                this.alias = alias;
                return this;
            }
    
            public V2NIMFriendSetParamsBuilder withServerExtension(String serverExtension) {
                this.serverExtension = serverExtension;
                return this;
            }
    
            public V2NIMFriendSetParams build() {
                return new V2NIMFriendSetParams(alias, serverExtension);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMFriendSetParams : NSObject
    
    @property (nullable,nonatomic,strong) NSString *alias;
    
    @property (nullable,nonatomic,strong) NSString *serverExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriendSetParams {
    
        nstd::optional<nstd::string> alias;
    
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendSetParams = {
    
      alias?: string;
    
      serverExtension?: string;
    
    };
    
    HarmonyOS
    TypeScriptexport type V2NIMFriendSetParams = {
    
      alias?: string
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    alias String - 别名
  • 不传表示不设置
  • 为空字符串表示清空别名。
  • serverExtension String - 扩展字段
  • 不传表示不设置
  • 为空字符串表示清空扩展字段。
  • V2NIMFriendAddApplicationQueryOption

    申请添加好友相关操作信息的查询参数。

    Android
    Javapublic class V2NIMFriendAddApplicationQueryOption {
    
        public long getOffset() {
            return offset;
        }
    
        public int getLimit() {
            if (limit <= 0) {
                return LIMIT_DEFAULT;
            } else {
                return limit;
            }
        }
    
        public List<V2NIMFriendAddApplicationStatus> getStatus() {
            return status;
        }
    
        private static final int LIMIT_DEFAULT = 50;
    
        public static final class V2NIMFriendAddApplicationQueryOptionBuilder {
            private long offset;
            private int limit = LIMIT_DEFAULT;
            private List<V2NIMFriendAddApplicationStatus> status;
    
            private V2NIMFriendAddApplicationQueryOptionBuilder() {
            }
    
            public static V2NIMFriendAddApplicationQueryOptionBuilder builder() {
                return new V2NIMFriendAddApplicationQueryOptionBuilder();
            }
    
            public V2NIMFriendAddApplicationQueryOptionBuilder withOffset(long offset) {
                this.offset = offset;
                return this;
            }
    
            public V2NIMFriendAddApplicationQueryOptionBuilder withLimit(int limit) {
                this.limit = limit;
                return this;
            }
    
            public V2NIMFriendAddApplicationQueryOptionBuilder withStatus(List<V2NIMFriendAddApplicationStatus> status) {
                this.status = status;
                return this;
            }
    
            public V2NIMFriendAddApplicationQueryOption build() {
                return new V2NIMFriendAddApplicationQueryOption(offset, limit, status);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMFriendAddApplicationQueryOption : NSObject
    
    @property (nonatomic,nonatomic,assign) NSUInteger offset;
    
    @property (nonatomic,nonatomic,assign) NSUInteger limit;
    
    @property (nonatomic, strong) NSArray <NSNumber *> *status;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriendAddApplicationQueryOption {
    
        uint64_t offset;
    
        uint32_t limit{V2NIM_DEFAULT_FRIEND_APPLICATION_QUERY_LIMIT};
    
        nstd::vector<V2NIMFriendAddApplicationStatus> status;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendAddApplicationQueryOption = {
    
      offset?: number
    
      limit?: number
    
      status: Array<V2NIMFriendAddApplicationStatus>
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMFriendAddApplicationQueryOption = {
    
      offset?: number
    
      limit?: number
    
      status: Array<V2NIMFriendAddApplicationStatus>
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    offset long - 分页查询偏移。首次查询传 0,下一次查询传入上一次查询返回值中的 offset(不包含 offset)
    limit Integer 50 单次查询的最大数量。
    status List<V2NIMFriendAddApplicationStatus> - 申请添加好友相关操作状态列表。如果列表为空或 size 为 0 则表示查询所有申请添加好友相关操作信息。

    V2NIMFriendAddApplicationResult

    查询申请添加好友相关操作信息列表的返回结果。

    Android
    Javapublic interface V2NIMFriendAddApplicationResult {
    
        List<V2NIMFriendAddApplication> getInfos();
    
        long getOffset();
    
        boolean isFinished();
    }
    
    iOS
    Objective-C@interface V2NIMFriendAddApplicationResult : NSObject
    
    @property (nullable,nonatomic,strong,readonly) NSArray <V2NIMFriendAddApplication*> *infos;
    
    @property (nonatomic, assign,readonly) NSUInteger offset;
    
    @property (nonatomic, assign,readonly) BOOL finished;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriendAddApplicationResult {
    
        nstd::vector<V2NIMFriendAddApplication> infos;
    
        uint64_t offset{0};
    
        bool finished{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendAddApplicationResult = {
    
      infos: Array<V2NIMFriendAddApplication>;
    
      offset: number;
    
      finished: boolean;
    
    };
    
    HarmonyOS
    TypeScriptexport type V2NIMFriendAddApplicationResult = {
      infos: Array<V2NIMFriendAddApplication>
      offset: number
      finished: boolean
    }
    

    成员参数

    名称 类型 是否只读 说明
    infos List<V2NIMFriendAddApplication> 查询返回的申请添加好友相关操作信息列表。
    offset long 下一下查询的偏移量。
    finished boolean 是否分页结束。

    V2NIMFriendSearchOption

    根据关键字搜索好友信息的配置参数。

    Android
    Javapublic class V2NIMFriendSearchOption {
    
        public String getKeyword() {
            return keyword;
        }
    
        public boolean isSearchAlias() {
            return searchAlias;
        }
    
        public boolean isSearchAccountId() {
            return searchAccountId;
        }
    
        @Override    public String toString() {
            return "V2NIMFriendSearchOption{" +
                    "keyword='" + keyword + '\'' +
                    ", searchAlias=" + searchAlias +
                    ", searchAccountId=" + searchAccountId +
                    '}';
        }
    
        public static final class V2NIMFriendSearchOptionBuilder {
            private final String keyword;
            private boolean searchAlias = SEARCH_ALIAS;
            private boolean searchAccountId = SEARCH_ACCOUNT_ID;
    
            private V2NIMFriendSearchOptionBuilder(String keyword) {
                this.keyword = keyword;
            }
    
            public static V2NIMFriendSearchOptionBuilder builder(String keyword) {
                return new V2NIMFriendSearchOptionBuilder(keyword);
            }
    
            public V2NIMFriendSearchOptionBuilder withSearchAlias(boolean searchAlias) {
                this.searchAlias = searchAlias;
                return this;
            }
    
            public V2NIMFriendSearchOptionBuilder withSearchAccountId(boolean searchAccountId) {
                this.searchAccountId = searchAccountId;
                return this;
            }
    
            public V2NIMFriendSearchOption build() {
                return new V2NIMFriendSearchOption(keyword, searchAlias, searchAccountId);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMFriendSearchOption : NSObject
    
    @property (nonatomic,copy) NSString *keyword;
    
    @property (nonatomic,assign) BOOL searchAlias;
    
    @property (nonatomic,assign) BOOL searchAccountId;
    
    + (instancetype)optionWithKeyword:(NSString *)keyword;
    
    @end
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendSearchOption = {
    
      keyword: string
    
      searchAlias?: boolean
    
      searchAccountId?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    keyword String - 搜索关键字,默认搜索好友的备注,可以指定是否同时搜索用户账号。
    searchAlias Boolean true 是否搜索好友的备注。
    searchAccountId Boolean false 是否搜索用户账号。

    V2NIMFriendListener

    好友信息相关监听器。

    Android
    Javapublic interface V2NIMFriendListener {
    
        void onFriendAdded(V2NIMFriend friendInfo);
    
        void onFriendDeleted(String accountId, V2NIMFriendDeletionType deletionType);
    
        void onFriendAddApplication(V2NIMFriendAddApplication applicationInfo);
    
        void onFriendAddRejected(V2NIMFriendAddApplication rejectionInfo);
    
        void onFriendInfoChanged(V2NIMFriend friendInfo);
    }
    
    iOS
    Objective-C@protocol V2NIMFriendListener <NSObject>
    
    - (void)onFriendAdded:(V2NIMFriend *)friendInfo;
    
    - (void)onFriendDeleted:(NSString *)accountId deletionType:(V2NIMFriendDeletionType)deletionType;
    
    - (void)onFriendAddApplication:(V2NIMFriendAddApplication *)application;
    
    - (void)onFriendAddRejected:(V2NIMFriendAddApplication *)rejectionInfo;
    
    - (void)onFriendInfoChanged:(V2NIMFriend *)friendInfo;
    
    @end
    
    macOS/Windows
    C++struct V2NIMFriendListener {
    
        nstd::function<void(V2NIMFriend friendInfo)> onFriendAdded;
    
        nstd::function<void(nstd::string accountId, V2NIMFriendDeletionType deletionType)> onFriendDeleted;
    
        nstd::function<void(V2NIMFriendAddApplication applicationInfo)> onFriendAddApplication;
    
        nstd::function<void(V2NIMFriendAddRejection rejectionInfo)> onFriendAddRejected;
    
        nstd::function<void(V2NIMFriend friendInfo)> onFriendInfoChanged;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMFriendListener = {
    
      onFriendAdded: [friend: V2NIMFriend]
    
      onFriendDeleted: [accountId: string, deletionType: V2NIMFriendDeletionType]
    
      onFriendAddApplication: [application: V2NIMFriendAddApplication]
    
      onFriendAddRejected: [rejection: V2NIMFriendAddApplication]
    
      onFriendInfoChanged: [friend: V2NIMFriend]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMFriendListener = {
    
      onFriendAdded: [friend: V2NIMFriend]
    
      onFriendDeleted: [accountId: string, deletionType: V2NIMFriendDeletionType]
    
      onFriendAddApplication: [application: V2NIMFriendAddApplication]
    
      onFriendAddRejected: [rejection: V2NIMFriendAddRejection]
    
      onFriendInfoChanged: [friend: V2NIMFriend]
    }
    
    

    成员函数

    • onFriendAdded

      添加好友成功的回调。

      当客户端本端或其他端同步添加好友成功时会触发该回调。

      参数名称 类型 是否必填 是否只读 说明
      friendInfo V2NIMFriend 添加成功的好友信息
    • onFriendDeleted

      删除好友回调。

      • 当客户端本端或其他端同步删除好友时会触发该回调。
      • 被对方删除好友时会触发该回调。
      参数名称 类型 是否必填 是否只读 说明
      deletionType V2NIMFriendDeletionType 删除好友的类型
      accountId String 账号 ID
    • deletionType=1(本端或其他端同步删除好友),则该字段为被删除的好友账号 ID
    • deletionType=2(被对方删除好友),则该字段为删除您的好友账号 ID
    • onFriendAddApplication

      请求好友添加申请的回调。

      参数名称 类型 是否必填 是否只读 说明
      application V2NIMFriendAddApplication 申请添加好友的信息
    • onFriendAddRejected

      被对方拒绝好友添加申请的回调。

      参数名称 类型 是否必填 是否只读 说明
      rejection V2NIMFriendAddApplication 被对方拒绝好友添加申请的信息
    • onFriendInfoChanged

      好友信息变更回调。

      当客户端本端或其他端同步更新好友信息时会触发该回调。

      参数名称 类型 是否必填 是否只读 说明
      friendInfo V2NIMFriend 变更的好友信息

    V2NIMChatroomClient

    聊天室实例入口类。

    成员参数

    参数名称 类型 说明
    instanceId int 实例 ID

    成员函数

    V2NIMChatroomInitParams(仅 Web & HarmonyOS)

    创建聊天室实例时的初始化参数。

    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomInitParams {
      appkey: string
      customClientType?: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomInitParams {
    
      appkey: string
      customClientType?: number
    }
    

    成员参数

    参数名称 类型 是否必填 默认值 说明
    appkey string - 应用 appkey
    customClientType int null 自定义设备类型。

    V2NIMChatroomEnterParams

    进入聊天室相关参数。

    Android
    Javapublic class V2NIMChatroomEnterParams {
    
        public V2NIMChatroomEnterParams(boolean anonymousMode, String accountId, String token, String roomNick, String roomAvatar, int timeout, V2NIMChatroomLoginOption loginOption, V2NIMChatroomLinkProvider linkProvider, String serverExtension, String notificationExtension, V2NIMChatroomTagConfig tagConfig, V2NIMChatroomLocationConfig locationConfig, V2NIMAntispamConfig antispamConfig) {
            this.anonymousMode = anonymousMode;
            this.accountId = accountId;
            this.token = token;
            this.roomNick = roomNick;
            this.roomAvatar = roomAvatar;
            this.timeout = timeout;
            this.loginOption = loginOption;
            this.linkProvider = linkProvider;
            this.serverExtension = serverExtension;
            this.notificationExtension = notificationExtension;
            this.tagConfig = tagConfig;
            this.locationConfig = locationConfig;
            this.antispamConfig = antispamConfig;
        }
    
        public boolean isAnonymousMode() {
            return anonymousMode;
        }
    
        public String getAccountId() {
            return accountId;
        }
    
        public String getToken() {
            return token;
        }
    
        public String getRoomNick() {
            return roomNick;
        }
    
        public String getRoomAvatar() {
            return roomAvatar;
        }
    
        public int getTimeout() {
            return timeout;
        }
    
        public V2NIMChatroomLoginOption getLoginOption() {
            if (loginOption == null) {
                return V2NIMChatroomLoginOption.V2NIMChatroomLoginOptionBuilder.builder().build();
            } else {
                return loginOption;
            }
        }
    
        public V2NIMChatroomLinkProvider getLinkProvider() {
            return linkProvider;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        public String getNotificationExtension() {
            return notificationExtension;
        }
    
        public V2NIMChatroomTagConfig getTagConfig() {
            return tagConfig;
        }
    
        public V2NIMChatroomLocationConfig getLocationConfig() {
            return locationConfig;
        }
    
        public V2NIMAntispamConfig getAntispamConfig() {
            return antispamConfig;
        }
    
        @Override
        public String toString() {
            return "V2NIMChatroomEnterParams{" +
                    "anonymousMode=" + anonymousMode +
                    ", accountId='" + accountId + '\'' +
                    ", token='" + token + '\'' +
                    ", roomNick='" + roomNick + '\'' +
                    ", roomAvatar='" + roomAvatar + '\'' +
                    ", timeout=" + timeout +
                    ", loginOption=" + loginOption +
                    ", linkProvider=" + linkProvider +
                    ", serverExtension='" + serverExtension + '\'' +
                    ", notificationExtension='" + notificationExtension + '\'' +
                    ", tagConfig=" + tagConfig +
                    ", locationConfig=" + locationConfig +
                    ", antispamConfig=" + antispamConfig +
                    '}';
        }
    
        public static final class V2NIMChatroomEnterParamsBuilder {
    
            public static V2NIMChatroomEnterParamsBuilder builder(V2NIMChatroomLoginOption loginOption, V2NIMChatroomLinkProvider linkProvider) {
                return new V2NIMChatroomEnterParamsBuilder(loginOption, linkProvider);
            }
    
            public V2NIMChatroomEnterParamsBuilder withAnonymousMode(boolean anonymousMode) {
                this.anonymousMode = anonymousMode;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withAccountId(String accountId) {
                this.accountId = accountId;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withToken(String token) {
                this.token = token;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withRoomNick(String roomNick) {
                this.roomNick = roomNick;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withRoomAvatar(String roomAvatar) {
                this.roomAvatar = roomAvatar;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withTimeout(int timeout) {
                this.timeout = timeout;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withServerExtension(String serverExtension) {
                this.serverExtension = serverExtension;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withNotificationExtension(String notificationExtension) {
                this.notificationExtension = notificationExtension;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withTagConfig(V2NIMChatroomTagConfig tagConfig) {
                this.tagConfig = tagConfig;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withLocationConfig(V2NIMChatroomLocationConfig locationConfig) {
                this.locationConfig = locationConfig;
                return this;
            }
    
            public V2NIMChatroomEnterParamsBuilder withAntispamConfig(V2NIMAntispamConfig antispamConfig) {
                this.antispamConfig = antispamConfig;
                return this;
            }
    
            public V2NIMChatroomEnterParams build() {
                return new V2NIMChatroomEnterParams(anonymousMode, accountId, token, roomNick, roomAvatar, timeout, loginOption, linkProvider, serverExtension, notificationExtension, tagConfig, locationConfig, antispamConfig);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomEnterParams : NSObject
    
    @property(nonatomic,assign,readwrite) BOOL anonymousMode;
    @property(nullable,nonatomic,copy,readwrite) NSString *accountId;
    @property(nullable,nonatomic,copy,readwrite) NSString *token;
    @property(nullable,nonatomic,copy,readwrite) NSString *roomNick;
    @property(nullable,nonatomic,copy,readwrite) NSString *roomAvatar;
    @property(nonatomic,assign,readwrite) NSInteger timeout;
    @property(nonatomic,copy,readwrite) V2NIMChatroomLoginOption *loginOption;
    @property(nonatomic,strong,readwrite) id<V2NIMChatroomLinkProvider> linkProvider;
    @property(nullable,nonatomic,copy,readwrite) NSString *serverExtension;
    @property(nullable,nonatomic,copy,readwrite) NSString *notificationExtension;
    @property(nullable,nonatomic,strong,readwrite) V2NIMChatroomTagConfig *tagConfig;
    @property(nullable,nonatomic,strong,readwrite) V2NIMChatroomLocationConfig *locationConfig;
    @property(nullable,nonatomic,strong,readwrite) V2NIMAntispamConfig *antispamConfig;
    
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomEnterParams {
        nstd::string accountId;
        nstd::string token;
        nstd::optional<nstd::string> roomNick;
        nstd::optional<nstd::string> roomAvatar;
        uint64_t timeout{V2NIM_DEFAULT_LOGIN_TIMEOUT};
        V2NIMChatroomLoginOption loginOption;
        bool anonymousMode{false};
        V2NIMChatroomLinkProvider linkProvider{nullptr};
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<nstd::string> notificationExtension;
        V2NIMChatroomTagConfig tagConfig;
        nstd::optional<V2NIMChatroomLocationConfig> locationConfig;
        V2NIMAntispamConfig antispamConfig;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomEnterParams {
      anonymousMode?: boolean
      accountId?: string
      token?: string
      roomNick?: string
      roomAvatar?: string
      timeout?: number
      loginOption?: V2NIMChatroomLoginOption
      linkProvider: (roomId: string, accountId: string) => Promise<Array<string>>
      serverExtension?: string
      notificationExtension?: string
      tagConfig?: V2NIMChatroomTagConfig
      locationConfig?: V2NIMChatroomLocationConfig
      antispamConfig?: V2NIMAntispamConfig
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomEnterParams {
    
      anonymousMode?: boolean
      accountId?: string
      token?: string
      roomNick?: string
      roomAvatar?: string
      timeout?: number
      loginOption?: V2NIMChatroomLoginOption
      linkProvider: (roomId: string, accountId: string) => Promise<Array<string>>
      serverExtension?: string
      notificationExtension?: string
      tagConfig?: V2NIMChatroomTagConfig
      antispamConfig?: V2NIMAntispamConfig
    }
    

    成员参数

    参数名称 类型 是否必填 默认值 说明
    anonymousMode boolean false 是否为匿名模式。
    在匿名模式下不能发消息,只能收消息。
    accountId String null 用户账号。
  • 若为匿名模式,则可以不填,SDK 内部会生成账号。规则:nimanon_ UUID.randomUUID().toString(),建议全局缓存。
  • 如果为非匿名模式,则必须为合法账号。
  • token String null 静态 token,可以不填。
    roomNick String 账号对应信息 进入聊天室后显示的昵称。
    可以不填,默认显示账号对应相关信息,例如:匿名模式则默认昵称为账号名称。
    roomAvatar String 账号对应信息 进入聊天室后显示的头像,可通过 V2NIMStorageService.uploadFile 方法上传头像。
    可以不填,默认显示账号对应相关信息,例如:匿名模式则默认头像为空。
    timeout int 60 调用 enter 方法进入聊天室超时时间。
    若超过该时间未成功进入聊天室,则返回失败回调。
    loginOption V2NIMChatroomLoginOption null 聊天室登录配置。
    linkProvider V2NIMChatroomLinkProvider - 获取聊天室连接链接地址回调,SDK 通过两种方式获取:
  • 若已登录 IM 且在线,则调用 V2NIMLoginService.getChatroomLinkAddress 方法获取聊天室连接地址。
  • 若未登录 IM,则请求业务服务器,通过服务端 API 获取聊天室地址
  • serverExtension String null 服务端扩展字段,建议使用 JSON 格式,多端同步。长度上限为 4096。
    notificationExtension String null 进入聊天室通知的扩展字段,长度上限为 2048。
    tagConfig V2NIMChatroomTagConfig null 进入聊天室的标签信息配置。
    locationConfig V2NIMChatroomLocationConfig null 进入聊天室的空间位置信息配置。
    antispamConfig V2NIMAntispamConfig null 易盾反垃圾检测。
  • 若不需要反垃圾检测,或已开启安全通,则不需要配置。
  • 若不使用安全通默认配置,需要定制审核规则,则配置该字段。
  • V2NIMChatroomLoginOption

    聊天室登录配置。

    Android
    Javapublic class V2NIMChatroomLoginOption {
    
        public V2NIMChatroomLoginOption(V2NIMLoginAuthType authType, V2NIMChatroomTokenProvider tokenProvider, V2NIMChatroomLoginExtensionProvider loginExtensionProvider) {
            this.authType = authType;
            this.tokenProvider = tokenProvider;
            this.loginExtensionProvider = loginExtensionProvider;
        }
    
        public V2NIMLoginAuthType getAuthType() {
            return authType;
        }
    
        public V2NIMChatroomTokenProvider getTokenProvider() {
            return tokenProvider;
        }
    
        public V2NIMChatroomLoginExtensionProvider getLoginExtensionProvider() {
            return loginExtensionProvider;
        }
    
        @Override
        public String toString() {
            return "V2NIMChatroomLoginOption{" +
                    "authType=" + authType +
                    ", tokenProvider=" + tokenProvider +
                    ", loginExtensionProvider=" + loginExtensionProvider +
                    '}';
        }
    
        public static final class V2NIMChatroomLoginOptionBuilder {
    
            public static V2NIMChatroomLoginOptionBuilder builder() {
                return new V2NIMChatroomLoginOptionBuilder();
            }
    
            public V2NIMChatroomLoginOptionBuilder withAuthType(V2NIMLoginAuthType authType) {
                this.authType = authType;
                return this;
            }
    
            public V2NIMChatroomLoginOptionBuilder withTokenProvider(V2NIMChatroomTokenProvider tokenProvider) {
                this.tokenProvider = tokenProvider;
                return this;
            }
    
            public V2NIMChatroomLoginOptionBuilder withLoginExtensionProvider(V2NIMChatroomLoginExtensionProvider loginExtensionProvider) {
                this.loginExtensionProvider = loginExtensionProvider;
                return this;
            }
    
            public V2NIMChatroomLoginOption build() {
                return new V2NIMChatroomLoginOption(authType, tokenProvider, loginExtensionProvider);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomLoginOption : NSObject
    
    @property(nonatomic,assign,readwrite) V2NIMLoginAuthType authType;
    
    @property(nullable,nonatomic,strong,readwrite) id<V2NIMChatroomTokenProvider> tokenProvider;
    
    @property(nullable,nonatomic,strong,readwrite) id<V2NIMChatroomLoginExtensionProvider> loginExtensionProvider;
    
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomLoginOption {
        V2NIMLoginAuthType authType{V2NIM_LOGIN_AUTH_TYPE_DEFAULT};
        V2NIMChatroomTokenProvider tokenProvider{nullptr};
        V2NIMChatroomLoginExtensionProvider loginExtensionProvider{nullptr};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomLoginOption {
      authType?: V2NIMLoginAuthType
      tokenProvider?: (appkey: string, roomId: string, accountId: string) => Promise<string>
      loginExtensionProvider?: (appkey: string, roomId: string, accountId: string) => Promise<string>
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomLoginOption {
    
      authType?: V2NIMLoginAuthType
      tokenProvider?: (appkey: string, roomId: string, accountId: string) => Promise<string>
      loginExtensionProvider?: (appkey: string, roomId: string, accountId: string) => Promise<string>
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    authType V2NIMLoginAuthType 0 鉴权方式,包括静态 Token 鉴权(默认)、动态 Token 鉴权、通过第三方回调鉴权。
    tokenProvider V2NIMChatroomTokenProvider 否,若使用动态 Token 鉴权则为必填 - 获取动态 Token 回调,用于动态 Token 登录鉴权。该回调在登录连接完成、登录鉴权校验前触发。若函数执行有异常或返回非预期内容(非法字符串),则登录中止并报错。
    loginExtensionProvider V2NIMChatroomLoginExtensionProvider 否,若使用第三方回调鉴权则为必填 - 获取用户登录业务扩展数据回调,用于第三方登录鉴权。该回调在登录连接完成、登录鉴权校验前触发。若函数执行有异常或返回非预期内容(非法字符串),则登录中止并报错。

    V2NIMChatroomTokenProvider

    聊天室获取动态 Token 回调。

    Android
    Javapublic interface V2NIMChatroomTokenProvider {
        String getToken(String roomId, String accountId);
    }
    
    iOS
    Objective-C@protocol V2NIMChatroomTokenProvider <NSObject>
    
    - (nullable NSString *)getToken:(NSString *)roomId
                          accountId:(NSString *)accountId;
    
    @end
    
    macOS/Windows
    C++using V2NIMChatroomTokenProvider = nstd::function<nstd::optional<nstd::string>(nstd::string roomId, nstd::string account)>;
    
    Web/uni-app/小程序
    TypeScript(appkey: string, roomId: string, accountId: string) => Promise<string>
    

    成员参数

    名称 类型 说明
    roomId String 聊天室 ID
    accountId String 用户登录账号

    V2NIMChatroomLoginExtensionProvider

    聊天室用户登录业务扩展数据回调。

    Android
    Javapublic interface V2NIMLoginExtensionProvider {
        String getLoginExtension(String accountId);
    }
    
    iOS
    Objective-C@protocol V2NIMLoginExtensionProvider <NSObject>
    
    - (nullable NSString *)getLoginExtension:(NSString *)accountId;
    
    @end
    
    macOS/Windows
    C++using V2NIMLoginExtensionProvider = nstd::function<nstd::optional<nstd::string>(nstd::string accountId)>;
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMLoginExtensionProvider = (accountId: string) => Promise<string> | string
    

    成员参数

    如果您的应用平台为 Android 或 iOS,则需要调用对应的成员函数获取对应参数。

    名称 类型 说明
    roomId String 聊天室 ID
    accountId String 用户登录账号

    V2NIMChatroomLinkProvider

    聊天室连接链接地址回调。

    Android
    Javapublic interface V2NIMChatroomLinkProvider {
    
        List<String> getLinkAddress(String roomId, String accountId);
    }
    
    iOS
    Objective-C@protocol V2NIMChatroomLinkProvider <NSObject>
    
    - (nullable NSArray<NSString *> *)getLinkAddress:(NSString *)roomId
                                           accountId:(NSString *)accountId;
    
    @end
    
    macOS/Windows
    C++using V2NIMChatroomLinkProvider = nstd::function<nstd::vector<nstd::string>(nstd::string roomId, nstd::string account)>;
    
    Web/uni-app/小程序
    TypeScript(roomId: string, accountId: string) => Promise<Array<string>>
    

    成员参数

    如果您的应用平台为 Android 或 iOS,则需要调用对应的成员函数获取对应参数。

    名称 类型 说明
    roomId String 聊天室 ID
    accountId String 用户登录账号

    V2NIMChatroomTagConfig

    进入聊天室标签信息配置。

    Android
    Javapublic class V2NIMChatroomTagConfig implements Serializable {
    
        public V2NIMChatroomTagConfig(List<String> tags, String notifyTargetTags) {
            this.tags = tags;
            this.notifyTargetTags = notifyTargetTags;
        }
    
        public List<String> getTags() {
            return tags;
        }
    
        public String getNotifyTargetTags() {
            return notifyTargetTags;
        }
    
        @Override
        public String toString() {
            return "V2NIMChatroomTagConfig{" +
                    "tags=" + tags +
                    ", notifyTargetTags='" + notifyTargetTags + '\'' +
                    '}';
        }
    
        public static final class V2NIMChatroomTagConfigBuilder {
    
            public static V2NIMChatroomTagConfigBuilder builder() {
                return new V2NIMChatroomTagConfigBuilder();
            }
    
            public V2NIMChatroomTagConfigBuilder withTags(List<String> tags) {
                this.tags = tags;
                return this;
            }
    
            public V2NIMChatroomTagConfigBuilder withNotifyTargetTags(String notifyTargetTags) {
                this.notifyTargetTags = notifyTargetTags;
                return this;
            }
    
            public V2NIMChatroomTagConfig build() {
                return new V2NIMChatroomTagConfig(tags, notifyTargetTags);
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomTagConfig : NSObject
    
    @property(nullable,nonatomic,copy,readwrite) NSArray<NSString *> *tags;
    @property(nullable,nonatomic,copy,readwrite) NSString *notifyTargetTags;
    
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomTagConfig {
    
        nstd::vector<nstd::string> tags;
    
        nstd::string notifyTargetTags;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomTagConfig {
    
      notifyTargetTags: string
    
      tags: string[]
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomTagConfig {
    
      notifyTargetTags: string
    
      tags: string[]
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    tags List<String> null 进入聊天室标签列表。
    notifyTargetTags String null 进入/退出聊天室通知标签信息,标签表达式请参考 聊天室标签管理

    V2NIMChatroomLocationConfig

    聊天室空间坐标信息及订阅范围配置。

    Android
    Javapublic class V2NIMChatroomLocationConfig implements Serializable {
    
        public V2NIMChatroomLocationConfig() {
        }
    
        public V2NIMChatroomLocationConfig(V2NIMLocationInfo locationInfo, double distance) {
            this.locationInfo = locationInfo;
            this.distance = distance;
        }
    
        public V2NIMLocationInfo getLocationInfo() {
            return locationInfo;
        }
    
        public void setLocationInfo(V2NIMLocationInfo locationInfo) {
            this.locationInfo = locationInfo;
        }
    
        public Double getDistance() {
            return distance;
        }
    
        public void setDistance(double distance) {
            this.distance = distance;
        }
    
        public boolean isValid() {
            return locationInfo != null && locationInfo.isValid() && distance != null;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomLocationConfig : NSObject
    
    @property(nullable,nonatomic,copy,readwrite) V2NIMLocationInfo *locationInfo;
    @property(nonatomic,assign,readwrite) double distance;
    
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomLocationConfig {
        V2NIMLocationInfo locationInfo;
        nstd::optional<double> distance;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomLocationConfig {
      locationInfo?: V2NIMLocationInfo
      distance: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomLocationConfig {
    
      locationInfo?: V2NIMLocationInfo
    
      distance: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    locationInfo V2NIMLocationInfo - 聊天室空间位置坐标信息。
    distance double - 基于空间位置订阅聊天室消息的距离。

    V2NIMLocationInfo

    聊天室空间坐标信息。

    Android
    Javapublic class V2NIMLocationInfo implements Serializable {
    
        public V2NIMLocationInfo() {
        }
    
        public V2NIMLocationInfo(double x, double y, double z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }
    
        public Double getX() {
            return x;
        }
    
        public void setX(double x) {
            this.x = x;
        }
    
        public Double getY() {
            return y;
        }
    
        public void setY(double y) {
            this.y = y;
        }
    
        public Double getZ() {
            return z;
        }
    
        public void setZ(double z) {
            this.z = z;
        }
    
        public boolean isValid() {
            return x != null && y != null && z != null;
        }
    }
    
    iOS
    Objective-C@interface V2NIMLocationInfo : NSObject <NSCopying>
    
    @property(nonatomic,assign,readwrite) double x;
    @property(nonatomic,assign,readwrite) double y;
    @property(nonatomic,assign,readwrite) double z;
    
    @end
    
    macOS/Windows
    C++struct V2NIMLocationInfo {
        nstd::optional<double> x;
        nstd::optional<double> y;
        nstd::optional<double> z;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMLocationInfo {
      x?: number
      y?: number
      z?: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMLocationInfo {
    
      x?: number
    
      y?: number
    
      z?: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    x double - 聊天室空间 x 坐标。
    y double - 聊天室空间 y 坐标。
    z double - 聊天室空间 z 坐标。

    V2NIMChatroomEnterResult

    进入聊天室结果回包。

    Android
    Javapublic interface V2NIMChatroomEnterResult {
    
        V2NIMChatroomInfo getChatroom();
        V2NIMChatroomMember getSelfMember();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomEnterResult : NSObject
    
    @property(nonatomic,copy,readonly) V2NIMChatroomInfo *chatroom;
    
    @property(nonatomic,copy,readonly) V2NIMChatroomMember *selfMember;
    
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomEnterResult {
        V2NIMChatroomInfo chatroom;
        V2NIMChatroomMember selfMember;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomEnterResult {
      chatroom: V2NIMChatroomInfo
      selfMember: V2NIMChatroomMember
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomEnterResult {
    
      chatroom: V2NIMChatroomInfo
    
      selfMember: V2NIMChatroomMember
    }
    

    成员参数

    名称 类型 是否只读 说明
    chatroom V2NIMChatroomInfo 聊天室信息。
    selfMember V2NIMChatroomMember 聊天室成员用户信息:
  • 必返回字段:roomId、accountId、memberRole、enterTime
  • 根据入参是否设置决定是否返回:roomNick、roomAvatar、serverExtension、tags、notifyTargetTags
  • 根据历史状态决定是否返回:chantBanned、tempChatBanned、tempChatBannedDuration
  • 以是否修改过决定是否返回:isOnline:true、blocked:false、memberLevel
  • updateTime:返回 0
  • V2NIMChatroomInfo

    聊天室信息。

    Android
    Javapublic interface V2NIMChatroomInfo extends Serializable {
        String getRoomId();
        String getRoomName();
        String getAnnouncement();
        String getLiveUrl();
        boolean isValidRoom();
        String getServerExtension();
        V2NIMChatroomQueueLevelMode getQueueLevelMode();
        String getCreatorAccountId();
        int getOnlineUserCount();
        boolean isChatBanned();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomInfo : NSObject <NSCopying>
    @property (nonatomic, strong, readonly) NSString *roomId;
    @property (nonatomic, strong, readonly) NSString *roomName;
    @property (nonatomic, strong, readonly) NSString *announcement;
    @property (nonatomic, strong, readonly) NSString *liveUrl;
    @property (nonatomic, assign, readonly) BOOL isValidRoom;
    @property (nonatomic, strong, readonly) NSString *serverExtension;
    @property (nonatomic, assign, readonly) V2NIMChatroomQueueLevelMode queueLevelMode;
    @property (nonatomic, strong, readonly) NSString *creatorAccountId;
    @property (nonatomic, assign, readonly) NSInteger onlineUserCount;
    @property (nonatomic, assign, readonly) BOOL chatBanned;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomInfo {
        nstd::string roomId;
        nstd::string roomName;
        nstd::string announcement;
        nstd::string liveUrl;
        bool isValidRoom{true};
        nstd::string serverExtension;
        V2NIMChatroomQueueLevelMode queueLevelMode{V2NIM_CHATROOM_QUEUE_LEVEL_MODE_ANY};
        nstd::string creatorAccountId;
        uint32_t onlineUserCount{0};
        bool chatBanned{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomInfo {
      roomId: string
      roomName: string
      announcement: string
      liveUrl: string
      isValidRoom: boolean
      serverExtension: string
      queueLevelMode: V2NIMChatroomQueueLevelMode
      creatorAccountId: string
      createTime: number
      onlineUserCount: number
      chatBanned: boolean
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomInfo {
    
      roomId: string
      roomName: string
      announcement: string
      liveUrl: string
      isValidRoom: boolean
      serverExtension: string
      queueLevelMode: V2NIMChatroomQueueLevelMode
      creatorAccountId: string
      createTime: number
      onlineUserCount: number
      chatBanned: boolean
    }
    

    成员参数

    名称 类型 是否只读 说明
    roomId String 聊天室 ID
    roomName String 聊天室名称。
    announcement String 聊天室公告。
    liveUrl String 视频直播拉流地址。
    isValidRoom boolean 聊天室是否有效。
    serverExtension String 聊天室服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    queueLevelMode V2NIMChatroomQueueLevelMode 聊天室队列操作权限模式。
    creatorAccountId String 聊天室创建者用户账号。
    onlineUserCount int 聊天室当前在线用户数量。
    chatBanned boolean 聊天室是否处于禁言状态:
  • true:禁言
  • false:非禁言。
  • tempChatBanned boolean 聊天室是否处于临时禁言状态:
  • true:禁言
  • false:非禁言。
  • V2NIMChatroomMember

    聊天室成员信息。

    Android
    Javapublic interface V2NIMChatroomMember extends Serializable {
        String getRoomId();
        String getAccountId();
        V2NIMChatroomMemberRole getMemberRole();
        Integer getMemberLevel();
        String getRoomNick();
        String getRoomAvatar();
        String getServerExtension();
        boolean isOnline();
        boolean isBlocked();
        boolean isChatBanned();
        boolean isTempChatBanned();
        long getTempChatBannedDuration();
        List<String> getTags();
        String getNotifyTargetTags();
        long getEnterTime();
        long getUpdateTime();
        boolean isValid();
        List<V2NIMChatroomEnterInfo> getMultiEnterInfo();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMember : NSObject <NSCopying>
    @property (nullable,nonatomic,strong,readonly) NSString *roomId;
    @property (nullable,nonatomic,strong,readonly) NSString *accountId;
    @property (nonatomic,assign,readonly) V2NIMChatroomMemberRole memberRole;
    @property (nonatomic,assign,readonly) NSInteger memberLevel;
    @property (nullable,nonatomic,strong,readonly) NSString *roomNick;
    @property (nullable,nonatomic,strong,readonly) NSString *roomAvatar;
    @property (nullable,nonatomic,strong,readonly) NSString *serverExtension;
    @property (nonatomic,assign,readonly) BOOL isOnline;
    @property (nonatomic,assign,readonly) BOOL blocked;
    @property (nonatomic,assign,readonly) BOOL chatBanned;
    @property (nonatomic,assign,readonly) BOOL tempChatBanned;
    @property (nonatomic,assign,readonly) NSInteger tempChatBannedDuration;
    @property (nullable,nonatomic,strong,readonly) NSArray<NSString *> *tags;
    @property (nullable,nonatomic,strong,readonly) NSString *notifyTargetTags;
    @property (nonatomic,assign,readonly) NSTimeInterval enterTime;
    @property (nonatomic,assign,readonly) NSTimeInterval updateTime;
    @property (nonatomic,assign,readonly) BOOL valid;
    @property (nullable,nonatomic,strong,readonly) NSArray *multiEnterInfo;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMember {
        nstd::string roomId;
        nstd::string accountId;
        V2NIMChatroomMemberRole memberRole{V2NIM_CHATROOM_MEMBER_ROLE_NORMAL};
        nstd::optional<uint32_t> memberLevel;
        nstd::optional<nstd::string> roomNick;
        nstd::optional<nstd::string> roomAvatar;
        nstd::optional<nstd::string> serverExtension;
        bool isOnline{true};
        bool blocked{false};
        bool chatBanned{false};
        bool tempChatBanned{false};
        uint64_t tempChatBannedDuration{0};
        nstd::vector<nstd::string> tags;
        nstd::string notifyTargetTags;
        uint64_t enterTime{0};
        uint64_t updateTime{0};
        bool valid{true};
        nstd::vector<V2NIMChatroomEnterInfo> multiEnterInfo;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomMember = {
      roomId: string
      accountId: string
      memberRole: V2NIMChatroomMemberRole
      memberLevel?: number
      roomNick?: string
      roomAvatar?: string
      serverExtension?: string
      isOnline: boolean
      blocked: boolean
      chatBanned: boolean
      tempChatBanned: boolean
      tempChatBannedDuration: number
      tags?: string
      notifyTargetTags?: string
      enterTime?: number
      updateTime: number
      valid: boolean
      multiEnterInfo: V2NIMChatroomEnterInfo[]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomMember = {
    
      roomId: string
      accountId: string
      memberRole: V2NIMChatroomMemberRole
      memberLevel?: number
      roomNick?: string
      roomAvatar?: string
      serverExtension?: string
      isOnline: boolean
      blocked: boolean
      chatBanned: boolean
      tempChatBanned: boolean
      tempChatBannedDuration: number
      tags?: string
      notifyTargetTags?: string
      enterTime?: number
      updateTime: number
      valid: boolean
      multiEnterInfo: V2NIMChatroomEnterInfo[]
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    roomId String - 聊天室 ID
    accountId String - 聊天室成员用户账号。
    memberRole V2NIMChatroomMemberRole - 聊天室成员角色类型。
    memberLevel int 0,表示未设置 聊天室成员等级,大于或等于 0 的整数。
    roomNick String - 聊天室中显示昵称。
    roomAvatar String - 聊天室中显示头像。
    serverExtension String - 聊天室成员服务端扩展字段,多端同步。建议 JSON 格式,长度上限为 2048。
    isOnline boolean - 聊天室用户是否在线。
    blocked boolean - 聊天室用户是否在黑名单列表中。
    chatBanned boolean - 聊天室用户是否处于禁言状态。
    tempChatBanned boolean - 聊天室用户是否处于临时禁言状态。
    tempChatBannedDuration long 0 聊天室临时禁言时长(秒)
    tags List<String> - 聊天室登录终端标签。
    notifyTargetTags String - 聊天室登录登出通知标签,请参考 标签表达式
    enterTime long 0 用户进入聊天室时间戳。
    固定成员离线后该字段为 0。
    updateTime long - 固定成员 (创建者、管理员、普通成员)更新时间戳。
    valid boolean - 预留字段。
    multiEnterInfo List<V2NIMChatroomEnterInfo> - 聊天室多端登录信息。
    同一个账号可以登录多个终端,多个终端同时在线。

    V2NIMChatroomEnterInfo

    进入聊天室信息。

    Android
    Javapublic interface V2NIMChatroomEnterInfo extends Serializable {
        String getRoomNick();
        String getRoomAvatar();
    
        long getEnterTime();
    
        int getClientType();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomEnterInfo: NSObject <NSCopying>
    @property (nullable,nonatomic,strong,readonly) NSString *roomNick;
    @property (nullable,nonatomic,strong,readonly) NSString *roomAvatar;
    @property (nonatomic,assign,readonly) NSTimeInterval enterTime;
    @property (nonatomic,assign,readonly) NSInteger clientType;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomEnterInfo {
        nstd::string roomNick;
        nstd::string roomAvatar;
        uint64_t enterTime{0};
        uint32_t clientType{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomEnterInfo {
      roomNick: string
      roomAvatar: string
      enterTime: number
      clientType: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomEnterInfo {
    
      roomNick: string
      roomAvatar: string
      enterTime: number
      clientType: number
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    roomNick String - 进入聊天室后显示的昵称。
    roomAvatar String - 进入聊天室后显示的头像。
    enterTime long 0 用户进入聊天室时间戳。离线成员该字段为 0。
    clientType int 0,表示未设置 进入聊天室终端类型。

    V2NIMChatroomKickedInfo

    被踢出聊天室信息。

    Android
    Javapublic interface V2NIMChatroomKickedInfo extends Serializable {
    
        V2NIMChatroomKickedReason getKickedReason();
    
        String getServerExtension();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomKickedInfo : NSObject
    
    @property(nonatomic,assign,readonly) V2NIMChatroomKickedReason kickedReason;
    @property(nullable,nonatomic,copy,readonly) NSString *serverExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomKickedInfo {
        V2NIMChatroomKickedReason kickedReason{V2NIM_CHATROOM_KICKED_REASON_UNKNOWN};
        nstd::string serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomKickedInfo {
      kickedReason: V2NIMChatroomKickedReason
      serverExtension: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomKickedInfo {
    
      kickedReason: V2NIMChatroomKickedReason
    
      serverExtension: string
    }
    

    成员参数

    名称 类型 是否只读 是否必填 说明
    kickedReason V2NIMChatroomKickedReason 被踢原因。
    serverExtension String 被踢信息的服务端扩展字段,多端同步。

    V2NIMUserInfoConfig

    消息发送方的用户信息配置。

    Android
    Javapublic class V2NIMUserInfoConfig implements Serializable {
        public Long getUserInfoTimestamp() {
            return userInfoTimestamp;
        }
    
        public void setUserInfoTimestamp(Long userInfoTimestamp) {
            this.userInfoTimestamp = userInfoTimestamp;
        }
    
        public String getSenderNick() {
            return senderNick;
        }
    
        public void setSenderNick(String senderNick) {
            this.senderNick = senderNick;
        }
    
        public String getSenderAvatar() {
            return senderAvatar;
        }
    
        public void setSenderAvatar(String senderAvatar) {
            this.senderAvatar = senderAvatar;
        }
    
        public String getSenderExtension() {
            return senderExtension;
        }
    
        public void setSenderExtension(String senderExtension) {
            this.senderExtension = senderExtension;
        }
    }
    
    iOS
    Objective-C@interface V2NIMUserInfoConfig : NSObject <NSCopying>
    
    @property(nonatomic, assign, readwrite) NSTimeInterval userInfoTimestamp;
    
    @property(nullable, nonatomic, strong, readwrite) NSString *senderNick;
    
    @property(nullable, nonatomic, strong, readwrite) NSString *senderAvatar;
    
    @property(nullable, nonatomic, strong, readwrite) NSString *senderExtension;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUserInfoConfig {
        uint64_t userInfoTimestamp{0};
        nstd::string senderNick;
        nstd::string senderAvatar;
        nstd::string senderExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUserInfoConfig = {
      userInfoTimestamp?: number
      senderNick?: string
      senderAvatar?: string
      senderExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMUserInfoConfig = {
    
      userInfoTimestamp?: number
    
      senderNick?: string
    
      senderAvatar?: string
    
      senderExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    userInfoTimestamp long null 消息发送方用户信息的最后更新时间。
    senderNick String null 消息发送方的昵称。
    senderAvatar String null 消息发送方的头像。
    senderExtension String null 消息发送方的服务端扩展字段,多端同步。

    V2NIMChatroomMessageConfig

    聊天室消息配置。

    Android
    Javapublic class V2NIMChatroomMessageConfig implements Serializable {
    
        public V2NIMChatroomMessageConfig() {
        }
    
        public V2NIMChatroomMessageConfig(Boolean historyEnabled) {
            this.historyEnabled = historyEnabled;
        }
    
        public boolean isHighPriority() {
            if (highPriority == null) {
                return false;
            }
            return highPriority;
        }
    
        public void setHighPriority(Boolean highPriority) {
            this.highPriority = highPriority;
        }
    
        public boolean isHistoryEnabled() {
            if (historyEnabled == null) {
                return true;
            }
            return historyEnabled;
        }
    
        public void setHistoryEnabled(boolean historyEnabled) {
            this.historyEnabled = historyEnabled;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMessageConfig : NSObject <NSCopying>
    @property(nonatomic,assign,readwrite) BOOL historyEnabled;
    @property(nonatomic,assign,readwrite) BOOL highPriority;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMessageConfig {
        bool historyEnabled{true};
        bool highPriority{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomMessageConfig = {
    
      historyEnabled?: boolean
    
      highPriority?: boolean
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomMessageConfig = {
    
      historyEnabled?: boolean
      highPriority?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    historyEnabled boolean true 是否需要在服务端保存历史消息。
    highPriority boolean false 是否是高优先级消息。
    在超频情况下,默认先流控低优先级消息。

    V2NIMChatroomMessage

    聊天室消息。

    Android
    Javapublic interface V2NIMChatroomMessage extends Serializable {
    
        String getMessageClientId();
    
        int getSenderClientType();
    
        long getCreateTime();
    
        String getSenderId();
    
        String getRoomId();
    
        boolean isSelf();
    
        V2NIMMessageAttachmentUploadState getAttachmentUploadState();
    
        V2NIMMessageSendingState getSendingState();
    
        // 消息类型
        V2NIMMessageType getMessageType();
    
        Integer getSubType();
    
        String getText();
    
        // 消息附属附件,根据消息类型继承实现
        V2NIMMessageAttachment getAttachment();
    
        String getServerExtension();
    
        String getCallbackExtension();
    
        V2NIMMessageRouteConfig getRouteConfig();
    
        V2NIMMessageAntispamConfig getAntispamConfig();
    
        String getNotifyTargetTags();
    
        V2NIMChatroomMessageConfig getMessageConfig();
    
        V2NIMUserInfoConfig getUserInfoConfig();
    
        V2NIMLocationInfo getLocationInfo();
    
    iOS
    Objective-C@interface V2NIMChatroomMessage : NSObject<NSCopying>
    @property(nullable,nonatomic,strong,readonly) NSString *messageClientId;
    @property(nonatomic,assign,readonly) NSInteger senderClientType;
    @property(nonatomic,assign,readonly) NSTimeInterval createTime;
    @property(nullable,nonatomic,strong,readonly) NSString *senderId;
    @property(nullable,nonatomic,strong,readonly) NSString *roomId;
    @property(nonatomic,assign,readonly) BOOL isSelf;
    @property(nonatomic,assign,readonly) V2NIMMessageAttachmentUploadState attachmentUploadState;
    @property(nonatomic,assign,readonly) V2NIMMessageSendingState sendingState;
    @property(nonatomic,assign,readonly) V2NIMMessageType messageType;
    @property(nonatomic,assign) NSInteger subType;
    @property(nullable,nonatomic,strong) NSString *text;
    @property(nullable,nonatomic,strong) V2NIMMessageAttachment *attachment;
    @property(nullable,nonatomic,strong) NSString *serverExtension;
    @property(nullable,nonatomic,strong,readonly) NSString *callbackExtension;
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageRouteConfig *routeConfig;
    @property(nullable,nonatomic,strong,readonly) V2NIMMessageAntispamConfig *antispamConfig;
    @property(nullable,nonatomic,strong) NSString *notifyTargetTags;
    @property(nullable,nonatomic,strong,readonly) V2NIMChatroomMessageConfig *messageConfig;
    @property(nullable,nonatomic,strong) V2NIMUserInfoConfig *userInfoConfig;
    @property(nullable,nonatomic,strong) V2NIMLocationInfo *locationInfo;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMessage {
        nstd::string messageClientId;
        V2NIMLoginClientType senderClientType{V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN};
        uint64_t createTime{0};
        nstd::string senderId;
        nstd::string roomId;
        bool isSelf{false};
        V2NIMMessageAttachmentUploadState attachmentUploadState{V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UNKNOWN};
        V2NIMMessageSendingState sendingState{V2NIM_MESSAGE_SENDING_STATE_UNKNOWN};
        V2NIMMessageType messageType{V2NIM_MESSAGE_TYPE_TEXT};
        uint32_t subType{0};
        nstd::string text;
        nstd::shared_ptr<V2NIMMessageAttachment> attachment;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<nstd::string> callbackExtension;
        V2NIMMessageRouteConfig routeConfig;
        V2NIMMessageAntispamConfig antispamConfig;
        nstd::string notifyTargetTags;
        V2NIMChatroomMessageConfig messageConfig;
        V2NIMUserInfoConfig userInfoConfig;
        nstd::optional<V2NIMLocationInfo> locationInfo;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomMessage = {
      messageClientId: string
      senderClientType: number
      createTime: number
      senderId: string
      roomId: string
      isSelf: boolean
      // attachmentUploadState: V2NIMMessageAttachmentUploadState
      sendingState: V2NIMMessageSendingState
      messageType: V2NIMMessageType
      subType?: number
      text?: string
      serverExtension?: string
      callbackExtension?: string
      messageConfig?: V2NIMChatroomMessageConfig
      routeConfig?: V2NIMMessageRouteConfig
      antispamConfig?: V2NIMMessageAntispamConfig
      notifyTargetTags?: string
      userInfoConfig?: V2NIMUserInfoConfig
      locationInfo?: V2NIMLocationInfo
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomMessage {
    
      messageClientId: string
      senderClientType: number
      createTime: number
      senderId: string
      roomId: string
      isSelf: boolean
      sendingState: V2NIMMessageSendingState
      messageType: V2NIMMessageType
      subType?: number
      text?: string
      attachment?:
        | V2NIMMessageAttachment
        | Partial<V2NIMMessageFileAttachment>
        | Partial<V2NIMMessageImageAttachment>
        | Partial<V2NIMMessageAudioAttachment>
        | Partial<V2NIMMessageVideoAttachment>
        | Partial<V2NIMMessageLocationAttachment>
        | V2NIMChatroomNotificationAttachment
        | V2NIMChatroomMessageRevokeNotificationAttachment
        | V2NIMChatroomQueueNotificationAttachment
        | V2NIMChatroomChatBannedNotificationAttachment
        | V2NIMChatroomMemberEnterNotificationAttachment
        | V2NIMChatroomMemberRoleUpdateAttachment
    
      serverExtension?: string
      callbackExtension?: string
      messageConfig?: V2NIMChatroomMessageConfig
      routeConfig?: V2NIMMessageRouteConfig
      antispamConfig?: V2NIMMessageAntispamConfig
      notifyTargetTags?: string
      userInfoConfig?: V2NIMUserInfoConfig
      locationInfo?: V2NIMLocationInfo
    }
    

    成员参数

    名称 类型 是否必填 是否只读 说明
    messageClientId String 消息客户端 ID。
    客户端生成的 UUID,不多端同步。
    senderClientType V2NIMLoginClientType 消息发送方的登录客户端类型,服务端返回。
    createTime long 消息创建时间戳(毫秒),服务端返回。
    在消息发送成功前,该字段为发送者本地时间。
    senderId String 消息发送方账号。
    roomId String 聊天室 ID
    isSelf boolean 消息发送方是否为本人。
    attachmentUploadState V2NIMMessageAttachmentUploadState 消息附件上传状态。
    sendingState V2NIMMessageSendingState 消息发送状态。
    messageType V2NIMMessageType 消息类型。
    subType int - 消息子类型。
    text String - 消息文本内容,仅文本类型的消息有该字段。不超过 5000 字符。
    attachment V2NIMMessageAttachment - 消息附件,仅图片、语音、视频、文件类型消息有该字段。
    serverExtension String - 消息服务端扩展字段,多端同步。不超过 2048 字节。
    callbackExtension String 第三方回调透传的自定义扩展字段,不超过 2048 字节。
    routeConfig V2NIMMessageRouteConfig 消息事件抄送相关配置。
    消息抄送功能需要在 网易云信控制台开通
    antispamConfig V2NIMMessageAntispamConfig 反垃圾相关配置。
    反垃圾功能包括客户端反垃圾和安全通,均需要在 网易云信控制台开通
    notifyTargetTags String - 消息通知标签信息,标签表达式请参考 聊天室标签管理
    messsageConfig V2NIMChatroomMessageConfig 聊天室消息配置。
    userInfoConfig V2NIMUserInfoConfig - 消息发送方用户信息配置。

    V2NIMChatroomNotificationAttachment

    聊天室通知消息附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMChatroomNotificationAttachment extends V2NIMMessageAttachment {
        V2NIMChatroomMessageNotificationType getType();
        List<String> getTargetIds();
        List<String> getTargetNicks();
        String getTargetTag();
        String getOperatorId();
        String getOperatorNick();
        String getNotificationExtension();
        List<String> getTags();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomNotificationAttachment : V2NIMMessageAttachment
    @property(nonatomic, assign, readonly) V2NIMChatroomMessageNotificationType type;
    @property(nonatomic, strong, readonly) NSArray<NSString *> *targetIds;
    @property(nonatomic, strong, readonly) NSArray<NSString *> *targetNicks;
    @property(nonatomic, strong, readonly) NSString *targetTag;
    @property(nonatomic, strong, readonly) NSString *operatorId;
    @property(nonatomic, strong, readonly) NSString *operatorNick;
    @property(nonatomic, strong, readonly) NSString *notificationExtension;
    @property(nonatomic, strong, readonly) NSArray<NSString *> *tags;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomNotificationAttachment : public V2NIMMessageAttachment {
        V2NIMChatroomNotificationAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_NOTIFICATION; }
        V2NIMChatroomMessageNotificationType type{V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_ENTER};
        nstd::vector<nstd::string> targetIds;
        nstd::vector<nstd::string> targetNicks;
        nstd::optional<nstd::string> targetTag;
        nstd::string operatorId;
        nstd::string operatorNick;
        nstd::optional<nstd::string> notificationExtension;
        nstd::vector<nstd::string> tags;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomNotificationAttachment extends V2NIMMessageAttachment {
      type: V2NIMChatroomMessageNotificationType
      targetIds?: string[]
      targetNicks?: string
      targetTag?: string
      operatorId?: string
      operatorNick?: string
      notificationExtension?: string
      tags?: string[]
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    type V2NIMChatroomMessageNotificationType - 通知类型。
    targetIds List<String> null 被操作者账号(accountId)列表。
    targetNicks List<String> null 被操作者的昵称列表。
    targetTag String null 被操作者的标签。
    operatorId String null 操作者账号(accountId)
    operatorNick String null 操作者的昵称。
    notificationExtension String null 操作后通知的扩展字段。
    tags List<String> null 操作后通知的通知的标签列表。

    V2NIMChatroomMessageRevokeNotificationAttachment

    聊天室撤回消息通知附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMChatroomMessageRevokeNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
     String getMessageClientId();
    
     long getMessageTime();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMessageRevokeNotificationAttachment: V2NIMChatroomNotificationAttachment
    
    @property(nonatomic, strong, readonly) NSString *messageClientId;
    
    @property(nonatomic, assign, readonly) NSTimeInterval messageTime;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMessageRevokeNotificationAttachment : public V2NIMChatroomNotificationAttachment {
        V2NIMChatroomMessageRevokeNotificationAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MESSAGE_REVOKE_NOTIFICATION; }
    
        nstd::string messageClientId;
    
        uint64_t messageTime{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomMessageRevokeNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
      messageClientId?: string
    
      messageTime?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomMessageRevokeNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
      messageClientId?: string
    
      messageTime?: string
    }
    

    成员参数

    名称 类型 是否必填 说明
    messageClientId String 撤回的消息客户端 ID。
    客户端生成的 UUID,不多端同步。
    messageTime long 消息撤回时间戳。

    V2NIMChatroomChatBannedNotificationAttachment

    聊天室禁言通知附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMChatroomChatBannedNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
     boolean isChatBanned();
    
     boolean isTempChatBanned();
    
     long getTempChatBannedDuration();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomChatBannedNotificationAttachment: V2NIMChatroomNotificationAttachment
    
    @property(nonatomic, assign, readonly) BOOL chatBanned;
    
    @property(nonatomic, assign, readonly) BOOL tempChatBanned;
    
    @property(nonatomic, assign, readonly) NSTimeInterval tempChatBannedDuration;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomChatBannedNotificationAttachment : public V2NIMChatroomNotificationAttachment {
        V2NIMChatroomChatBannedNotificationAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_CHAT_BANNED_NOTIFICATION; }
    
        bool chatBanned{false};
    
        bool tempChatBanned{false};
    
        uint64_t tempChatBannedDuration{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomChatBannedNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
      chatBanned?: boolean
    
      tempChatBanned?: boolean
    
      tempChatBannedDuration?: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomChatBannedNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
      chatBanned?: boolean
    
      tempChatBanned?: boolean
    
      tempChatBannedDuration?: number
    }
    

    成员参数

    名称 类型 是否必填 说明
    chatBanned boolean 聊天室成员是否被禁言。
    tempChatBanned boolean 聊天室成员是否被临时禁言。
    tempChatBannedDuration long 聊天室成员被临时禁言时长(毫秒)。0 表示已解除禁言。

    V2NIMChatroomMemberEnterNotificationAttachment

    成员进出聊天室通知附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMChatroomMemberEnterNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
     boolean isChatBanned();
    
     boolean isTempChatBanned();
    
     long getTempChatBannedDuration();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMemberEnterNotificationAttachment: V2NIMChatroomNotificationAttachment
    
    @property(nonatomic, assign, readonly) BOOL chatBanned;
    
    @property(nonatomic, assign, readonly) BOOL tempChatBanned;
    
    @property(nonatomic, assign, readonly) NSTimeInterval tempChatBannedDuration;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMemberEnterNotificationAttachment : public V2NIMChatroomNotificationAttachment {
        V2NIMChatroomMemberEnterNotificationAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MEMBER_ENTER_NOTIFICATION; }
    
        bool chatBanned{false};
    
        bool tempChatBanned{false};
    
        uint64_t tempChatBannedDuration{0};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomMemberEnterNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
      chatBanned?: boolean
    
      tempChatBanned?: boolean
    
      tempChatBannedDuration?: number
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomMemberEnterNotificationAttachment extends V2NIMChatroomNotificationAttachment {
    
      chatBanned?: boolean
    
      tempChatBanned?: boolean
    
      tempChatBannedDuration?: number
    }
    

    成员参数

    名称 类型 是否必填 说明
    chatBanned boolean 聊天室成员是否被禁言。
    管理员、普通成员、普通游客离开后再次进入聊天室时,保持之前设置的状态不变。
    tempChatBanned boolean 聊天室成员是否被临时禁言。
    管理员、普通成员、普通游客离开后再次进入聊天室时,保持之前设置的状态不变。
    tempChatBannedDuration long 聊天室成员被禁言时长(毫秒)。
    成员离开后再次进入聊天室时,禁言时长不会重新计算。

    V2NIMChatroomMemberRoleUpdateAttachment

    聊天室成员角色变更通知附件对象,继承自 V2NIMMessageAttachment

    Android
    Javapublic interface V2NIMChatroomMemberRoleUpdateAttachment extends V2NIMChatroomNotificationAttachment {
     V2NIMChatroomMemberRole getPreviousRole();
    
     V2NIMChatroomMember getCurrentMember();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMemberRoleUpdateAttachment: V2NIMChatroomNotificationAttachment
    
    @property(nonatomic, assign, readonly) V2NIMChatroomMemberRole previousRole;
    
    @property(nonatomic, strong, readonly) V2NIMChatroomMember *currentMember;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMemberRoleUpdateAttachment : public V2NIMChatroomNotificationAttachment {
        V2NIMChatroomMemberRoleUpdateAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MEMBER_ROLE_UPDATE_NOTIFICATION; }
    
        V2NIMChatroomMemberRole previousRole{V2NIM_CHATROOM_MEMBER_ROLE_NORMAL};
    
        V2NIMChatroomMember currentMember;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomMemberRoleUpdateAttachment extends V2NIMChatroomNotificationAttachment {
      previousRole: V2NIMChatroomMemberRole
    
      currentMember: V2NIMChatroomMember
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomMemberRoleUpdateAttachment extends V2NIMChatroomNotificationAttachment {
      previousRole: V2NIMChatroomMemberRole
    
      currentMember: V2NIMChatroomMember
    }
    

    成员参数

    名称 类型 是否必填 说明
    previousRole V2NIMChatroomMemberRole 变更前的角色类型。
    currentMember V2NIMChatroomMember 变更后的成员信息。

    V2NIMSendChatroomMessageParams

    聊天室消息发送参数配置。

    Android
    Javapublic class V2NIMSendChatroomMessageParams {
    
        public V2NIMSendChatroomMessageParams() {
        }
    
        public V2NIMChatroomMessageConfig getMessageConfig() {
            return messageConfig;
        }
        public void setMessageConfig(V2NIMChatroomMessageConfig messageConfig) {
        this.messageConfig = messageConfig;
        }
        public V2NIMMessageRouteConfig getRouteConfig() {
            return routeConfig;
        }
    
        public void setRouteConfig(V2NIMMessageRouteConfig routeConfig) {
            this.routeConfig = routeConfig;
        }
    
        public V2NIMMessageAntispamConfig getAntispamConfig() {
            return antispamConfig;
        }
    
        public void setAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
            this.antispamConfig = antispamConfig;
        }
    
        public boolean isClientAntispamEnabled() {
            if (clientAntispamEnabled == null) {
            return false;
        }
            return clientAntispamEnabled;
        }
    
        public void setClientAntispamEnabled(Boolean clientAntispamEnabled) {
            this.clientAntispamEnabled = clientAntispamEnabled;
        }
    
        public String getClientAntispamReplace() {
            if(clientAntispamReplace == null) {
            return "";
        }
            return clientAntispamReplace;
        }
    
        public void setClientAntispamReplace(String clientAntispamReplace) {
            this.clientAntispamReplace = clientAntispamReplace;
        }
    
        public List<String> getReceiverIds() {
            return receiverIds;
        }
    
        public void setReceiverIds(List<String> receiverIds) {
            this.receiverIds = receiverIds;
        }
    
        public String getNotifyTargetTags() {
            return notifyTargetTags;
        }
    
        public void setNotifyTargetTags(String notifyTargetTags) {
            this.notifyTargetTags = notifyTargetTags;
        }
    
        public V2NIMLocationInfo getLocationInfo() {
            return locationInfo;
        }
    
        public void setLocationInfo(V2NIMLocationInfo locationInfo) {
            this.locationInfo = locationInfo;
        }
    }
    
    iOS
    Objective-C@interface V2NIMSendChatroomMessageParams : NSObject
    @property(nullable, nonatomic, strong, readwrite) V2NIMChatroomMessageConfig *messageConfig;
    @property(nullable, nonatomic, strong, readwrite) V2NIMMessageRouteConfig *routeConfig;
    @property(nullable, nonatomic, strong, readwrite) V2NIMMessageAntispamConfig *antispamConfig;
    V2NIMClientAntispamOperateType,
    @property(nonatomic, assign, readwrite) BOOL clientAntispamEnabled;
    @property(nullable, nonatomic, strong, readwrite) NSString *clientAntispamReplace;
    @property(nullable, nonatomic, strong, readwrite) NSArray *receiverIds;
    @property(nullable, nonatomic, strong, readwrite) NSString *notifyTargetTags;
    @property(nullable, nonatomic, strong, readwrite) V2NIMLocationInfo *locationInfo;
    
    @end
    
    macOS/Windows
    C++struct V2NIMSendChatroomMessageParams {
        V2NIMChatroomMessageConfig messageConfig;
        V2NIMMessageRouteConfig routeConfig;
        V2NIMMessageAntispamConfig antispamConfig;
        bool clientAntispamEnabled{false};
        nstd::string clientAntispamReplace;
        nstd::vector<nstd::string> receiverIds;
        nstd::string notifyTargetTags;
        nstd::optional<V2NIMLocationInfo> locationInfo;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMSendChatroomMessageParams = {
      messageConfig?: V2NIMChatroomMessageConfig
      routeConfig?: V2NIMMessageRouteConfig
      antispamConfig?: V2NIMMessageAntispamConfig
      clientAntispamEnabled?: boolean
      clientAntispamReplace?: string
      receiverIds?: string[]
      notifyTargetTags?: string
      locationInfo?: V2NIMLocationInfo
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMSendChatroomMessageParams = {
    
      messageConfig?: V2NIMChatroomMessageConfig
      routeConfig?: V2NIMMessageRouteConfig
      antispamConfig?: V2NIMMessageAntispamConfig
      clientAntispamEnabled?: boolean
      clientAntispamReplace?: string
      receiverIds?: string[]
      notifyTargetTags?: string
      locationInfo?: V2NIMLocationInfo
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    messageConfig V2NIMChatroomMessageConfig - 聊天室消息相关配置。
    routeConfig V2NIMMessageRouteConfig - 消息事件抄送相关配置。
    antispamConfig V2NIMMessageAntispamConfig - 消息反垃圾相关配置,包括本地反垃圾或安全通配置,均需要在 网易云信控制台开通
    clientAntispamEnabled boolean false 是否启用本地反垃圾。
  • 仅对文本消息生效
  • 如果开启本地发垃圾,发送消息时会进行本地反垃圾检测,完成后返回检测结果 V2NIMClientAntispamOperatorType
    • 0:检测通过,可以发送该消息。
    • 1:发送替换后的文本消息。
    • 2:检测不通过,消息发送失败,返回本地错误码。
    • 3:消息发送后,由服务端拦截
  • clientAntispamReplace String clientAntispamEnabled 为 true 则必填 "" 反垃圾命中后替换的文本。
    receiverIds List<String> null 定向消息接收者账号列表,最多支持指定 100 个接收者。
    若该字段不为空,则表示该消息为聊天室定向消息,不在服务端进行存储
    notifyTargetTags String null 消息接收通知的标签,请参考 标签表达式
    locationInfo V2NIMLocationInfo null 消息空间位置信息配置。

    V2NIMSendChatroomMessageResult

    聊天室消息发送成功结果回包。

    Android
    Javapublic interface V2NIMSendChatroomMessageResult {
    
        V2NIMChatroomMessage getMessage();
    
        String getAntispamResult();
    
        V2NIMClientAntispamResult getClientAntispamResult();
    }
    
    iOS
    Objective-C@interface V2NIMSendChatroomMessageResult: NSObject <NSCopying>
    @property(nullable,nonatomic,strong,readonly) V2NIMChatroomMessage *message;
    @property(nullable,nonatomic,strong,readonly) NSString *antispamResult;
    @property(nullable,nonatomic,strong,readonly) V2NIMClientAntispamResult *clientAntispamResult;
    @end
    
    macOS/Windows
    C++struct V2NIMSendChatroomMessageResult {
        V2NIMChatroomMessage message;
        nstd::string antispamResult;
        nstd::optional<V2NIMClientAntispamResult> clientAntispamResult;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMSendChatroomMessageResult = {
      message: V2NIMChatroomMessage
      antispamResult?: string
      clientAntispamResult?: V2NIMClientAntispamResult
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMSendChatroomMessageResult = {
    
      message: V2NIMChatroomMessage
      antispamResult?: string
      clientAntispamResult?: V2NIMClientAntispamResult
    }
    

    成员参数

    名称 类型 是否只读 说明
    message V2NIMChatroomMessage 聊天室消息对象。
    antispamResult String 安全通反垃圾检测结果。
    clientAntispamResult V2NIMClientAntispamResult 本地反垃圾结果。

    V2NIMChatroomMemberQueryOption

    聊天室成员分页查询选项。

    Android
    Javapublic class V2NIMChatroomMemberQueryOption {
    
        public List<V2NIMChatroomMemberRole> getMemberRoles() {
            return memberRoles;
        }
    
        public boolean isOnlyBlocked() {
            return Boolean.TRUE.equals(onlyBlocked);
        }
    
        public boolean isOnlyChatBanned() {
            return Boolean.TRUE.equals(onlyChatBanned);
        }
    
        public boolean isOnlyOnline() {
            return Boolean.TRUE.equals(onlyOnline);
        }
    
        public String getPageToken() {
            if(pageToken == null){
                return "";
            }
            return pageToken;
        }
    
        public int getLimit() {
            if(limit == null){
                return 100;
            }
            return limit;
        }
    
        public void setMemberRoles(List<V2NIMChatroomMemberRole> memberRoles) {
            this.memberRoles = memberRoles;
        }
    
        public void setOnlyBlocked(boolean onlyBlocked) {
            this.onlyBlocked = onlyBlocked;
        }
    
        public void setOnlyChatBanned(boolean onlyChatBanned) {
            this.onlyChatBanned = onlyChatBanned;
        }
    
        public void setOnlyOnline(boolean onlyOnline) {
            this.onlyOnline = onlyOnline;
        }
    
        public void setPageToken(String pageToken) {
            this.pageToken = pageToken;
        }
    
        public void setLimit(int limit) {
            this.limit = limit;
        }
    
        public boolean isValid() {
            if (getLimit() <= 0) {
                return false;
            }
            if (memberRoles != null && memberRoles.contains(null)) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMemberQueryOption: NSObject <NSCopying>
    @property (nullable, nonatomic, strong) NSArray *memberRoles;
    @property (nonatomic, assign) BOOL onlyBlocked;
    @property (nonatomic, assign) BOOL onlyChatBanned;
    @property (nonatomic, assign) BOOL onlyOnline;
    @property (nullable, nonatomic, copy) NSString *pageToken;
    @property (nonatomic, assign) NSInteger limit;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMemberQueryOption {
        nstd::vector<V2NIMChatroomMemberRole> memberRoles;
        bool onlyBlocked{false};
        bool onlyChatBanned{false};
        bool onlyOnline{false};
        nstd::string pageToken;
        uint32_t limit{V2NIM_DEFAULT_CHATROOM_QUERY_LIMIT};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomMemberQueryOption = {
      memberRoles?: V2NIMChatroomMemberRole[]
      onlyBlocked?: boolean
      onlyChatBanned?: boolean
      onlyOnline?: boolean
      pageToken: string
      limit: number
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomMemberQueryOption = {
    
      memberRoles?: V2NIMChatroomMemberRole[]
      onlyBlocked?: boolean
      onlyChatBanned?: boolean
      onlyOnline?: boolean
      pageToken: string
      limit: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    memberRoles List<V2NIMChatroomMemberRole> - 聊天室成员类型。如果不设置或为空则表示查询所有类型的成员。
    onlyBlocked boolean false 是否只返回黑名单成员:
  • true:仅黑名单成员
  • false:全部成员。
  • onlyChatBanned boolean false 是否只返回聊天禁言成员列表:
  • true:仅聊天禁言成员
  • false:全部成员。
  • onlyOnline boolean false 是否只返回在线的固定成员(创建者、管理员、普通成员):
  • true:仅在线的固定成员
  • false:全部成员。
  • pageToken String "" 分页偏移,首次查询传空,下一次查询传入上一次查询返回值中的 nextToken
    limit int 100 单次查询聊天室成员最大数量。不建议超过 200,设置小于等于 0 则默认为 200。

    V2NIMChatroomMemberListResult

    分页获取聊天室成员列表返回结果。

    Android
    Javapublic interface V2NIMChatroomMemberListResult {
        String getPageToken();
    
        boolean isFinished();
    
        List<V2NIMChatroomMember> getMemberList();
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMemberListResult: NSObject<NSCopying>
    @property (nonnull, nonatomic, copy, readonly) NSString *pageToken;
    @property (nonatomic, assign, readonly) BOOL finished;
    @property (nonnull, nonatomic, copy, readonly) NSArray *memberList;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMemberListResult {
        nstd::string pageToken;
        bool finished{false};
        nstd::vector<V2NIMChatroomMember> memberList;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomMemberListResult = {
      pageToken: string
      finished: boolean
      memberList: V2NIMChatroomMember
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomMemberListResult = {
    
      pageToken: string
      finished: boolean
      memberList: V2NIMChatroomMember
    }
    

    成员参数

    名称 类型 是否只读 说明
    pageToken String 分页偏移。
    finished boolean 群成员是否全部获取:
  • true:已全部获取
  • false:未全部获取,可以继续获取。
  • memberList List<V2NIMChatroomMember> 分页获取的聊天室成员列表。

    V2NIMChatroomMessageListOption

    聊天室历史消息分页查询选项。

    Android
    Javapublic class V2NIMChatroomMessageListOption {
        public V2NIMChatroomMessageListOption() {
        }
    
        public V2NIMChatroomMessageListOption(V2NIMMessageQueryDirection direction, List<V2NIMMessageType> messageTypes, long beginTime, int limit) {
            this.direction = direction;
            this.messageTypes = messageTypes;
            this.beginTime = beginTime;
            this.limit = limit;
        }
    
        public V2NIMMessageQueryDirection getDirection() {
            if (direction == null) {
                return V2NIMMessageQueryDirection.V2NIM_QUERY_DIRECTION_DESC;
            } else {
                return direction;
            }
        }
    
        public List<V2NIMMessageType> getMessageTypes() {
            return messageTypes;
        }
    
        public long getBeginTime() {
            if (beginTime == null) {
                return 0;
            }
            return beginTime;
        }
    
        public int getLimit() {
            if (limit == null) {
            return 100;
            }
            return limit;
        }
    
        public void setDirection(V2NIMMessageQueryDirection direction) {
            this.direction = direction;
        }
    
        public void setMessageTypes(List<V2NIMMessageType> messageTypes) {
            this.messageTypes = messageTypes;
        }
    
        public void setBeginTime(long beginTime) {
            this.beginTime = beginTime;
        }
    
        public void setLimit(int limit) {
            this.limit = limit;
        }
    
        public boolean isValid() {
            if (messageTypes != null && messageTypes.contains(null)) {
                return false;
            }
            if (getLimit() <= 0) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMessageListOption: NSObject
    @property (nonatomic, assign) V2NIMQueryDirection direction;
    @property (nullable, nonatomic, strong) NSArray *messageTypes;
    @property (nonatomic, assign) NSTimeInterval beginTime;
    @property (nonatomic, assign) NSInteger limit;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMessageListOption {
        V2NIMQueryDirection direction{V2NIM_QUERY_DIRECTION_DESC};
        nstd::vector<V2NIMMessageType> messageTypes;
        uint64_t beginTime{0};
        uint32_t limit{V2NIM_DEFAULT_CHATROOM_QUERY_LIMIT};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomMessageListOption = {
      direction?: V2NIMQueryDirection
      messageTypes?: V2NIMMessageType[]
      beginTime?: number
      limit?: number
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomMessageListOption = {
    
      direction?: V2NIMQueryDirection
      messageTypes?: V2NIMMessageType[]
      beginTime?: number
      limit?: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    messageTypes List<V2NIMMessageType> null 消息类型,为 null 或空列表则表示查询所有消息类型。
    仅支持 0:文本,1:图片,2:语音,3:视频,4:地理位置,5:通知,6:文件,10:提示,11:Robot,100:自定义,其它为非法参数。
    beginTime long 0 查询开始时间(毫秒)。首次查询传 0,下一次查询传入上一次查询返回值中的 beginTime
    limit int 100 本次查询条数上限,取值范围为 [0,200]。传入小于 0 则默认为 100。
    direction V2NIMQueryDirection V2NIM_QUERY_DIRECTION_DESC 时间降序 查询方向(查询结果方向):按照时间升序或降序。

    V2NIMChatroomMemberRoleUpdateParams

    聊天室成员角色更新参数。

    Android
    Javapublic class V2NIMChatroomMemberRoleUpdateParams {
        public V2NIMChatroomMemberRoleUpdateParams() {
        }
    
        public V2NIMChatroomMemberRoleUpdateParams(V2NIMChatroomMemberRole memberRole, Integer memberLevel, String notificationExtension) {
            this.memberRole = memberRole;
            this.memberLevel = memberLevel;
            this.notificationExtension = notificationExtension;
        }
    
        public V2NIMChatroomMemberRole getMemberRole() {
            return memberRole;
        }
    
        public Integer getMemberLevel() {
            return memberLevel;
        }
    
        public String getNotificationExtension() {
            return notificationExtension;
        }
    
        public void setMemberRole(V2NIMChatroomMemberRole memberRole) {
            this.memberRole = memberRole;
        }
    
        public void setMemberLevel(int memberLevel) {
            this.memberLevel = memberLevel;
        }
    
        public void setNotificationExtension(String notificationExtension) {
            this.notificationExtension = notificationExtension;
        }
    
        public boolean isValid() {
            if (memberRole == null | |
                    memberRole == V2NIMChatroomMemberRole.V2NIM_CHATROOM_MEMBER_ROLE_CREATOR | |
                    memberRole == V2NIMChatroomMemberRole.V2NIM_CHATROOM_MEMBER_ROLE_ANONYMOUS_GUEST | |
                    memberRole == V2NIMChatroomMemberRole.V2NIM_CHATROOM_MEMBER_ROLE_VIRTUAL) {
                return false;
            }
            if (memberLevel != null && memberLevel < 0) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomMemberRoleUpdateParams: NSObject
    @property (nonatomic, assign) V2NIMChatroomMemberRole memberRole;
    @property (nonatomic, assign) NSInteger memberLevel;
    @property (nullable, nonatomic, copy) NSString *notificationExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomMemberRoleUpdateParams {
        V2NIMChatroomMemberRole memberRole{V2NIM_CHATROOM_MEMBER_ROLE_NORMAL};
        nstd::optional<uint32_t> memberLevel;
        nstd::optional<nstd::string> notificationExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomMemberRoleUpdateParams = {
      memberRole: V2NIMChatroomMemberRole
      memberLevel?: number
      notificationExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomMemberRoleUpdateParams = {
    
      memberRole: V2NIMChatroomMemberRole
      memberLevel?: number
      notificationExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    memberRole V2NIMChatroomMemberRole - 聊天室成员角色类型:
  • 仅聊天室创建者有操作权限:将普通游客、普通成员设置为管理员或反之。
  • 聊天室管理员和创建者均有操作权限:将普通成员设置为普通游客或反之。
  • 不允许操作虚构用户和匿名游客,否则产生报错。
  • memberLevel int 0,表示未设置 聊天室成员等级,大于或等于 0 的整数。
    notificationExtension String null 聊天室成员角色变更通知的扩展字段。

    V2NIMChatroomUpdateParams

    聊天室信息更新参数。

    Android
    Javapublic class V2NIMChatroomUpdateParams {
    
        public V2NIMChatroomUpdateParams() {
        }
    
        public String getRoomName() {
            return roomName;
        }
    
        public String getAnnouncement() {
            return announcement;
        }
    
        public String getLiveUrl() {
            return liveUrl;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        public boolean isNotificationEnabled() {
            if (notificationEnabled == null) {
                return true;
            } else {
                return notificationEnabled;
            }
        }
    
        public String getNotificationExtension() {
            return notificationExtension;
        }
    }
    
        public void setRoomName(String roomName) {
         this.roomName = roomName;
        }
    
        public void setAnnouncement(String announcement) {
         this.announcement = announcement;
        }
    
        public void setLiveUrl(String liveUrl) {
            this.liveUrl = liveUrl;
        }
    
        public void setServerExtension(String serverExtension) {
            this.serverExtension = serverExtension;
        }
    
        public void setNotificationEnabled(boolean notificationEnabled) {
            this.notificationEnabled = notificationEnabled;
        }
    
        public void setNotificationExtension(String notificationExtension) {
            this.notificationExtension = notificationExtension;
        }
    
        public boolean isValid() {
            if(roomName != null && roomName.isEmpty()){
                return false;
            }
            if(roomName != null){
                return true;
            }
            if(announcement != null){
                return true;
            }
            if(liveUrl != null){
                return true;
            }
            if(serverExtension != null){
                return true;
            }
            return false;
            }
        }
    
    iOS
    Objective-C@interface V2NIMChatroomUpdateParams: NSObject
    @property (nullable, nonatomic, copy) NSString *roomName;
    @property (nullable, nonatomic, copy) NSString *announcement;
    @property (nullable, nonatomic, copy) NSString *liveUrl;
    @property (nullable, nonatomic, copy) NSString *serverExtension;
    @property (nonatomic, assign) BOOL notificationEnabled;
    @property (nullable, nonatomic, copy) NSString *notificationExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomUpdateParams {
        nstd::optional<nstd::string> roomName;
        nstd::optional<nstd::string> announcement;
        nstd::optional<nstd::string> liveUrl;
        nstd::optional<nstd::string> serverExtension;
        bool notificationEnabled{true};
        nstd::string notificationExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomUpdateParams {
      roomName?: string;
      announcement?: string;
      liveUrl?: string;
      serverExtension?: string;
      notificationEnabled?: boolean;
      notificationExtension?: string;
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomUpdateParams {
    
      roomName?: string
      announcement?: string
      liveUrl?: string
      serverExtension?: string
      notificationEnabled?: boolean
      notificationExtension?: string
    }
    

    成员参数

    • 以下参数必须设置其一,否则返回参数错误。
    • 如果您的应用平台为 Android,则需要调用对应的成员函数获取对应参数。
    名称 类型 是否必填 说明
    roomName String 聊天室名称。设置为空表示不更新该字段,不可设置为 "",否则返回参数错误。
    announcement String 聊天室公告。设置为空表示不更新该字段。
    liveUrl String 视频直播拉流地址。设置为空表示不更新该字段。
    serverExtension String 聊天室服务端扩展字段。必须为 JSON 格式封装,长度上限为 4096 字节,多端同步。
    设置为空表示不更新该字段。
    notificationEnabled boolean 否,默认 true 操作后是否需要通知。
    notificationExtension String 聊天室信息变更通知的扩展字段。

    V2NIMChatroomSelfMemberUpdateParams

    聊天室成员更新本人信息参数。

    Android
    Javapublic class V2NIMChatroomSelfMemberUpdateParams {
    
        public V2NIMChatroomSelfMemberUpdateParams() {
        }
    
        public String getRoomNick() {
            return roomNick;
        }
    
        public String getRoomAvatar() {
            return roomAvatar;
        }
    
        public String getServerExtension() {
            return serverExtension;
        }
    
        public boolean isNotificationEnabled() {
            if (notificationEnabled == null) {
                return true;
            }
            return notificationEnabled;
        }
    
        public String getNotificationExtension() {
            return notificationExtension;
        }
    
        public boolean isPersistence() {
            if (persistence == null) {
                return false;
            }
            return persistence;
        }
    
        public void setRoomNick(String roomNick) {
            this.roomNick = roomNick;
        }
    
        public void setRoomAvatar(String roomAvatar) {
            this.roomAvatar = roomAvatar;
        }
    
        public void setServerExtension(String serverExtension) {
            this.serverExtension = serverExtension;
        }
    
        public void setNotificationEnabled(boolean notificationEnabled) {
            this.notificationEnabled = notificationEnabled;
        }
    
        public void setNotificationExtension(String notificationExtension) {
            this.notificationExtension = notificationExtension;
        }
    
        public void setPersistence(boolean persistence) {
            this.persistence = persistence;
        }
    
        public boolean isValid() {
            if (roomNick != null && roomNick.isEmpty()) {
                return false;
            }
            if (roomNick != null) {
                return true;
            }
            if (roomAvatar != null) {
                return true;
            }
            if (serverExtension != null) {
                return true;
            }
            return false;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomSelfMemberUpdateParams: NSObject
    @property (nullable, nonatomic, copy) NSString *roomNick;
    @property (nullable, nonatomic, copy) NSString *roomAvatar;
    @property (nullable, nonatomic, copy) NSString *serverExtension;
    @property (nonatomic, assign) BOOL notificationEnabled;
    @property (nullable, nonatomic, copy) NSString *notificationExtension;
    @property (nonatomic, assign) BOOL persistence;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomSelfMemberUpdateParams {
        nstd::optional<nstd::string> roomNick;
        nstd::optional<nstd::string> roomAvatar;
        nstd::optional<nstd::string> serverExtension;
        bool notificationEnabled{true};
        nstd::string notificationExtension;
        bool persistence{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomSelfMemberUpdateParams = {
      roomNick?: string
      roomAvatar?: string
      serverExtension?: string
      notificationEnabled?: boolean
      notificationExtension?: string
      persistence?: boolean
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomSelfMemberUpdateParams = {
    
      roomNick?: string
      roomAvatar?: string
      serverExtension?: string
      notificationEnabled?: boolean
      notificationExtension?: string
      persistence?: boolean
    }
    
    

    成员参数

    • 以下参数必须设置其一,否则返回参数错误。
    • 如果您的应用平台为 Android,则需要调用对应的成员函数获取对应参数。
    名称 类型 是否只读 默认值 说明
    roomNick String - 聊天室中显示昵称。设置为空表示不更新该字段,不可设置为 "",否则返回参数错误。
    roomAvatar String - 聊天室中显示头像。设置为空表示不更新该字段。
    serverExtension String - 聊天室成员服务端扩展字段,多端同步。建议 JSON 格式,长度上限为 2048。
    设置为空表示不更新该字段。
    notificationEnabled boolean true 操作后是否需要通知。
    notificationExtension String - 操作后通知的扩展字段。
    persistence String false 更新信息是否持久化,即是否将数据保存在本地数据库中。

    V2NIMChatroomTagTempChatBannedParams

    聊天室标签用户临时禁言参数。

    Android
    Javapublic class V2NIMChatroomTagTempChatBannedParams {
    
        public V2NIMChatroomTagTempChatBannedParams() {
        }
    
        public String getTargetTag() {
            return targetTag;
        }
    
        public String getNotifyTargetTags() {
            return notifyTargetTags;
        }
    
        public int getDuration() {
            if (duration == null) {
                return 0;
            }
            return duration;
        }
    
        public boolean isNotificationEnabled() {
            if (notificationEnabled == null) {
                return true;
            }
            return notificationEnabled;
        }
    
        public String getNotificationExtension() {
            return notificationExtension;
        }
    
        public void setTargetTag(String targetTag) {
            this.targetTag = targetTag;
        }
    
        public void setNotifyTargetTags(String notifyTargetTags) {
            this.notifyTargetTags = notifyTargetTags;
        }
    
        public void setDuration(int duration) {
            this.duration = duration;
        }
    
        public void setNotificationEnabled(boolean notificationEnabled) {
            this.notificationEnabled = notificationEnabled;
        }
    
        public void setNotificationExtension(String notificationExtension) {
            this.notificationExtension = notificationExtension;
        }
    
        public boolean isValid() {
            if (TextUtils.isEmpty(targetTag)) {
                return false;
            }
            if (duration != null && duration < 0) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomTagTempChatBannedParams: NSObject
    @property (nonnull, nonatomic, copy) NSString *targetTag;
    @property (nonnull, nonatomic, copy) NSString *notifyTargetTags;
    @property (nonatomic, assign) NSUInteger duration;
    @property (nonatomic, assign) BOOL notificationEnabled;
    @property (nullable, nonatomic, copy) NSString *notificationExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomTagTempChatBannedParams {
        nstd::string targetTag;
        nstd::string notifyTargetTags;
        uint64_t duration{0};
        bool notificationEnabled{true};
        nstd::string notificationExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomTagTempChatBannedParams {
      targetTag: string
      notifyTargetTags: string
      duration: number
      notificationEnabled: boolean
      notificationExtension: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomTagTempChatBannedParams {
    
      targetTag: string
      notifyTargetTags: string
      duration: number
      notificationEnabled: boolean
      notificationExtension: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    targetTag String - 被操作者标签。
    notifyTargetTags String - 操作后通知的标签,请参考 标签表达式
    duration long 0,表示取消临时禁言 临时禁言时长(秒)
    notificationEnabled boolean true 操作后是否需要通知。
    notificationExtension String - 操作后通知的扩展字段。

    V2NIMChatroomTagsUpdateParams

    聊天室标签信息更新参数。

    Android
    Javapublic class V2NIMChatroomTagsUpdateParams {
    
        public V2NIMChatroomTagsUpdateParams() {
        }
    
        public List<String> getTags() {
            return tags;
        }
    
        public String getNotifyTargetTags() {
            return notifyTargetTags;
        }
    
        public boolean isNotificationEnabled() {
            if (notificationEnabled == null) {
                return true;
            }
            return notificationEnabled;
        }
    
        public String getNotificationExtension() {
            return notificationExtension;
        }
    
        public void setTags(List<String> tags) {
            this.tags = tags;
        }
    
        public void setNotifyTargetTags(String notifyTargetTags) {
            this.notifyTargetTags = notifyTargetTags;
        }
    
        public void setNotificationEnabled(boolean notificationEnabled) {
            this.notificationEnabled = notificationEnabled;
        }
    
        public void setNotificationExtension(String notificationExtension) {
            this.notificationExtension = notificationExtension;
        }
    
        public boolean isValid(){
            if (tags == null && notifyTargetTags == null) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomTagsUpdateParams: NSObject
    @property (nullable, nonatomic, copy) NSArray<NSString *> *tags;
    @property (nullable, nonatomic, copy) NSString *notifyTargetTags;
    @property (nonatomic, assign) BOOL notificationEnabled;
    @property (nullable, nonatomic, copy) NSString *notificationExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomTagsUpdateParams {
        nstd::optional<nstd::vector<nstd::string>> tags;
        nstd::optional<nstd::string> notifyTargetTags;
        bool notificationEnabled{true};
        nstd::string notificationExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMChatroomtagsUpdateParams {
      tags?: string[]
      notifyTargetTags?: string
      notificationEnabled?: boolean
      notificationExtension?: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMChatroomtagsUpdateParams {
    
      tags?: string[]
      notifyTargetTags?: string
      notificationEnabled?: boolean
      notificationExtension?: string
    }
    

    成员参数

    tagsnotifyTargetTags 必须设置其一,否则返回参数错误。

    名称 类型 是否必填 说明
    tags List<String> 聊天室标签信息。
    设置为空表示不更新,设置为 [] 表示清空原有标签。
    notifyTargetTags String 操作后通知的标签信息,标签表达式请参考 聊天室标签管理
    设置为空表示不更新,设置为 "" 表示清空原有通知标签信息。
    notificationEnabled boolean 否,默认 true 操作后是否需要通知。
    notificationExtension String 操作后通知的扩展字段。

    V2NIMChatroomTagMemberOption

    聊天室标签成员查询选项。

    Android
    Javapublic class V2NIMChatroomTagMemberOption {
    
        public V2NIMChatroomTagMemberOption() {
        }
    
        public V2NIMChatroomTagMemberOption(String tag, String pageToken, Integer limit) {
            this.tag = tag;
            this.pageToken = pageToken;
            this.limit = limit;
        }
    
        public String getTag() {
            return tag;
        }
    
        public String getPageToken() {
            if(pageToken == null){
                return "";
            }
            return pageToken;
        }
    
        public int getLimit() {
            if (limit == null) {
                return 100;
            }
            return limit;
        }
    
        public void setTag(String tag) {
            this.tag = tag;
        }
    
        public void setPageToken(String pageToken) {
            this.pageToken = pageToken;
        }
    
        public void setLimit(int limit) {
            this.limit = limit;
        }
    
        public boolean isValid(){
            if (TextUtils.isEmpty(tag)) {
                return false;
            }
            if (limit != null && limit <= 0) {
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomTagMemberOption: NSObject
    @property (nonnull, nonatomic, copy) NSString *tag;
    @property (nonatomic, copy) NSString *pageToken;
    @property (nonatomic, assign) NSInteger limit;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomTagMemberOption {
        nstd::string tag;
        nstd::string pageToken;
        uint32_t limit{V2NIM_DEFAULT_CHATROOM_QUERY_LIMIT};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomTagMemberOption = {
      tag: string
      pageToken?: number
      limit?: number
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomTagMemberOption = {
    
      tag: string
      pageToken?: number
      limit?: number
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    tag String - 聊天室标签信息。
    pageToken String "" 分页偏移,首次查询传空,下一次查询传入上一次查询返回值中的 nextToken
    limit int 100 单次查询最大数量。必须大于 0,否则返回参数错误。

    V2NIMChatroomTagMessageOption

    按标签分页查询聊天室消息选项。

    Android
    Javapublic class V2NIMChatroomTagMessageOption {
    
        public List<String> getTags() {
            return tags;
        }
    
        public List<V2NIMMessageType> getMessageTypes() {
            return messageTypes;
        }
    
        public long getBeginTime() {
            if (beginTime == null) {
                return 0;
            }
            return beginTime;
        }
    
        public long getEndTime() {
            if (endTime == null) {
                return 0;
            }
            return endTime;
        }
    
        public Integer getLimit() {
            if (limit == null) {
                return 100;
            }
            return limit;
        }
    
        public V2NIMMessageQueryDirection getDirection() {
            if(direction == null){
                return V2NIMMessageQueryDirection.V2NIM_QUERY_DIRECTION_DESC;
            }
            return direction;
        }
    
        public void setTags(List<String> tags) {
            this.tags = tags;
        }
    
        public void setMessageTypes(List<V2NIMMessageType> messageTypes) {
            this.messageTypes = messageTypes;
        }
    
        public void setBeginTime(Long beginTime) {
            this.beginTime = beginTime;
        }
    
        public void setEndTime(Long endTime) {
            this.endTime = endTime;
        }
    
        public void setLimit(Integer limit) {
            this.limit = limit;
        }
    
        public void setDirection(V2NIMMessageQueryDirection direction) {
            this.direction = direction;
        }
    
        public boolean isValid() {
            if(CollectionUtil.isEmpty(tags)){
                return false;
            }
            if(getLimit() <= 0){
                return false;
            }
            if(getEndTime()> 0 && getBeginTime()> getEndTime()){
                return false;
            }
            if(messageTypes != null && messageTypes.contains(null)){
                return false;
            }
            return true;
        }
    }
    
    iOS
    Objective-C@interface V2NIMChatroomTagMessageOption: NSObject
    @property (nonnull, nonatomic, strong) NSArray *tags;
    @property (nullable, nonatomic, strong) NSArray *messageTypes;
    @property (nonatomic, assign) NSTimeInterval beginTime;
    @property (nonatomic, assign) NSTimeInterval endTime;
    @property (nonatomic, assign) NSInteger limit;
    @property (nonatomic, assign) V2NIMQueryDirection direction;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomTagMessageOption {
        nstd::vector<nstd::string> tags;
        nstd::vector<V2NIMMessageType> messageTypes;
        uint64_t beginTime{0};
        uint64_t endTime{0};
        uint32_t limit{V2NIM_DEFAULT_CHATROOM_QUERY_LIMIT};
        V2NIMQueryDirection direction{V2NIM_QUERY_DIRECTION_DESC};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomTagMessageOption = {
      tags?: string[]
      messageTypes?: V2NIMMessageType[]
      beginTime?: number
      endTime?: number
      limit?: number
      direction?: V2NIMQueryDirection
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomTagMessageOption = {
    
      messageTypes?: V2NIMMessageType[]
      beginTime?: number
      endTime?: number
      limit?: number
      direction?: V2NIMQueryDirection
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    tags List<String> - 聊天室标签信息。如果为空或 size 为 0,则返回参数错误。
    messageTypes List<V2NIMMessageType> null 消息类型,为 null 或空列表则表示查询所有消息类型。
    beginTime long 0 查询开始时间。该字段必须小于等于 endTime
    endTime long 0 查询结束时间。该字段必须大于等于 beginTime,默认为系统当前时间。
    direction V2NIMQueryDirection V2NIM_QUERY_DIRECTION_DESC 查询方向(查询结果方向):按照时间升序或降序。
    limit int 100 本次查询条数上限。必须大于 0,否则返回 191004 参数错误。

    V2NIMChatroomClientListener

    聊天室实例监听器。

    调用 addChatroomClientListener 注册聊天室实例监听后,当相关事件发生时,会返回对应回调。

    Android
    Javapublic interface V2NIMChatroomClientListener {
    
        void onChatroomStatus(V2NIMChatroomStatus status,V2NIMError error);
        void onChatroomEntered();
        void onChatroomExited(V2NIMError error);
        void onChatroomKicked(V2NIMChatroomKickedInfo kickedInfo);
    }
    
    iOS
    Objective-C@protocol V2NIMChatroomClientListener <NSObject>
    
    @optional
    
    - (void)onChatroomStatus:(V2NIMChatroomStatus)status
                       error:(nullable V2NIMError *)error;
    
    - (void)onChatroomEntered;
    
    - (void)onChatroomExited:(nullable V2NIMError *)error;
    
    - (void)onChatroomKicked:(V2NIMChatroomKickedInfo *)kickedInfo;
    
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomClientListener {
        nstd::function<void(V2NIMChatroomStatus status, nstd::optional<V2NIMError> error)> onChatroomStatus;
        nstd::function<void()> onChatroomEntered;
        nstd::function<void(nstd::optional<V2NIMError> error)> onChatroomExited;
        nstd::function<void(V2NIMChatroomKickedInfo kickedInfo)> onChatroomKicked;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomClientListener = {
      onChatroomStatus: [status: V2NIMChatroomStatus, error?: V2NIMError]
      onChatroomEntered: []
      onChatroomExited: [error?: V2NIMError]
      onChatroomKicked: [kickedInfo: V2NIMChatroomKickedInfo]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomClientListener = {
    
      onChatroomStatus: [status: V2NIMChatroomStatus, error?: V2NIMError]
      onChatroomEntered: []
      onChatroomExited: [error?: V2NIMError]
      onChatroomKicked: [kickedInfo: V2NIMChatroomKickedInfo]
    }
    

    成员函数

    • onChatroomStatus

      聊天室状态变更回调。聊天室内所有成员均会收到该回调。

      参数名称 类型 说明
      status V2NIMChatroomStatus 聊天室状态信息
      error V2NIMError 错误信息。
    • onChatroomEntered

      进入聊天室回调。

    • onChatroomExited

      退出聊天室回调。退出聊天室后,不会继续重连。

      退出聊天室包括以下场景:

      • 账号变更后登录失败导致退出聊天室。
      • 被加入聊天室黑名单导致退出聊天室。
      • 由于账号被封禁导致退出聊天室。
      • 由于聊天室被关闭导致退出聊天室。
      参数名称 类型 说明
      error V2NIMError 错误信息
    • onChatroomKicked

      被踢出聊天室回调。
      被踢出聊天室后,会同时触发 onChatroomExited 回调。

      参数名称 类型 说明
      kickedInfo V2NIMChatroomKickedInfo 被踢详细信息

    V2NIMChatroomListener

    聊天室监听器。

    调用 addChatroomListener 注册聊天室监听后,当相关事件发生时,会返回对应回调。

    Android
    Javapublic interface V2NIMChatroomListener extends Serializable {
    
        void onSendMessage(V2NIMChatroomMessage message);
        void onReceiveMessages(List<V2NIMChatroomMessage> messages);
        void onChatroomMemberEnter(V2NIMChatroomMember member);
        void onChatroomMemberExit(String accountId);
        void onChatroomMemberRoleUpdated(V2NIMChatroomMemberRole previousRole, V2NIMChatroomMember member);
        void onChatroomMemberInfoUpdated(V2NIMChatroomMember member);
        void onSelfChatBannedUpdated(boolean chatBanned);
        void onSelfTempChatBannedUpdated(boolean tempChatBanned, long tempChatBannedDuration);
        void onChatroomInfoUpdated(V2NIMChatroomInfo chatroom);
        void onChatroomChatBannedUpdated(boolean chatBanned);
        void onMessageRevokedNotification(String messageClientId, long messageTime);
        void onChatroomTagsUpdated(List<String> tags);
    }
    
    iOS
    Objective-C@protocol V2NIMChatroomListener <NSObject>
    
    @optional
    - (void)onSendMessage:(V2NIMChatroomMessage *)message;
    - (void)onReceiveMessages:(NSArray *)messages;
    - (void)onChatroomMemberEnter:(V2NIMChatroomMember *)member;
    - (void)onChatroomMemberExit:(NSString *)accountId;
    - (void)onChatroomMemberRoleUpdated:(V2NIMChatroomMemberRole)previousRole
                                 member:(V2NIMChatroomMember *)member;
    - (void)onChatroomMemberInfoUpdated:(V2NIMChatroomMember *)member;
    - (void)onSelfChatBannedUpdated:(BOOL)chatBanned;
    - (void)onSelfTempChatBannedUpdated:(BOOL)tempChatBanned
                 tempChatBannedDuration:(NSInteger)tempChatBannedDuration;
    - (void)onChatroomInfoUpdated:(V2NIMChatroomInfo *)chatroomInfo;
    - (void)onChatroomChatBannedUpdated:(BOOL)chatBanned;
    - (void)onMessageRevokedNotification:(NSString *)messageClientId
                             messageTime:(NSTimeInterval)messageTime;
    - (void)onChatroomTagsUpdated:(NSArray<NSString *> *)tags;
    @end
    
    macOS/Windows
    C++struct V2NIMChatroomListener {
        nstd::function<void(nstd::vector<V2NIMChatroomMessage> messages)> onReceiveMessages;
        nstd::function<void(V2NIMChatroomMember member)> onChatroomMemberEnter;
        nstd::function<void(nstd::string accountId)> onChatroomMemberExit;
        nstd::function<void(V2NIMChatroomMemberRole previousRole, V2NIMChatroomMember member)> onChatroomMemberRoleUpdated;
        nstd::function<void(V2NIMChatroomMember member)> onChatroomMemberInfoUpdated;
        nstd::function<void(bool chatBanned)> onSelfChatBannedUpdated;
        nstd::function<void(bool tempChatBanned, uint64_t tempChatBannedDuration)> onSelfTempChatBannedUpdated;
        nstd::function<void(V2NIMChatroomInfo chatroomInfo)> onChatroomInfoUpdated;
        nstd::function<void(bool chatBanned)> onChatroomChatBannedUpdated;
        nstd::function<void(nstd::string messageClientId, uint64_t messageTime)> onMessageRevokedNotification;
        nstd::function<void(nstd::vector<nstd::string> tags)> onChatroomTagsUpdated;
        nstd::function<void(const V2NIMChatroomMessage &message)> 	onSendMessage;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMChatroomListener = {
    
      onSendMessage: [message: V2NIMChatroomMessage]
      onReceiveMessages: [messages: V2NIMChatroomMessage[]]
      onMessageRevokedNotification: [messageClientId: string, messageTime: number]
      onChatroomMemberEnter: [member: V2NIMChatroomMember]
      onChatroomMemberExit: [member: V2NIMChatroomMember]
      onChatroomMemberRoleUpdated: [previousRole: V2NIMChatroomMemberRole, currentMember: V2NIMChatroomMember]
      onChatroomMemberInfoUpdated: [member: V2NIMChatroomMember]
      onSelfChatBannedUpdated: [chatBanned: boolean]
      onSelfTempChatBannedUpdated: [tempChatBanned: boolean, tempChatBannedDuration: number]
      onChatroomInfoUpdated: [chatroomInfo: V2NIMChatroomInfo]
      onChatroomChatBannedUpdated: [chatBanned: boolean]
      onChatroomTagsUpdated: [tags: Array<string>]
    }
    
    HarmonyOS
    TypeScriptexport type V2NIMChatroomListener = {
    
      onSendMessage: [message: V2NIMChatroomMessage]
      onReceiveMessages: [messages: V2NIMChatroomMessage[]]
      onMessageRevokedNotification: [messageClientId: string, messageTime: number]
      onChatroomMemberEnter: [member: V2NIMChatroomMember]
      onChatroomMemberExit: [member: V2NIMChatroomMember]
      onChatroomMemberRoleUpdated: [previousRole: V2NIMChatroomMemberRole, currentMember: V2NIMChatroomMember]
      onChatroomMemberInfoUpdated: [member: V2NIMChatroomMember]
      onSelfChatBannedUpdated: [chatBanned: boolean]
      onSelfTempChatBannedUpdated: [tempChatBanned: boolean, tempChatBannedDuration: number]
      onChatroomInfoUpdated: [chatroomInfo: V2NIMChatroomInfo]
      onChatroomChatBannedUpdated: [chatBanned: boolean]
      onChatroomTagsUpdated: [tags: Array<string>]
    }
    

    成员函数

    • onSendMessage

      本端发送聊天室消息状态回调,本端发送聊天室消息或插入聊天室消息成功后,SDK 会返回该回调。

      参数名称 类型 说明
      message V2NIMChatroomMessage 发送或插入的聊天室消息
    • onReceiveMessages

      聊天室消息接收回调,本端接收到消息,或其他端同步的消息时会触发该回调。

      参数名称 类型 说明
      messages List<V2NIMChatroomMessage> 聊天室消息列表
    • onChatroomInfoUpdated

      聊天室资料信息更新回调。聊天室内所有成员均会收到该回调。

      参数名称 类型 说明
      chatroomInfo V2NIMChatroomInfo 更新后的聊天室信息
    • onChatroomMemberEnter

      成员进入聊天室回调。聊天室内所有成员均会收到该回调。

      参数名称 类型 说明
      member V2NIMChatroomMember 聊天室成员信息,只包含账号、昵称、禁言状态信息。
    • onChatroomMemberExit

      成员退出聊天室回调。聊天室内所有成员均会收到该回调。

      参数名称 类型 说明
      accountId String 退出的聊天室成员账号
    • onChatroomMemberRoleUpdated

      聊天室成员角色类型变更回调。聊天室内所有成员均会收到该回调。

      参数名称 类型 说明
      previousRole V2NIMChatroomMemberRole 变更前的角色类型信息
      member V2NIMChatroomMember 聊天室成员信息
    • onChatroomMemberInfoUpdated

      聊天室成员信息变更回调。聊天室内所有成员均会收到该回调。

      参数名称 类型 说明
      member V2NIMChatroomMember 聊天室成员信息,只包含昵称、头像、扩展字段
    • onSelfChatBannedUpdated

      聊天室成员本人禁言状态变更回调。

      参数名称 类型 说明
      chatBanned boolean 是否处于禁言状态
    • onSelfTempChatBannedUpdated

      聊天室成员本人临时禁言状态变更回调。

      参数名称 类型 说明
      tempChatBanned boolean 是否处于临时禁言状态
      tempChatBannedDuration long 临时禁言时长(秒)
    • onChatroomChatBannedUpdated

      聊天室整体禁言状态变更回调。

      参数名称 类型 说明
      chatBanned boolean 聊天室是否处于禁言状态:
    • true:处于禁言状态,仅创建者和管理员能发言
    • false:非禁言状态,聊天室全员都可以发言
    • onMessageRevokedNotification

      聊天室消息撤回回调。

      参数名称 类型 说明
      messageClientId String 被撤回消息的客户端 ID
      messageTime long 被撤回消息的时间戳
    • onChatroomTagsUpdated

      聊天室标签信息变更回调。

      参数名称 类型 说明
      tags List<String> 更新后的标签信息

    V2NIMUploadFileTask

    文件上传任务。

    Android
    Javapublic interface V2NIMUploadFileTask {
    
        String getTaskId();
    
        V2NIMUploadFileParams getUploadFileParams();
    }
    
    iOS
    Objective-C@interface V2NIMUploadFileTask : NSObject
    @property (nonatomic,strong) NSString *taskId;
    @property (nonatomic,strong) V2NIMUploadFileParams *uploadParams;
    @end
    
    macOS/Windows
    C++struct V2NIMUploadFileTask {
        nstd::string taskId;
        V2NIMUploadFileParams uploadParams;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMUploadFileTask {
      taskId: string
      uploadParams: V2NIMUploadFileParams
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMUploadFileTask {
    
      taskId: string
      uploadParams: V2NIMUploadFileParams
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    taskId String - 任务 ID
    uploadParams V2NIMUploadFileParams - 文件上传参数。

    V2NIMUploadFileParams

    文件上传任务。

    Android
    Javapublic class V2NIMUploadFileParams {
    
        public V2NIMUploadFileParams() {
            this.filePath = null;
            this.sceneName = null;
        }
    
        public V2NIMUploadFileParams(String filePath) {
            this.filePath = filePath;
            this.sceneName = null;
        }
    
        public V2NIMUploadFileParams(String filePath, String sceneName) {
            this.filePath = filePath;
            this.sceneName = sceneName;
        }
    
        public String getFilePath() {
            return filePath;
        }
    
        public String getSceneName() {
            if (TextUtils.isEmpty(sceneName)) {
                return V2NIMStorageSceneConfig.DEFAULT_PROFILE.getSceneName();
            }
            return sceneName;
        }
    
        public boolean isValid() {
            return filePath != null && !filePath.isEmpty();
        }
    
    }
    
    iOS
    Objective-C@interface V2NIMUploadFileParams : NSObject
    @property (nonatomic,strong) NSString *filePath;
    @property (nonatomic,strong) NSString *sceneName;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUploadFileParams {
        nstd::string filePath;
        nstd::string sceneName;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMUploadFileParams {
      fileObj: File | string
    
      sceneName: string
    }
    
    HarmonyOS
    TypeScriptexport interface V2NIMUploadFileParams {
    
      filePath: string
      sceneName: string
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    filePath String 非 Web 端必填 - 文件地址。
    fileObj String/File 仅 Web 端必填 -
  • 非小程序:File 对象
  • 小程序:File 对象或文件地址。
  • sceneName String DEFAULT_PROFILE 对应场景名,默认为 nim_default_profile_icon 场景名。
    使用自定义场景前,需要先调用 V2NIMStorageService.addCustomStorageScene 新增自定义场景名。

    V2NIMClientAntispamUtil

    客户端本地反垃圾工具。

    成员函数

    • checkTextAntispam

      对输入的文本进行本地反垃圾检查,根据反垃圾配置规则返回不同的内容。

      • 请在登录 IM 后调用该函数。
      • 本地有缓存数据(除 Web),支持以当前状态进行检测。
      • 参数说明
      Android
      Javapublic static V2NIMClientAntispamResult checkTextAntispam(String text, String replace)
      
      参数名称 类型 是否必填 默认值 说明
      text String - 待本地反垃圾检测的文本。
      replace String null 检测到的敏感内容替换词。
      iOS
      Objective-C+ (V2NIMClientAntispamUtil *)checkTextAntispam:(NSString *)text
                                        replace:(nullable NSString *)replace;
      
      参数名称 类型 是否必填 默认值 说明
      text NSString * - 待本地反垃圾检测的文本。
      replace NSString * null 检测到的敏感内容替换词。
      macOS/Windows
      C++static V2NIMClientAntispamResult checkTextAntispam(nstd::string text, nstd::string replace);
      
      参数名称 类型 是否必填 默认值 说明
      text nstd::string - 待本地反垃圾检测的文本。
      replace nstd::string null 检测到的敏感内容替换词。
      Web/uni-app/小程序
      TypeScriptcheckTextAntispam(text: string, replace?: string): V2NIMClientAntispamResult
      
      参数名称 类型 是否必填 默认值 说明
      text string - 待本地反垃圾检测的文本。
      replace string null 检测到的敏感内容替换词。
      • 示例代码
      Android
      JavaV2NIMClientAntispamResult res = V2NIMClientAntispamUtil.checkTextAntispam('bad sentense', '***')
      
      iOS
      Objective-CV2NIMClientAntispamResult *res = [V2NIMClientAntispamUtil checkTextAntispam:@"bad sentense" replace:@"***"];
      
      macOS/Windows
      C++auto result = V2NIMClientAntispamUtil::checkTextAntispam("spam text", "*");
      
      Web/uni-app/小程序
      TypeScriptconst res = nim.V2NIMClientAntispamUtil.checkTextAntispam('bad sentense', '***')
      

      返回值:V2NIMClientAntispamResult

    V2NIMAntispamConfig

    若需要使用反垃圾检测,但不使用网易云信安全通默认配置,则需要通过该类定制审核规则。

    成员参数

    名称 类型 是否必填 默认值 说明
    antispamBusinessId String - 指定易盾业务 ID。样例:JSON 格式 {"textbid":"","picbid":""}

    NIMSDKOption(仅 iOS)

    初始化配置选项。

    Objective-C@interface NIMSDKOption : NSObject
    @property (nonatomic,copy)          NSString    *appKey;
    @property (nullable,nonatomic,copy) NSString    *apnsCername;
    @property (nullable,nonatomic,copy) NSString    *pkCername;
    + (instancetype)optionWithAppKey:(NSString *)appKey;
    @end
    

    类方法

    注册网易云信应用 AppKey。

    Objective-C+ (instancetype)optionWithAppKey:(NSString *)appKey;
    

    成员参数

    名称 类型 是否必填 说明
    appKey NSString 网易云信控制台获取到的 App Key。
    apnsCername NSString APNs 推送证书名,如不需要实现离线推送可不配置。
    pkCername NSString PushKit 推送证书名,如不需要实现离线推送可不配置。

    V2NIMSDKOption(仅 iOS)

    V10 初始化配置选项。

    Objective-C@interface V2NIMSDKOption : NSObject
    @property(nonatomic,assign,readwrite) BOOL useV1Login;
    @end
    

    成员参数

    名称 类型 是否必填 说明
    useV1Login BOOL 是否在开启 V10 API 后,仍使用 V9 的登录 API 登录 IM。
  • 默认 NO,即开启 V10 API 后需要使用 V10 的登录 API 登录 IM。
  • 设置为 YES,则开启 V10 API 后仍需要使用 V9 的登录 API 登录 IM。V9 和 V10 版本的登录 API 无法同时使用,只能选择其一。
  • V2NIMInitOption(仅 macOS/Windows)

    V10 初始化配置选项。

    C++struct V2NIMInitOption {
        nstd::string appkey;
        nstd::string appDataPath;
        V2NIMBasicOption basicOption;
        V2NIMLinkOption linkOption;
        V2NIMDatabaseOption databaseOption;
        V2NIMFCSOption fcsOption;
        nstd::optional<V2NIMPrivateServerOption> privateServerOption;
    };
    

    成员参数

    名称 类型 是否必填 说明
    appkey nstd::string 网易云信应用的 AppKey。
    appDataPath nstd::string 应用的数据目录,为空则使用默认目录。
    默认数据:
  • Windows:%localappdata%/NIM
  • macOS:~/Library/Application Support/NIM
  • Linux:~/.local/share/NIM
  • basicOption V2NIMBasicOption 基础配置。
    linkOption V2NIMLinkOption 连接相关配置。
    databaseOption V2NIMDatabaseOption 数据库配置。
    fcsOption V2NIMFCSOption 融合存储配置。
    privateServerOption nstd::optional<V2NIMPrivateServerOption> 私有化配置。

    V2NIMUpdatedTeamInfo

    群信息更新。

    Android
    Javapublic interface V2NIMUpdatedTeamInfo extends Serializable {
    
        String getName();
    
        Integer getMemberLimit();
    
        String getIntro();
    
        String getAnnouncement();
    
        String getAvatar();
    
        String getServerExtension();
    
        V2NIMTeamJoinMode getJoinMode();
    
        V2NIMTeamAgreeMode getAgreeMode();
    
        V2NIMTeamInviteMode getInviteMode();
    
        V2NIMTeamUpdateInfoMode getUpdateInfoMode();
    
        V2NIMTeamUpdateExtensionMode getUpdateExtensionMode();
    
        V2NIMTeamChatBannedMode getChatBannedMode();
    }
    
    iOS
    Objective-C@interface V2NIMUpdatedTeamInfo : NSObject
    
    /// 群组名称,nil 表示未更新
    @property(nullable,nonatomic,copy,readonly) NSString *name;
    
    /// 群组人数上限,0 表示未更新
    @property(nonatomic,assign,readonly) NSInteger memberLimit;
    
    /// 群组介绍,nil 表示未更新
    @property(nullable,nonatomic,copy,readonly) NSString *intro;
    
    /// 群组公告,nil 表示未更新
    @property(nullable,nonatomic,copy,readonly) NSString *announcement;
    
    /// 群组头像,nil 表示未更新
    @property(nullable,nonatomic,copy,readonly) NSString *avatar;
    
    /// 服务端扩展字段,nil 表示未更新
    @property(nullable,nonatomic,copy,readonly) NSString *serverExtension;
    
    /// 申请入群模式,-1 表示未更新
    @property(nonatomic,assign,readonly) V2NIMTeamJoinMode joinMode;
    
    /// 被邀请人同意入群模式,-1 表示未更新
    @property(nonatomic,assign,readonly) V2NIMTeamAgreeMode agreeMode;
    
    /// 邀请入群模式,-1 表示未更新
    @property(nonatomic,assign,readonly) V2NIMTeamInviteMode inviteMode;
    
    /// 群组资料修改模式,-1 表示未更新
    @property(nonatomic,assign,readonly) V2NIMTeamUpdateInfoMode updateInfoMode;
    
    /// 群组扩展字段修改模式,-1 表示未更新
    @property(nonatomic,assign,readonly) V2NIMTeamUpdateExtensionMode updateExtensionMode;
    
    /// 群组禁言状态,-1 表示未更新
    @property(nonatomic,assign,readonly) V2NIMTeamChatBannedMode chatBannedMode;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUpdatedTeamInfo {
        nstd::optional<nstd::string> name;
        nstd::optional<uint32_t> memberLimit;
        nstd::optional<nstd::string> intro;
        nstd::optional<nstd::string> announcement;
        nstd::optional<nstd::string> avatar;
        nstd::optional<nstd::string> serverExtension;
        nstd::optional<V2NIMTeamJoinMode> joinMode;
        nstd::optional<V2NIMTeamAgreeMode> agreeMode;
        nstd::optional<V2NIMTeamInviteMode> inviteMode;
        nstd::optional<V2NIMTeamUpdateInfoMode> updateInfoMode;
        nstd::optional<V2NIMTeamUpdateExtensionMode> updateExtensionMode;
        V2NIMTeamChatBannedMode chatBannedMode{V2NIM_TEAM_CHAT_BANNED_MODE_NONE};
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMUpdatedTeamInfo = {
      name?: string
      memberLimit?: number
      intro?: string
      announcement?: string
      avatar?: string
      serverExtension?: string
      joinMode?: V2NIMTeamJoinMode
      agreeMode?: V2NIMTeamAgreeMode
      inviteMode?: V2NIMTeamInviteMode
      updateInfoMode?: V2NIMTeamUpdateInfoMode
      updateExtensionMode?: V2NIMTeamUpdateExtensionMode
      chatBannedMode?: V2NIMTeamChatBannedMode
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    name String - 群组名称
  • 若为空,则表示不修改该字段
  • 若为空串,返回参数错误。
  • memberLimit int - 群组人数上限。若为空,则表示不修改。
  • 高级群:默认 200 人/群(免费),可通过 网易云信控制台配置为 500/1000/2000 人/群(计费),最大可扩展至 5000 人/群(联系商务经理或技术支持)。
  • 超大群:默认 2000 人/群,可通过网易云信控制台 配置为 2000-10000 人/群。
  • 2000 人以上的群必须由服务端 API 发起创建。
  • intro String - 群组介绍,最大为 255 个字符。
    若为空,则表示不修改该字段。
    announcement String - 群组公告,最大为 5000 个字符。
    若为空,则表示不修改该字段。
    avatar String - 群组头像
    若为空,则表示不修改该字段。
    serverExtension String - 群组服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。
    若为空,则表示不修改该字段。
    joinMode V2NIMTeamJoinMode V2NIMTeamJoinMode.V2NIM_TEAM_JOIN_MODE_FREE 无需验证 入群验证模式。
    agreeMode V2NIMTeamAgreeMode V2NIMTeamAgreeMode.V2NIM_TEAM_AGREE_MODE_AUTH 需要被邀请人同意 被邀请人同意模式。
    inviteMode V2NIMTeamInviteMode V2NIMTeamInviteMode.V2NIM_TEAM_INVITE_MODE_MANAGER 仅群主或管理员可以邀请其他人入群 群组邀请模式,即群主/管理员或普通成员可以邀请入群。
    updateInfoMode V2NIMTeamUpdateInfoMode V2NIMTeamUpdateInfoMode.V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组资料修改模式。
    updateExtensionMode V2NIMTeamUpdateExtensionMode V2NIMTeamUpdateExtensionMode.V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER 仅群主或管理员可以修改群组资料 群组扩展字段修改模式。
    chatBannedMode V2NIMTeamChatBannedMode V2NIM_TEAM_CHAT_BANNED_MODE_NONE 不禁言 群组禁言状态。
    名称 类型 是否必填 默认值 说明
    alias String null 好友备注,长度上限 128 字符。
    name String null 用户昵称。
    teamNick String null 群组内昵称。
    avatar String "" 用户头像图片地址,长度上限 1024 字节。

    V2NIMSubscribeUserStatusOption

    订阅用户状态的配置参数。

    Android
    Javapublic class V2NIMSubscribeUserStatusOption {
    
      private static final String TAG = "V2NIMSubscribeUserStatusOption";
      private final List<String> accountIds;
      private static final int MAX_ACCOUNT_IDS_SIZE = 100;
      private long duration = 60L;
      private static final long MIN_DURATION = 60L;
      private static final long MAX_DURATION = 2592000L;
      private boolean immediateSync = false;
      private V2NIMSubscribeUserStatusOption() {
       this.accountIds = null;
      }
    
      public V2NIMSubscribeUserStatusOption(List<String> accountIds) {
       this.accountIds = accountIds;
      }
    
      public V2NIMSubscribeUserStatusOption(List<String> accountIds, long duration, boolean immediateSync) {
       this.accountIds = accountIds;
       this.duration = duration;
       this.immediateSync = immediateSync;
      }
    
      public List<String> getAccountIds() {
       return accountIds;
      }
    
      public long getDuration() {
       return duration;
      }
    
      public void setDuration(long duration) {
       this.duration = duration;
      }
    
      public boolean isImmediateSync() {
       return immediateSync;
      }
    
      public void setImmediateSync(boolean immediateSync) {
       this.immediateSync = immediateSync;
      }
    
      public boolean isValid(){
       if(accountIds == null || accountIds.isEmpty()){
        NimLog.i(TAG, "subscribeUserStatus accountIds is empty");
        return false;
       }
       if(accountIds.size() > MAX_ACCOUNT_IDS_SIZE){
        NimLog.i(TAG, "subscribeUserStatus accountIds size is invalid");
        return false;
       }
       if(duration < MIN_DURATION || duration > MAX_DURATION){
        NimLog.i(TAG, "subscribeUserStatus duration is invalid");
        return false;
       }
       return true;
      }
    }
    
    iOS
    Objective-C@interface V2NIMSubscribeUserStatusOption : NSObject
    
    @property(nonatomic,copy) NSArray<NSString *> * _Nonnull accountIds;
    
    @property(nonatomic,assign) NSInteger duration;
    
    @property(nonatomic,assign) BOOL immediateSync;
    
    @end
    
    macOS/Windows
    C++struct V2NIMSubscribeUserStatusOption {
        nstd::vector<nstd::string> accountIds;
        uint32_t duration{V2NIM_DEFAULT_SUBSCRIBE_DURATION};
        bool immediateSync{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMSubscribeUserStatusOption {
    
      accountIds: Array<string>
    
      duration?: number
    
      immediateSync?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    accountIds List<String> - 订阅的成员列表,为空返回参数错误,单次订阅的数量不超过 100 个,超限则返回参数错误。
    duration Long 60s 订阅的有效期。
  • 时间范围为 60s ~ 2592000s(302460*60s)。
  • 过期后需要重新订阅。如果未过期的情况下重复订阅,新设置的有效期会覆盖之前的有效期。
  • immediateSync Boolean false 订阅后是否立即同步事件状态值。默认为 false,即不立即同步。若设置为 true,表示立即同步当前状态值。但为了性能考虑,30s 内重复订阅,会忽略该参数。

    V2NIMUserStatus

    用户状态对象。

    Android
    Javapublic class V2NIMUserStatus {
    
      private final String accountId;
      private final Integer statusType;
      private final V2NIMLoginClientType clientType;
      private final Long publishTime;
      private String uniqueId;
      private String extension;
      private String serverExtension;
    
      private V2NIMUserStatus() {
        this.accountId = null;
        this.statusType = null;
        this.clientType = null;
        this.publishTime = null;
        this.uniqueId = null;
        this.extension = null;
        this.serverExtension = null;
      }
    
      public V2NIMUserStatus(String accountId, int statusType, V2NIMLoginClientType clientType, long publishTime){
       this(accountId, statusType, clientType, publishTime, null, null, null);
      }
    
      public V2NIMUserStatus(String accountId, int statusType, V2NIMLoginClientType clientType, long publishTime, String uniqueId, String extension, String serverExtension) {
       this.accountId = accountId;
        this.statusType = statusType;
        this.clientType = clientType;
        this.publishTime = publishTime;
        this.uniqueId = uniqueId;
        this.extension = extension;
        this.serverExtension = serverExtension;
      }
    
      public String getAccountId() {
       return accountId;
      }
    
      public int getStatusType() {
       if (statusType == null) {
        return 0;
       }
       return statusType;
      }
    
      public V2NIMLoginClientType getClientType() {
       return clientType;
      }
    
      public long getPublishTime() {
       if (publishTime == null) {
        return 0L;
       }
       return publishTime;
      }
    
      public String getUniqueId() {
       return uniqueId;
      }
    
      public void setUniqueId(String uniqueId) {
       this.uniqueId = uniqueId;
      }
    
      public String getExtension() {
       return extension;
      }
    
      public void setExtension(String extension) {
       this.extension = extension;
      }
    
      public String getServerExtension() {
       return serverExtension;
      }
    
      public void setServerExtension(String serverExtension) {
       this.serverExtension = serverExtension;
      }
    
      @Override
      public String toString() {
       final StringBuilder sb = new StringBuilder("V2NIMUserStatus{");
       if(NimLog.isDebuggable()){
        sb.append("accountId='").append(accountId).append('\'');
        sb.append(", statusType=").append(statusType);
        sb.append(", clientType=").append(clientType);
        sb.append(", publishTime=").append(publishTime);
        sb.append(", uniqueId='").append(uniqueId).append('\'');
        sb.append(", extension='").append(extension).append('\'');
        sb.append(", serverExtension='").append(serverExtension).append('\'');
       }else{
        sb.append("accountId='").append(accountId).append('\'');
        sb.append(", statusType=").append(statusType);
        sb.append(", clientType=").append(clientType);
        sb.append(", publishTime=").append(publishTime);
       }
       sb.append('}');
       return sb.toString();
      }
    
      /**
       * V2NIMUserStatus构造器
       */
      public static final class Builder {
        private final String accountId;
        private final int statusType;
        private final V2NIMLoginClientType clientType;
        private final long publishTime;
        private String uniqueId;
        private String extension;
        private String serverExtension;
    
        public Builder(String accountId, int statusType, V2NIMLoginClientType clientType, long publishTime) {
        this.accountId = accountId;
          this.statusType = statusType;
          this.clientType = clientType;
          this.publishTime = publishTime;
        }
    
        public Builder uniqueId(String uniqueId) {
          this.uniqueId = uniqueId;
          return this;
        }
    
        public Builder extension(String extension) {
          this.extension = extension;
          return this;
        }
    
        public Builder serverExtension(String serverExtension) {
          this.serverExtension = serverExtension;
          return this;
        }
    
        public V2NIMUserStatus build() {
          return new V2NIMUserStatus(accountId, statusType, clientType, publishTime, uniqueId, extension, serverExtension);
        }
      }
    }
    
    iOS
    Objective-C@interface V2NIMUserStatus : NSObject
    
    @property(nonatomic,copy,readonly) NSString * _Nonnull accountId;
    
    @property(nonatomic,assign,readonly) V2NIMUserStatusType statusType;
    
    @property(nonatomic,assign,readonly) V2NIMLoginClientType clientType;
    
    @property(nonatomic,assign,readonly) NSTimeInterval publishTime;
    
    @property(nonatomic,copy,nullable,readonly) NSString * uniqueId;
    
    @property(nonatomic,copy,nullable,readonly) NSString *extension;
    
    @property(nonatomic,copy,nullable,readonly) NSString *serverExtension;
    @end
    
    macOS/Windows
    C++struct V2NIMUserStatus {
        nstd::string accountId;
        uint32_t statusType{0};
        V2NIMLoginClientType clientType{V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN};
        time_t publishTime{0};
        nstd::optional<nstd::string> uniqueId;
        nstd::optional<uint32_t> duration;
        nstd::optional<nstd::string> extension;
        nstd::optional<nstd::string> serverExtension;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMUserStatus {
    
      accountId: string
    
      statusType: number
    
      clientType: V2NIMLoginClientType
    
      publishTime: number
    
      uniqueId?: number
    
      duration?: number
    
      extension?: string
    
      serverExtension?: string
    }
    

    成员参数

    名称 类型 是否必填 是否只读 默认值 说明
    accountId String - 用户账号 ID。
    statusType Int - 在线状态类型。0:未知;1:登录;2:登出;3:断开连接;自定义设置值:10000 及以上(9999 以内为预定义值,不可使用)。
    clientType V2NIMLoginClientType - 用户发布状态对应的终端。
    publishTime Long - 用户发布状态的时间,服务端时间。
    uniqueId String - 每次发布时,会生成一个唯一 ID, 发布自定义事件时会生成该参数,如果 ID 相同,表示同一个事件。
    extension String - 用户发布状态时设置的扩展字段。
    serverExtension String - 获取预留状态中的配置信息,JSONArray 格式,由服务端填入。

    V2NIMUnsubscribeUserStatusOption

    取消订阅用户状态的配置参数。

    Android
    Javapublic class V2NIMUnsubscribeUserStatusOption {
    
      private List<String> accountIds;
      private static final int MAX_ACCOUNT_IDS_SIZE = 100;
      public V2NIMUnsubscribeUserStatusOption() {
       this.accountIds = null;
      }
    
      public V2NIMUnsubscribeUserStatusOption(List<String> accountIds) {
       this.accountIds = accountIds;
      }
    
      public List<String> getAccountIds() {
       return accountIds;
      }
    
      public void setAccountIds(List<String> accountIds) {
       this.accountIds = accountIds;
      }
    
      public boolean isValid() {
       if(accountIds != null && accountIds.size() > MAX_ACCOUNT_IDS_SIZE) {
        NimLog.e("V2NIMUnsubscribeUserStatusOption", "accountIds size is invalid");
        return false;
       }
       return true;
      }
    }
    
    iOS
    Objective-C@interface V2NIMUnsubscribeUserStatusOption : NSObject
    
    @property(nonatomic,copy) NSArray<NSString *> * _Nullable accountIds;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUnsubscribeUserStatusOption {
        nstd::optional<nstd::vector<nstd::string>> accountIds;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMUnsubscribeUserStatusOption {
    
      accountIds: Array<string>
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    accountIds List<String> - 取消订阅的成员列表,为空则表示取消所有订阅的成员,否则取消指定的成员。单次取消订阅的数量不超过 100,超过返回 191004 错误。

    V2NIMCustomUserStatusParams

    自定义用户状态数据结构。

    Android
    Javapublic class V2NIMCustomUserStatusParams {
    
        private static final String TAG = "V2NIMCustomUserStatusParams";
        private final Integer statusType;
        private static final int MIN_STATUS_TYPE = 10000;
        private final Long duration;
        private static final long MIN_DURATION = 60L;
        private static final long MAX_DURATION = 604800L;
        private String extension;
        private boolean onlineOnly = true;
        private boolean multiSync = false;
    
        private V2NIMCustomUserStatusParams() {
            this.statusType = null;
            this.duration = 60L;
        }
    
        public V2NIMCustomUserStatusParams(int statusType, long duration) {
            this.statusType = statusType;
            this.duration = duration;
        }
    
        public int getStatusType() {
            if (this.statusType == null) {
                return 0;
            }
            return this.statusType;
        }
    
        public long getDuration() {
            return this.duration;
        }
    
        public String getExtension() {
            return this.extension;
        }
    
        public void setExtension(String extension) {
            this.extension = extension;
        }
    
        public boolean isOnlineOnly() {
            return this.onlineOnly;
        }
    
        public void setOnlineOnly(boolean onlineOnly) {
            this.onlineOnly = onlineOnly;
        }
    
        public boolean isMultiSync() {
            return this.multiSync;
        }
    
        public void setMultiSync(boolean multiSync) {
            this.multiSync = multiSync;
        }
    
        public boolean isValid(){
            if(statusType == null || statusType < MIN_STATUS_TYPE){
                NimLog.e(TAG, "statusType is invalid");
                return false;
            }
            if(duration == null || duration < MIN_DURATION || duration > MAX_DURATION){
                NimLog.e(TAG, "duration is invalid");
                return false;
            }
            return true;
        }
    
        public static class Builder {
    
            private int statusType;
            private long duration;
            private String extension;
            private boolean onlineOnly = true;
            private boolean multiSync = false;
            public Builder(int statusType, long duration) {
                this.statusType = statusType;
                this.duration = duration;
            }
            public Builder extension(String extension) {
                this.extension = extension;
                return this;
            }
            public Builder onlineOnly(boolean onlineOnly) {
                this.onlineOnly = onlineOnly;
                return this;
            }
            public Builder multiSync(boolean multiSync) {
                this.multiSync = multiSync;
                return this;
            }
    
            public V2NIMCustomUserStatusParams build() {
                V2NIMCustomUserStatusParams params = new V2NIMCustomUserStatusParams(statusType, duration);
                params.setExtension(extension);
                params.setOnlineOnly(onlineOnly);
                params.setMultiSync(multiSync);
                return params;
            }
        }
    }
    
    iOS
    Objective-C@interface V2NIMCustomUserStatusParams : NSObject
    
    @property(nonatomic,assign) int statusType;
    
    @property(nonatomic,assign) NSInteger duration;
    
    @property(nonatomic,assign,nullable) NSString *extension;
    
    @property(nonatomic,assign) BOOL onlineOnly;
    
    @property(nonatomic,assign) BOOL mulitSync;
    @end
    
    macOS/Windows
    C++struct V2NIMCustomUserStatusParams {
        uint32_t statusType{0};
        uint32_t duration{V2NIM_DEFAULT_SUBSCRIBE_DURATION};
        nstd::optional<nstd::string> extension;
        bool onlineOnly{true};
        bool multiSync{false};
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMCustomUserStatusParams {
    
      statusType: number
    
      duration?: number
    
      extension?: string
    
      onlineOnly?: boolean
    
      multiSync?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    statusType Int - 自定义状态设置值,10000 及以上(9999 以内为预定义值,不可使用)。若设置的值小于 10000 或超过 Int 上限,则返回参数错误。
    duration Long 60s 自定义状态的有效期,范围为 60s ~ 604800s(72460*60s)。
    extension String - 用户发布状态时设置的扩展字段。
    onlineOnly Boolean true 用户发布状态时是否只广播给在线的订阅者。
    multiSync Boolean false 用户发布状态时是否需要多端同步。

    V2NIMUserStatusSubscribeResult

    用户状态订阅的结果。

    Android
    Javapublic interface V2NIMUserStatusSubscribeResult {
    
        String getAccountId();
    
        long getDuration();
    
        long getSubscribeTime();
    }
    
    iOS
    Objective-C@interface V2NIMUserStatusSubscribeResult : NSObject
    
    @property(nonatomic,copy,readonly) NSString *accountId;
    
    @property(nonatomic,assign,readonly) NSInteger duration;
    
    @property(nonatomic,assign,readonly) NSTimeInterval subscribeTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMUserStatusSubscribeResult {
        nstd::string accountId;
        uint32_t duration;
        time_t subscribeTime;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMUserStatusSubscribeResult {
    
      accountId: string
    
      duration: number
    
      subscribeTime: number
    }
    

    成员参数

    名称 类型 是否必填 是否只读 默认值 说明
    accountId String - 查询的用户账号 ID。
    duration Long 60s 订阅的有效期,范围为 60s ~ 2592000s(302460*60s)。
    subscribeTime Long - 订阅时间。

    V2NIMCustomUserStatusPublishResult

    自定义用户状态发布的结果。

    Android
    Javapublic interface V2NIMCustomUserStatusPublishResult {
    
        String getUniqueId();
    
        String getServerId();
    
        long getPublishTime();
    }
    
    iOS
    Objective-C@interface V2NIMCustomUserStatusPublishResult : NSObject
    
    @property(nonatomic,copy,readonly) NSString *uniqueId;
    
    @property(nonatomic,copy,readonly) NSString *serverId;
    
    @property(nonatomic,assign,readonly) NSTimeInterval publishTime;
    
    @end
    
    macOS/Windows
    C++struct V2NIMCustomUserStatusPublishResult {
        nstd::string uniqueId;
        nstd::string serverId;
        time_t publishTime;
    };
    
    Web/uni-app/小程序
    TypeScriptexport interface V2NIMCustomUserStatusPublishResult {
    
      uniqueId: string
    
      serverId: string
    
      publishTime: number
    }
    

    成员参数

    名称 类型 是否必填 是否只读 默认值 说明
    uniqueId String - 发布自定义用户状态时内部生成的唯一 ID。
    serverId String - 服务器针对该状态事件生成的 ID。
    publishTime Long - 用户状态的发布时间。

    V2NIMSubscribeListener

    用户订阅相关监听器。

    Android
    Javapublic interface V2NIMSubscribeListener {
    
      void onUserStatusChanged(List<V2NIMUserStatus> userStatusList);
    }
    
    iOS
    Objective-C@protocol V2NIMSubscribeListener <NSObject>
    
    @optional
    
    - (void)onUserStatusChanged:(NSArray<V2NIMUserStatus *> *)data;
    
    @end
    
    macOS/Windows
    C++struct V2NIMSubscribeListener {
        nstd::function<void(const nstd::vector<V2NIMUserStatus>&)> onUserStatusChanged;
    };
    
    Web/uni-app/小程序
    TypeScriptexport type V2NIMSubscribeListener = {
    
      onUserStatusChanged: [userStatusList: Array<V2NIMUserStatus>]
    }
    

    成员函数

    • onUserStatusChanged

      其他用户的用户状态变更回调,包括在线状态和自定义状态。同账号发布状态时,多端也会同步收到回调。

      在线状态事件会受到推送的影响:
      如果应用被清理,但厂商推送(APNS、小米、华为、OPPO、VIVO、魅族、FCM)可达,则默认不会触发该用户断开连接的事件;若开发者需要该种情况下视为离线,请 前往网易云信控制台>选择应用>IM 即时通讯>功能配置>全局功能>在线状态订阅 进行设置。

      参数名称 类型 说明
      userStatusList List<V2NIMUserStatus> 用户状态列表

    V2NIMLocalConversationResult(仅 HarmonyOS)

    本地会话查询结果。

    HarmonyOS
    TypeScriptexport interface V2NIMLocalConversationResult {
    
      offset: number
    
      finished: boolean
    
      conversationList: V2NIMLocalConversation[]
    }
    

    成员参数

    名称 类型 是否只读 说明
    offset Number 分页偏移。首次调用传 0,后续调用时传入上一次调用返回的 offset
    finished Boolean 数据是否获取完毕:
  • true:获取完毕。
  • false:未获取完毕,需要继续调用方法获取。
  • conversationList V2NIMLocalConversation[] 本地会话对象列表。

    V2NIMLocalConversationOption(仅 HarmonyOS)

    本地会话查询选项。

    HarmonyOS
    TypeScriptexport interface V2NIMLocalConversationOption {
    
      conversationTypes?: V2NIMConversationType[]
    
      onlyUnread?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    conversationTypes V2NIMConversationType[] [] 或 null 需要指定的会话类型,null 表示不限制会话类型。
    onlyUnread Boolean false 是否仅查询包含未读数的会话:
  • true:仅查询包含未读数的本地会话。
  • false:查询所有本地会话。
  • V2NIMLocalConversationFilter(仅 HarmonyOS)

    本地会话过滤器对象。

    HarmonyOS
    TypeScriptexport interface V2NIMLocalConversationFilter {
    
      conversationTypes?: V2NIMConversationType[]
    
      ignoreMuted?: boolean
    }
    

    成员参数

    名称 类型 是否必填 默认值 说明
    conversationTypes V2NIMConversationType[] null 需要过滤的会话类型,null 表示不限制会话类型。
    ignoreMuted Boolean false 是否过滤具有免打扰属性(mutetrue)的本地会话对象:
  • true:过滤免打扰的本地会话。
  • false:不过滤免打扰的本地会话。
  • V2NIMLocalConversation(仅 HarmonyOS)

    本地会话对象。

    HarmonyOS
    TypeScriptexport interface V2NIMLocalConversation {
    
      conversationId: string
      type: V2NIMConversationType
      name?: string
      avatar?: string
      mute?: boolean
      stickTop: boolean
      localExtension?: string
      lastMessage?: V2NIMLastMessage
      unreadCount: number
      readTime: number
      sortOrder: number
      createTime: number
      updateTime: number
    }
    

    成员参数

    名称 类型 是否只读 默认值 说明
    conversationId String - 本地会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 本地会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    type V2NIMConversationType V2NIM_CONVERSATION_TYPE_UNKNOWN 本地会话类型。
    name Optional<String> null 本地会话名称。
  • 如果会话类型为单聊,则为聊天对象的用户名(好友备注/用户名称/用户账号)。
  • 如果会话类型为群组或超大群,则为群组名(群组名称/群组 ID)。
  • avatar Optional<String> null 本地会话头像。
  • 如果会话类型为单聊,则为聊天对象的头像。
  • 如果会话类型为群组或超大群,则为群组头像。
  • mute Optional<Boolean> null 本地会话是否为免打扰状态。
    stickTop Boolean false 本地会话是否为置顶状态。
    localExtension String "" 本地会话扩展字段,不会多端同步。长度上限为 1024 字节。
    lastMessage V2NIMLastMessage null 会话中最后一条消息。
    unreadCount Number 0 本地会话消息未读数。
    readTime Number 0 本地会话的未读消息计数时间戳。
    createTime Number 0 本地会话创建时间戳(毫秒)。
    updateTime Number 0 本地会话更新时间戳(毫秒)。
    sortOrder Number 0 本地会话排序字段。默认将置顶会话排首位,如有多条置顶会话,则按其创建时间进行排序。

    V2NIMLocalConversationOperationResult(仅 HarmonyOS)

    单条本地会话操作结果。

    HarmonyOS
    TypeScriptexport interface V2NIMLocalConversationOperationResult {
    
      conversationId: string
      error: V2NIMError
    }
    

    成员参数

    名称 类型 是否只读 说明
    conversationId String 操作失败的本地会话 ID。如果操作成功则为空。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType)| 聊天对象账号(accountId)或群组 ID。
    error V2NIMError 操作失败的错误码和错误信息,如果操作成功,则为空。

    V2NIMLocalConversationListener(仅 HarmonyOS)

    本地会话相关监听器。

    调用 on("EventName") 注册会话监听后,当会话相关事件发生时,会返回对应回调。

    HarmonyOS
    TypeScriptexport interface V2NIMLocalConversationListener extends NIMEBaseListener {
    
      onSyncStarted: []
      onSyncFinished: []
      onSyncFailed: [error: V2NIMError]
      onConversationCreated: [conversation: V2NIMLocalConversation]
      onConversationDeleted: [conversationIds: string[]]
      onConversationChanged: [conversationList: V2NIMLocalConversation[]]
      onTotalUnreadCountChanged: [unreadCount: number]
      onUnreadCountChangedByFilter: [
        filter: V2NIMLocalConversationUnreadCountChangedFilter,
        unreadCount: number
      ]
      onConversationReadTimeUpdated: [conversationId: string, readTime: number]
    }
    

    成员函数

    • onSyncStarted

      消息云端同步开始回调。

      建议在回调完成后操作数据,如果在此期间操作数据,会出现数据不全,只能操作部分数据的情况。

    • onSyncFinished

      消息云端同步结束回调。

      此回调后需要用户重新获取本地会话列表;回调后可任意操作相关的本地会话数据。请在收到该回调之后进行会话相关操作,否则可能导致会话数据不完整。

    • onSyncFailed

      消息云端同步失败回调。

      此回调后可以操作本地会话数据,但由于同步失败,本地只能操作已有数据,数据可能不全。在相关错误恢复后,SDK 会逐步按需重建会话数据。

      参数名称 类型 说明
      error V2NIMError 会话数据同步失败错误码及错误信息
    • onConversationCreated

      本地会话创建回调,返回创建的本地会话对象。

      当本端或多端同步主动创建本地会话成功时会触发该回调。

      参数名称 类型 说明
      conversation V2NIMLocalConversation 创建的本地会话对象。
    • onConversationDeleted

      本地会话删除回调,返回被删除的本地会话 ID 列表。

      当本端或多端同步主动删除本地会话成功时会触发该回调。

      参数名称 类型 说明
      conversationIds String[] 删除的本地会话 ID 列表。
    • onConversationChanged

      本地会话变更回调,返回变更后的会话列表。

      当本端或多端同步置顶会话、设置免打扰、会话有新消息、主动更新会话成功时会触发该回调。

      参数名称 类型 说明
      conversationList V2NIMLocalConversation[] 变更的本地会话对象列表
    • onTotalUnreadCountChanged

      本地会话消息总未读数变更回调,返回变更后的消息未读数。

      参数名称 类型 说明
      unreadCount int 变更后的会话消息总未读数
    • onUnreadCountChangedByFilter

      指定过滤条件的会话消息未读数变更,根据过滤条件返回变更后的消息未读数。

      调用 subscribeUnreadCountByFilter 订阅后,当会话过滤后的本地会话未读数变化时会返回该回调。

      参数名称 类型 说明
      filter V2NIMLocalConversationFilter 本地会话过滤对象
      unreadCount int 过滤后的本地会话消息未读数
    • onConversationReadTimeUpdated

      同一账号多端登录会话已读时间戳标记时间变更回调,返回同步标记的会话 ID 和标记的时间戳。

      当某一账号分别登录设备 A 和 B,A 的会话已读时间戳标记会同步到 B。

      参数名称 类型 说明
      conversationId String 同步标记的本地会话 ID
      readTime Number 标记的时间戳

    枚举

    V2NIMAIModelType

    数字人配置的 LLM(Large Language Models)模型类型。

    枚举类型 枚举值 说明
    V2NIM_AI_MODEL_TYPE_UNKNOW 0 未知。
    V2NIM_AI_MODEL_TYPE_QWEN 1 阿里云通义千问大模型。
    V2NIM_AI_MODEL_TYPE_AZURE 2 微软 Azure OpenAI。
    V2NIM_AI_MODEL_TYPE_PRIVATE 3 网易云信定制私有化本地大模型。

    V2NIMAIModelRoleType

    数字人请求的 LLM 大模型的角色类型。

    枚举类型 枚举值 说明
    V2NIM_AI_MODEL_ROLE_TYPE_SYSTEM system 系统。
    V2NIM_AI_MODEL_ROLE_TYPE_USER user 用户。
    V2NIM_AI_MODEL_ROLE_TYPE_ASSISTANT assistant 助手。

    V2NIMMessageAIStatus

    数字人收发的消息的询问和应答标识。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_AI_STATUS_UNKNOW 0 表示未知消息。
    V2NIM_MESSAGE_AI_STATUS_AT 1 表示是一个艾特数字人的消息。
    V2NIM_MESSAGE_AI_STATUS_RESPONSE 2 表示是数字人响应艾特的消息。

    V2NIMLoginStatus

    登录状态。

    枚举类型 枚举值 说明
    V2NIM_LOGIN_STATUS_LOGOUT 0 已登出。
    V2NIM_LOGIN_STATUS_LOGINED 1 已登录。
    V2NIM_LOGIN_STATUS_LOGINING 2 正在登录。
    V2NIM_LOGIN_STATUS_UNLOGIN 3 未登录。

    V2NIMLoginAuthType

    登录认证类型。请参考 登录方式概览

    枚举类型 枚举值 说明
    V2NIM_LOGIN_AUTH_TYPE_DEFAULT 0 静态 Token 登录。
    V2NIM_LOGIN_AUTH_TYPE_DYNAMIC_TOKEN 1 动态 Token 登录。
    V2NIM_LOGIN_AUTH_TYPE_THIRD_PARTY 2 通过第三方回调登录。

    V2NIMDataSyncLevel

    数据同步模式。

    Web 端仅支持完全同步。

    枚举类型 枚举值 说明
    V2NIM_DATA_SYNC_TYPE_LEVEL_FULL 0 全量同步。耗时较长,占用流量大,但数据展示时无需拉取。
    V2NIM_DATA_SYNC_TYPE_LEVEL_BASIC 1 基础数据同步。耗时较短,占用流量小,但数据展示时需要先拉取数据。

    V2NIMLoginClientType

    当前处于登录状态的客户端类型。

    枚举类型 枚举值 说明
    V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN 0 未知类型
    V2NIM_LOGIN_CLIENT_TYPE_ANDROID 1 Android
    V2NIM_LOGIN_CLIENT_TYPE_IOS 2 iOS
    V2NIM_LOGIN_CLIENT_TYPE_PC 4 PC
    V2NIM_LOGIN_CLIENT_TYPE_WINPHONE 8 Windows Phone
    V2NIM_LOGIN_CLIENT_TYPE_WEB 16 Web
    V2NIM_LOGIN_CLIENT_TYPE_RESTFUL 32 服务端
    V2NIM_LOGIN_CLIENT_TYPE_HarmonyOS_OS 65 鸿蒙

    V2NIMLoginClientChange

    客户端登录状态变更原因。

    枚举类型 枚举值 说明
    V2NIM_LOGIN_CLIENT_CHANGE_LIST 1 已登录客户端列表刷新。
    V2NIM_LOGIN_CLIENT_CHANGE_LOGIN 2 客户端登录。
    V2NIM_LOGIN_CLIENT_CHANGE_LOGOUT 3 客户端登出。

    V2NIMKickedOfflineReason

    当前登录的客户端被踢下线的原因类型。

    枚举类型 枚举值 说明
    V2NIM_KICKED_OFFLINE_REASON_CLIENT_EXCLUSIVE 1 被互斥的客户端踢下线。
    V2NIM_KICKED_OFFLINE_REASON_SERVER 2 被服务端踢下线。
    V2NIM_KICKED_OFFLINE_REASON_CLIENT 3 被其他客户端手动踢下线。

    V2NIMConnectStatus

    SDK 连接状态。您可以根据不同的状态进行界面提示相应的业务操作。

    枚举类型 枚举值 说明
    V2NIM_CONNECT_STATUS_DISCONNECTED 0 SDK 未连接服务端。
    V2NIM_CONNECT_STATUS_CONNECTED 1 SDK 已连接服务端。
    V2NIM_CONNECT_STATUS_CONNECTING 2 SDK 正在与服务端连接。
    V2NIM_CONNECT_STATUS_WAITING 3 SDK 正在等待与服务端重连。

    V2NIMDataSyncType

    数据同步类型:

    • 主数据:离线消息,漫游消息,用户信息,群信息,超大群信息等。
    • 群成员:高级群群成员。
    • 超大群成员:超大群群成员。
    枚举类型 枚举值 说明
    V2NIM_DATA_SYNC_MAIN 1 同步主数据。
    V2NIM_DATA_SYNC_TEAM_MEMBER 2 同步群成员。
    V2NIM_DATA_SYNC_SUPER_TEAM_MEMBER 3 同步超大群成员。

    V2NIMDataSyncState

    数据同步状态。

    枚举类型 枚举值 说明
    V2NIM_DATA_SYNC_STATE_WAITING 1 等待数据同步。
    V2NIM_DATA_SYNC_STATE_SYNCING 2 开始数据同步。
    V2NIM_DATA_SYNC_STATE_COMPLETED 3 数据同步完成。

    V2NIMConversationType

    会话类型。

    枚举类型 枚举值 说明
    V2NIM_CONVERSATION_TYPE_UNKNOWN 0 未知类型。
    V2NIM_CONVERSATION_TYPE_P2P 1 单聊(点对点)会话。
    V2NIM_CONVERSATION_TYPE_TEAM 2 高级群会话。
    V2NIM_CONVERSATION_TYPE_SUPER_TEAM 3 超大群会话。

    V2NIMMessageType

    消息类型。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_TYPE_INVALID -1 未知/不合法类型。
    V2NIM_MESSAGE_TYPE_TEXT 0 文本。
    V2NIM_MESSAGE_TYPE_IMAGE 1 图片。
    V2NIM_MESSAGE_TYPE_AUDIO 2 语音。
    V2NIM_MESSAGE_TYPE_VIDEO 3 视频。
    V2NIM_MESSAGE_TYPE_LOCATION 4 地理位置。
    V2NIM_MESSAGE_TYPE_NOTIFICATION 5 通知。
    V2NIM_MESSAGE_TYPE_FILE 6 文件。
    V2NIM_MESSAGE_TYPE_AVCHAT 7 音视频通话。
    V2NIM_MESSAGE_TYPE_TIPS 10 提示。
    V2NIM_MESSAGE_TYPE_ROBOT 11 机器人。
    V2NIM_MESSAGE_TYPE_CALL 12 话单。
    V2NIM_MESSAGE_TYPE_CUSTOM 100 自定义。

    V2NIMMessageAttachmentUploadState

    消息附件上传状态。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UNKNOWN 0 未知/不存在不需要上传。
    V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_SUCCEEDED 1 上传成功。
    V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_FAILED 2 上传失败。
    V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UPLOADING 3 正在上传。

    V2NIMMessageNotificationType

    通知消息类型。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE 0 邀请成员入高级群。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_KICK 1 高级群成员被踢出。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_LAVE 2 高级群成员退群。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_UPDATE_TINFO 3 高级群信息更新。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_DISMISS 4 高级群被解散。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_APPLY_PASS 5 进高级群申请通过。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_OWNER_TRANSFER 6 高级群主身份转移。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_ADD_MANAGER 7 添加高级群管理员。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_REMOVE_MANAGER 8 移除高级群管理员。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE_ACCEPT 9 接受邀请进高级群。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_BANNED_TEAM_MEMBER 10 禁言高级群成员。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE 401 超大群拉人。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_KICK 402 超大群踢人。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_LAVE 403 退出超大群。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_UPDATE_TINFO 404 更新超大群信息。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_DISMISS 405 超大群解散。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_APPLY_PASS 410 超大群申请加入通过。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_OWNER_TRANSFER 406 移交超大群主。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_ADD_MANAGER 407 添加超大群管理员。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_REMOVE_MANAGER 408 移除超大群管理员。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE_ACCEPT 411 接受邀请进超大群。
    V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_BANNED_TEAM_MEMBER 409 禁言超大群成员。

    V2NIMMessageSendingState

    消息发送状态。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_SENDING_STATE_UNKNOWN 0 未知状态。
    V2NIM_MESSAGE_SENDING_STATE_SUCCEEDED 1 消息发送成功。
    V2NIM_MESSAGE_SENDING_STATE_FAILED 2 消息发送失败。
    V2NIM_MESSAGE_SENDING_STATE_SENDING 3 消息正在发送。

    V2NIMClientAntispamOperateType

    客户端本地反垃圾命中后的操作类型。

    枚举类型 枚举值 说明
    V2NIM_CLIENT_ANTISPAM_OPERATE_NONE 0 无操作。
    V2NIM_CLIENT_ANTISPAM_OPERATE_REPLACE 1 本地替换。
    V2NIM_CLIENT_ANTISPAM_OPERATE_CLIENT_SHIELD 2 本地屏蔽。该文本消息无法发送。
    V2NIM_CLIENT_ANTISPAM_OPERATE_SERVER_SHIELD 3 服务端屏蔽。该文本消息发送后由服务器屏蔽。

    V2NIMQueryDirection

    消息查询方向。

    枚举类型 枚举值 说明
    V2NIM_QUERY_DIRECTION_DESC 0 按时间戳降序查询。
    V2NIM_QUERY_DIRECTION_ASC 1 按时间戳升序查询。

    V2NIMMessageRevokeType

    消息撤回类型。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_REVOKE_TYPE_UNDEFINED 0 未定义。
    V2NIM_MESSAGE_REVOKE_TYPE_P2P_BOTHWAY 1 单聊消息双向撤回,消息双方均收到撤回通知并清除消息。
    V2NIM_MESSAGE_REVOKE_TYPE_TEAM_BOTHWAY 2 群消息双向撤回,消息双方均收到撤回通知并清除消息。
    V2NIM_MESSAGE_REVOKE_TYPE_SUPER_TEAM_BOTHWAY 3 超大群消息双向撤回,消息双方均收到撤回通知并清除消息。
    V2NIM_MESSAGE_REVOKE_TYPE_P2P_ONEWAY 4 单聊消息单向撤回,发送方无感知,接收方收到撤回通知并清除消息。
    V2NIM_MESSAGE_REVOKE_TYPE_TEAM_ONEWAY 5 群消息单向撤回,发送方无感知,接收方收到撤回通知并清除消息。

    V2NIMMesssagePinState

    Pin 消息的状态。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_PIN_STEATE_NOT_PINNED 0 未 Pin
    V2NIM_MESSAGE_PIN_STEATE_PINNED 1 已 Pin
    V2NIM_MESSAGE_PIN_STEATE_UPDATED 2 已 Pin 状态更新。

    V2NIMMessagePinState

    Pin 消息的状态。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_PIN_STEATE_NOT_PINNED 0 未被 Pin
    V2NIM_MESSAGE_PIN_STEATE_PINNED 1 已被 Pin
    V2NIM_MESSAGE_PIN_STEATE_UPDATED 2 状态更新。

    V2NIMMessageQuickCommentType

    快捷评论操作类型。

    枚举类型 枚举值 说明
    V2NIM_MESSAGE_QUICK_COMMENT_TYPE_ADD 1 添加快捷评论。
    V2NIM_MESSAGE_QUICK_COMMENT_TYPE_REMOVE 2 移除快捷评论。

    V2NIMSortOrder

    排序规则。

    枚举类型 枚举值 说明
    V2NIM_SORT_ORDER_DESC 0 按时间戳降序排序。
    V2NIM_SORT_ORDER_ASC 1 按时间戳升序排序。

    V2NIMTeamType

    群组类型。

    枚举类型 枚举值 说明
    V2NIM_TEAM_TYPE_INVALID 0 无效类型。
    V2NIM_TEAM_TYPE_NORMAL 1 高级群。
    V2NIM_TEAM_TYPE_SUPER 2 超大群。

    V2NIMTeamJoinMode

    入群验证模式。

    枚举类型 枚举值 说明
    V2NIM_TEAM_JOIN_MODE_FREE 0 自由加入群组,无须验证。
    V2NIM_TEAM_JOIN_MODE_APPLY 1 需群主或管理员同意后加入群组。
    V2NIM_TEAM_JOIN_MODE_INVITE 2 私有群,不接受申请,仅能通过邀请方式入群。

    V2NIMTeamAgreeMode

    被邀请人同意模式。

    枚举类型 枚举值 说明
    V2NIM_TEAM_AGREE_MODE_AUTH 0 需要被邀请人同意。
    V2NIM_TEAM_AGREE_MODE_NO_AUTH 1 不需要被邀请人同意。

    V2NIMTeamInviteMode

    被邀请人同意模式。

    枚举类型 枚举值 说明
    V2NIM_TEAM_INVITE_MODE_MANAGER 0 仅群主或管理员可以邀请其他人入群。
    V2NIM_TEAM_INVITE_MODE_ALL 1 所有群成员都可以邀请其他人入群。

    V2NIMTeamUpdateInfoMode

    群组资料修改模式。

    枚举类型 枚举值 说明
    V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER 0 仅群主或管理员可以修改群组资料。
    V2NIM_TEAM_UPDATE_INFO_MODE_ALL 1 所有群成员都可以修改群组资料。

    V2NIMTeamChatBannedMode

    群组禁言状态。

    枚举类型 枚举值 说明
    V2NIM_TEAM_CHAT_BANNED_MODE_NONE 0 不禁言。
    V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL 1 普通成员禁言,不包括群主和管理员。
    V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_ALL 2 全员禁言,包括群主和管理员。全员禁言仅能由服务端 API 发起。

    V2NIMTeamUpdateExtensionMode

    群组扩展字段修改模式。

    枚举类型 枚举值 说明
    V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER 0 仅群主或管理员可以修改群组扩展字段。
    V2NIM_TEAM_UPDATE_EXTENSION_MODE_ALL 1 所有群成员都可以修改群组扩展字段。

    V2NIMTeamMemberRole

    群成员角色类型。

    枚举类型 枚举值 说明
    V2NIM_TEAM_MEMBER_ROLE_NORMAL 0 普通成员。
    V2NIM_TEAM_MEMBER_ROLE_OWNER 1 群主。
    V2NIM_TEAM_MEMBER_ROLE_MANAGER 2 群管理员。

    V2NIMTeamMemberRoleQueryType

    群成员角色查询类型。

    枚举类型 枚举值 说明
    V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_ALL 0 所有成员。
    V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_MANAGER 1 群主和群管理员。
    V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_NORMAL 2 普通成员。

    V2NIMTeamJoinActionType

    群成员入群操作类型。

    枚举类型 枚举值 说明
    V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION 0 (管理员身份)收到其他成员入群申请。
    V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_APPLICATION 1 收到管理员拒绝入群申请。
    V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION 2 收到入群邀请。
    V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION 3 (邀请人)收到被邀请人拒绝入群邀请。

    V2NIMTeamJoinActionStatus

    群成员入群操作处理状态。

    枚举类型 枚举值 说明
    V2NIM_TEAM_JOIN_ACTION_STATUS_INIT 0 未处理。
    V2NIM_TEAM_JOIN_ACTION_STATUS_AGREED 1 已同意。
    V2NIM_TEAM_JOIN_ACTION_STATUS_REJECTED 2 已拒绝。
    V2NIM_TEAM_JOIN_ACTION_STATUS_EXPIRED 3 已过期。

    V2NIMP2PMessageMuteMode

    单聊(点对点)消息免打扰模式。

    枚举类型 枚举值 说明
    V2NIM_P2P_MESSAGE_MUTE_MODE_OFF 0 单聊消息免打扰关闭。
    V2NIM_P2P_MESSAGE_MUTE_MODE_ON 1 单聊消息免打扰开启。

    V2NIMTeamMessageMuteMode

    群消息免打扰模式。

    枚举类型 枚举值 说明
    V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF 0 群消息免打扰关闭。
    V2NIM_TEAM_MESSAGE_MUTE_MODE_ON 1 群消息免打扰开启。
    V2NIM_TEAM_MESSAGE_MUTE_MODE_NORMAL_ON 2 普通成员群消息免打扰开启。

    V2NIMFriendAddMode

    添加好友模式。

    枚举类型 枚举值 说明
    V2NIM_FRIEND_MODE_TYPE_ADD 1 直接添加对方为好友,无需对方验证。
    V2NIM_FRIEND_MODE_TYPE_APPLY 2 请求添加对方为好友,需要对方验证通过。

    V2NIMFriendAddApplicationStatus

    申请添加好友相关操作状态。

    枚举类型 枚举值 说明
    V2NIM_FRIEND_ADD_APPLICATION_STATUS_INIT 0 未处理。
    V2NIM_FRIEND_ADD_APPLICATION_STATUS_AGREED 1 已同意。
    V2NIM_FRIEND_ADD_APPLICATION_STATUS_REJECED 2 已拒绝。
    V2NIM_FRIEND_ADD_APPLICATION_STATUS_EXPIRED 3 已过期。
    V2NIM_FRIEND_ADD_APPLICATION_STATUS_DIRECT_ADD 4 直接添加为好友。

    V2NIMFriendDeletionType

    好友删除的类型。

    枚举类型 枚举值 说明
    V2NIM_FRIEND_DELETION_TYPE_BY_SELF 1 自己删除好友。
    V2NIM_FRIEND_DELETION_TYPE_BY_PEER 2 对方删除好友。

    V2NIMChatroomQueueLevelMode

    聊天室队列操作权限。

    枚举类型 枚举值 说明
    V2NIM_CHATROOM_QUEUE_LEVEL_MODE_ANY 0 聊天室所有用户均有操作权限。
    V2NIM_CHATROOM_QUEUE_LEVEL_MODE_MANAGER 1 仅聊天室创建者/管理员有操作权限。

    V2NIMChatroomMemberRole

    聊天室成员角色类型:

    • 固定成员:创建者、管理员、普通成员。总计上限 1000 人。
    • 游客:普通游客、匿名游客。无人数上限。
    • 虚构成员:虚构用户。仅支持通过服务端 API 添加聊天室虚构用户
    枚举类型 枚举值 说明
    V2NIM_CHATROOM_MEMBER_ROLE_NORMAL 0 普通成员。
    V2NIM_CHATROOM_MEMBER_ROLE_CREATOR 1 创建者。
    V2NIM_CHATROOM_MEMBER_ROLE_MANAGER 2 管理员。
    V2NIM_CHATROOM_MEMBER_ROLE_NORMAL_GUEST 3 普通游客。
    V2NIM_CHATROOM_MEMBER_ROLE_ANONYMOUS_GUEST 4 匿名游客。
    V2NIM_CHATROOM_MEMBER_ROLE_VIRTUAL 5 虚构用户。

    V2NIMChatroomKickedReason

    被提出聊天室的原因。

    枚举类型 枚举值 说明
    V2NIM_CHATROOM_KICKED_REASON_UNKNOWN -1 未知。
    V2NIM_CHATROOM_KICKED_REASON_CHATROOM_INVALID 1 聊天室解散。
    V2NIM_CHATROOM_KICKED_REASON_BY_MANAGER 2 被管理员踢出。
    V2NIM_CHATROOM_KICKED_REASON_BY_CONFLICT_LOGIN 3 多端被踢。
    V2NIM_CHATROOM_KICKED_REASON_SILENTLY 4 静默被踢
    表示连接聊天室的 link 已作废,客户端不做重连(只有 Web 端才会有此场景)
    V2NIM_CHATROOM_KICKED_REASON_BE_BLOCKED 5 被拉入黑名单。

    V2NIMChatroomMessageNotificationType

    聊天室通知类消息类型。

    枚举类型 枚举值 说明
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_ENTER 0 成员进入聊天室。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_EXIT 1 成员退出聊天室。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_BLOCK_ADDED 2 聊天室成员被加入黑名单。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_BLOCK_REMOVED 3 聊天室成员被移除黑名单。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_CHAT_BANNED_ADDED 4 聊天室成员被禁言。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_CHAT_BANNED_REMOVED 5 聊天室成员被取消禁言。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_ROOM_INFO_UPDATED 6 聊天室信息更新。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_KICKED 7 聊天室成员被踢。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_TEMP_CHAT_BANNED_ADDED 8 聊天室成员被临时禁言。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_TEMP_CHAT_BANNED_REMOVED 9 聊天室成员被解除临时禁言。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_INFO_UPDATED 10 聊天室成员信息更新(nick/avatar/extension)
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_QUEUE_CHANGE 11 聊天室队列变更。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_CHAT_BANNED 12 聊天室处于禁言状态。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_CHAT_BANNED_REMOVED 13 聊天室处于非禁言状态。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAG_TEMP_CHAT_BANNED_ADDED 14 聊天室标签成员被临时禁言。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAG_TEMP_CHAT_BANNED_REMOVED 15 聊天室标签成员被解除临时禁言。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MESSAGE_REVOKE 16 聊天室消息撤回。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAGS_UPDATE 17 聊天室标签更新。
    V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_ROLE_UPDATE 18 聊天室成员角色更新。

    V2NIMChatroomStatus

    聊天室状态。

    枚举类型 枚举值 说明
    V2NIM_CHATROOM_STATUS_DISCONNECTED 0 聊天室断开连接。
    V2NIM_CHATROOM_STATUS_WAITING 1 聊天室等待重连。
    V2NIM_CHATROOM_STATUS_CONNECTING 2 聊天室连接过程中。
    V2NIM_CHATROOM_STATUS_CONNECTED 3 聊天室已连接。
    V2NIM_CHATROOM_STATUS_ENTERING 4 正在进入聊天室。
    V2NIM_CHATROOM_STATUS_ENTERED 5 已进入聊天室。
    V2NIM_CHATROOM_STATUS_EXITED 6 已退出聊天室。

    V2NIMDownloadAttachmentType

    下载附件的类型。

    枚举类型 枚举值 说明
    V2NIM_DOWNLOAD_ATTACHMENT_TYPE_SOURCE 0 原始资源,支持全部有附件的类型。
    V2NIM_DOWNLOAD_ATTACHMENT_TYPE_THUMBNAIL 1 图片缩略图,仅支持图片类附件。
    V2NIM_DOWNLOAD_ATTACHMENT_TYPE_VIDEO_COVER 2 视频封面,仅支持视频类附件。

    V2NIMUserStatusType

    用户在线状态的类型。

    枚举类型 枚举值 说明
    V2NIM_USER_STATUS_TYPE_UNKNOWN 0 未知。
    V2NIM_USER_STATUS_TYPE_LOGIN 1 登录。
    V2NIM_USER_STATUS_TYPE_LOGOUT 2 登出。
    V2NIM_USER_STATUS_TYPE_DISCONNECT 3 断开连接。
    此文档是否对你有帮助?
    有帮助
    去反馈
    • 支持平台
    • V2NIMSuccessCallback
    • V2NIMFailureCallback
    • V2NIMProgressCallback
    • V2NIMError
    • V2NIMLoginOption
    • V2NIMTokenProvider
    • V2NIMLoginExtensionProvider
    • V2NIMLoginClient
    • V2NIMReconnectDelayProvider
    • V2NIMKickedOfflineDetail
    • V2NIMDataSyncDetail
    • V2NIMLoginListener
    • V2NIMLoginDetailListener
    • V2NIMConversationOption
    • V2NIMConversationResult
    • V2NIMConversation
    • V2NIMConversationFilter
    • V2NIMConversationOperationResult
    • V2NIMConversationUpdate
    • V2NIMConversationListener
    • V2NIMConversationGroup
    • V2NIMConversationGroupResult
    • V2NIMConversationGroupListener
    • V2NIMConversationIdUtil
    • V2NIMMessageListener
    • V2NIMMessage
    • V2NIMMessageStatus
    • V2NIMMessageConfig
    • V2NIMMessagePushConfig
    • V2NIMMessageRouteConfig
    • V2NIMMessageAntispamConfig
    • V2NIMMessageRobotConfig
    • V2NIMLastMessage
    • V2NIMMessageQuickComment
    • V2NIMMessageQuickComment
    • V2NIMMessagePin
    • V2NIMCollection
    • V2NIMAddCollectionParams
    • V2NIMCollectionOption
    • V2NIMSendMessageParams
    • V2NIMMessageTargetConfig
    • V2NIMModifyMessageParams
    • V2NIMMessageRefer
    • V2NIMMessageAttachment
    • V2NIMDownloadMessageAttachmentParams
    • V2NIMGetMediaResourceInfoResult
    • V2NIMSize
    • V2NIMMessageFileAttachment
    • V2NIMMessageImageAttachment
    • V2NIMMessageAudioAttachment
    • V2NIMMessageVideoAttachment
    • V2NIMMessageCallAttachment
    • V2NIMMessageCallDuration
    • V2NIMMessageLocationAttachment
    • V2NIMMessageNotificationAttachment
    • V2NIMSendMessageResult
    • V2NIMModifyMessageResult
    • V2NIMMessageListOption
    • V2NIMThreadMessageListOption
    • V2NIMThreadMessageListResult
    • V2NIMP2PMessageReadReceipt
    • V2NIMTeamMessageReadReceipt
    • V2NIMTeamMessageReadReceiptDetail
    • V2NIMMessageRevokeParams
    • V2NIMMessageRevokeNotification
    • V2NIMMessageDeletedNotification
    • V2NIMMessageQuickCommentNotification
    • V2NIMMessagePinNotification
    • V2NIMClearHistoryMessageOption
    • V2NIMClearHistoryNotification
    • V2NIMMessageSearchParams
    • V2NIMClientAntispamResult
    • V2NIMVoiceToTextParams
    • V2NIMStorageScene
    • V2NIMStorageSceneConfig
    • V2NIMCustomNotification
    • V2NIMNotificationConfig
    • V2NIMNotificationPushConfig
    • V2NIMNotificationRouteConfig
    • V2NIMNotificationAntispamConfig
    • V2NIMSendCustomNotificationParams
    • V2NIMBroadcastNotification
    • V2NIMNotificationListener
    • V2NIMTeam
    • V2NIMTeamMember
    • V2NIMCreateTeamParams
    • V2NIMTeamMemberQueryOption
    • V2NIMUpdateTeamInfoParams
    • V2NIMCreateTeamResult
    • V2NIMUpdateSelfMemberInfoParams
    • V2NIMTeamMemberListResult
    • V2NIMTeamJoinActionInfo
    • V2NIMTeamJoinActionInfoQueryOption
    • V2NIMTeamJoinActionInfoResult
    • V2NIMTeamMemberSearchOption
    • V2NIMTeamMemberSearchResult
    • V2NIMTeamListener
    • V2NIMDndConfig
    • V2NIMOfflinePushConfig(仅 Web)
    • V2NIMManufacturerPushConfig(仅 Web)
    • V2NIMSettingListener
    • V2NIMUser
    • V2NIMAIUser
    • V2NIMAIModelConfig
    • V2NIMProxyAIModelCallParams
    • V2NIMProxyAICallAntispamConfig
    • V2NIMAIModelCallContent
    • V2NIMAIModelCallMessage
    • V2NIMAIModelConfigParams
    • V2NIMMessageAIConfigParams
    • V2NIMAIModelCallResult
    • V2NIMAIListener
    • V2NIMMessageAIConfig
    • V2NIMUserUpdateParams
    • V2NIMUserSearchOption
    • V2NIMUserListener
    • V2NIMFriend
    • V2NIMFriendAddParams
    • V2NIMFriendAddApplication
    • V2NIMFriendDeleteParams
    • V2NIMFriendSetParams
    • V2NIMFriendAddApplicationQueryOption
    • V2NIMFriendAddApplicationResult
    • V2NIMFriendSearchOption
    • V2NIMFriendListener
    • V2NIMChatroomClient
    • V2NIMChatroomInitParams(仅 Web & HarmonyOS)
    • V2NIMChatroomEnterParams
    • V2NIMChatroomLoginOption
    • V2NIMChatroomTokenProvider
    • V2NIMChatroomLoginExtensionProvider
    • V2NIMChatroomLinkProvider
    • V2NIMChatroomTagConfig
    • V2NIMChatroomLocationConfig
    • V2NIMLocationInfo
    • V2NIMChatroomEnterResult
    • V2NIMChatroomInfo
    • V2NIMChatroomMember
    • V2NIMChatroomEnterInfo
    • V2NIMChatroomKickedInfo
    • V2NIMUserInfoConfig
    • V2NIMChatroomMessageConfig
    • V2NIMChatroomMessage
    • V2NIMChatroomNotificationAttachment
    • V2NIMChatroomMessageRevokeNotificationAttachment
    • V2NIMChatroomChatBannedNotificationAttachment
    • V2NIMChatroomMemberEnterNotificationAttachment
    • V2NIMChatroomMemberRoleUpdateAttachment
    • V2NIMSendChatroomMessageParams
    • V2NIMSendChatroomMessageResult
    • V2NIMChatroomMemberQueryOption
    • V2NIMChatroomMemberListResult
    • V2NIMChatroomMessageListOption
    • V2NIMChatroomMemberRoleUpdateParams
    • V2NIMChatroomUpdateParams
    • V2NIMChatroomSelfMemberUpdateParams
    • V2NIMChatroomTagTempChatBannedParams
    • V2NIMChatroomTagsUpdateParams
    • V2NIMChatroomTagMemberOption
    • V2NIMChatroomTagMessageOption
    • V2NIMChatroomClientListener
    • V2NIMChatroomListener
    • V2NIMUploadFileTask
    • V2NIMUploadFileParams
    • V2NIMClientAntispamUtil
    • V2NIMAntispamConfig
    • NIMSDKOption(仅 iOS)
    • V2NIMSDKOption(仅 iOS)
    • V2NIMInitOption(仅 macOS/Windows)
    • V2NIMUpdatedTeamInfo
    • V2NIMSubscribeUserStatusOption
    • V2NIMUserStatus
    • V2NIMUnsubscribeUserStatusOption
    • V2NIMCustomUserStatusParams
    • V2NIMUserStatusSubscribeResult
    • V2NIMCustomUserStatusPublishResult
    • V2NIMSubscribeListener
    • V2NIMLocalConversationResult(仅 HarmonyOS)
    • V2NIMLocalConversationOption(仅 HarmonyOS)
    • V2NIMLocalConversationFilter(仅 HarmonyOS)
    • V2NIMLocalConversation(仅 HarmonyOS)
    • V2NIMLocalConversationOperationResult(仅 HarmonyOS)
    • V2NIMLocalConversationListener(仅 HarmonyOS)
    • 枚举
    • V2NIMAIModelType
    • V2NIMAIModelRoleType
    • V2NIMMessageAIStatus
    • V2NIMLoginStatus
    • V2NIMLoginAuthType
    • V2NIMDataSyncLevel
    • V2NIMLoginClientType
    • V2NIMLoginClientChange
    • V2NIMKickedOfflineReason
    • V2NIMConnectStatus
    • V2NIMDataSyncType
    • V2NIMDataSyncState
    • V2NIMConversationType
    • V2NIMMessageType
    • V2NIMMessageAttachmentUploadState
    • V2NIMMessageNotificationType
    • V2NIMMessageSendingState
    • V2NIMClientAntispamOperateType
    • V2NIMQueryDirection
    • V2NIMMessageRevokeType
    • V2NIMMesssagePinState
    • V2NIMMessagePinState
    • V2NIMMessageQuickCommentType
    • V2NIMSortOrder
    • V2NIMTeamType
    • V2NIMTeamJoinMode
    • V2NIMTeamAgreeMode
    • V2NIMTeamInviteMode
    • V2NIMTeamUpdateInfoMode
    • V2NIMTeamChatBannedMode
    • V2NIMTeamUpdateExtensionMode
    • V2NIMTeamMemberRole
    • V2NIMTeamMemberRoleQueryType
    • V2NIMTeamJoinActionType
    • V2NIMTeamJoinActionStatus
    • V2NIMP2PMessageMuteMode
    • V2NIMTeamMessageMuteMode
    • V2NIMFriendAddMode
    • V2NIMFriendAddApplicationStatus
    • V2NIMFriendDeletionType
    • V2NIMChatroomQueueLevelMode
    • V2NIMChatroomMemberRole
    • V2NIMChatroomKickedReason
    • V2NIMChatroomMessageNotificationType
    • V2NIMChatroomStatus
    • V2NIMDownloadAttachmentType
    • V2NIMUserStatusType