类和枚举
更新时间: 2025/02/11 15:14:29
本文介绍网易云信即时通讯 SDK(简称 NIM SDK)客户端接口类和枚举信息。
支持平台
本文内容适用的开发平台或框架如下表所示:
Android | iOS | macOS/Windows | Web/uni-app/小程序 | Node.js/Electron | HarmonyOS |
---|---|---|---|---|---|
✔️️ | ✔️️ | ✔️️ | ✔️️ | ✔️️ | ✔️️ |
类
V2NIMSuccessCallback
操作成功回调对象。
Javapublic interface V2NIMSuccessCallback<T> {
void onSuccess(T t);
}
Objective-Ctypedef void (^V2NIMSuccessCallback)(void);
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
操作失败回调对象。
Javapublic interface V2NIMFailureCallback {
void onFailure(V2NIMError error);
}
Objective-Ctypedef void (^V2NIMFailureCallback)(V2NIMError *error);
C++using V2NIMFailureCallback = nstd::function<void(V2NIMError error)>;
成员函数
onFailed
操作失败回调。
参数名称 | 类型 | 说明 |
---|---|---|
error |
V2NIMError |
回调错误详情 |
V2NIMProgressCallback
操作进度回调对象。
Javapublic interface V2NIMProgressCallback {
void onProgress(int progress);
}
Objective-Ctypedef void (^V2NIMProgressCallback)(NSUInteger);
C++using V2NIMProgressCallback = nstd::function<void(uint32_t progress)>;
TypeScriptexport type V2NIMProgressCallback = (progress: { [key: string]: any }) => void
TypeScriptV2NIMProgressCallback: ((progress: number) => void)
TypeScriptexport type V2NIMProgressCallback = (progress: number) => void
成员函数
onProgress
操作进度回调。
参数名称 | 类型 | 说明 |
---|---|---|
progress |
int | 操作进度,取值范围 [0,100],100 表示操作成功,0 表示未开始。 |
V2NIMError
错误信息。具体错误码请参考 API 错误码文档。
参数名称 | 类型 | 说明 |
---|---|---|
code |
int | 错误码 |
desc |
String | 错误描述 |
detail |
Map | 错误详情,用于补充上下文细节。 |
V2NIMLoginOption
登录配置参数。
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;
}
}
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
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};
};
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
}
TypeScriptinterface V2NIMLoginOption {
retryCount?: number;
timeout?: number;
forceMode?: boolean;
authType?: V2NIMLoginAuthType;
tokenProvider?: V2NIMTokenProvider;
loginExtensionProvider?: V2NIMLoginExtensionProvider;
syncLevel?: V2NIMDataSyncLevel;
}
TypeScriptexport interface V2NIMLoginOption {
retryCount?: number
timeout?: number
forceMode?: boolean
authType?: V2NIMLoginAuthType
loginExtensionProvider?: V2NIMLoginExtensionProvider
tokenProvider?: V2NIMTokenProvider
syncLevel?: V2NIMDataSyncLevel
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
retryCount |
int | 否 | 3 | 登录失败后,重试登录的次数。 若登录成功后因网络原因断开连接,则不限次数重连。 |
timeout |
int | 否 | 60000 | 登录超时时间,单位毫秒。 系统会在超时时间内重试登录,重试次数最大为 retryCount 。 |
|
Bool |
否 |
false |
多端登录互踢时,是否强制登录: |
authType |
V2NIMLoginAuthType |
否 | 0 | 鉴权方式,包括静态 Token 鉴权(默认)、动态 Token 鉴权、通过第三方回调鉴权。 |
tokenProvider |
V2NIMTokenProvider |
否,若使用动态 Token 鉴权则为必填 | - | 获取动态 Token 回调,用于动态 Token 登录鉴权。该回调在登录连接完成、登录鉴权校验前触发。若函数执行有异常或返回非预期内容(非法字符串),则登录中止并报错。 |
loginExtensionProvider |
V2NIMLoginExtensionProvider |
否,若使用第三方回调鉴权则为必填 | - | 获取用户登录业务扩展数据回调,用于第三方登录鉴权。该回调在登录连接完成、登录鉴权校验前触发。若函数执行有异常或返回非预期内容(非法字符串),则登录中止并报错。 |
syncLevel |
V2NIMDataSyncLevel |
是 | - | 数据同步模式,分为完全同步和基础数据同步。Web 端仅支持完全同步。 |
V2NIMTokenProvider
获取动态 Token 回调。
Javapublic interface V2NIMTokenProvider {
String getToken(String account);
}
Objective-C@protocol V2NIMTokenProvider <NSObject>
- (nullable NSString *)getToken:(NSString *)accountId;
@end
C++using V2NIMTokenProvider = nstd::function<nstd::optional<nstd::string>(nstd::string accountId)>;
TypeScriptexport type V2NIMTokenProvider = (accountId: string) => Promise<string> | string
TypeScriptV2NIMTokenProvider: ((accountId: string) => string)
TypeScriptexport type V2NIMTokenProvider = (accountId: string) => Promise<string> | string
成员参数
名称 | 类型 | 说明 |
---|---|---|
accountId |
String | 登录账号 |
V2NIMLoginExtensionProvider
用户登录业务扩展数据回调。
Javapublic interface V2NIMLoginExtensionProvider {
String getLoginExtension(String accountId);
}
Objective-C@protocol V2NIMLoginExtensionProvider <NSObject>
- (nullable NSString *)getLoginExtension:(NSString *)accountId;
@end
C++using V2NIMLoginExtensionProvider = nstd::function<nstd::optional<nstd::string>(nstd::string accountId)>;
TypeScriptexport type V2NIMLoginExtensionProvider = (accountId: string) => Promise<string> | string
TypeScriptV2NIMLoginExtensionProvider: ((accountId: string) => string)
TypeScriptexport type V2NIMLoginExtensionProvider = (accountId: string) => Promise<string> | string
成员参数
名称 | 类型 | 说明 |
---|---|---|
accountId |
String | 登录账号 |
V2NIMLoginClient
当前处于登录状态的客户端信息。
Javapublic interface V2NIMLoginClient {
V2NIMLoginClientType getType();
String getOs();
long getTimestamp();
String getCustomTag();
int getCustomClientType();
String getClientId();
String getClientIP();
}
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;
@property(nullable,nonatomic,copy,readonly) NSString *clientIp;
@end
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;
ne_std::string ip;
};
TypeScriptexport type V2NIMLoginClient = {
type: V2NIMLoginClientType
os: string
timestamp: number
customTag?: string
customClientType?: number
clientId: string
clientIP?: string
}
TypeScriptinterface V2NIMLoginClient {
type?: V2NIMLoginClientType;
os?: string;
timestamp?: number;
customTag?: string;
customClientType?: number;
clientId?: string;
clientIP?: string;
}
TypeScriptinterface V2NIMLoginClient {
clientId: string;
clientIP?: string;
customClientType?: number;
customTag?: string;
os: string;
timestamp: number;
type: V2NIMLoginClientType;
}
成员参数
参数名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
type |
V2NIMLoginClientType | 是 | - | 客户端类型。 |
os |
String | 是 | - | 客户端操作系统。 |
timestamp |
long | 是 | - | 客户端登录时间戳。 |
customTag |
String | 是 | - | 自定义标签,不得超过 32 个字符。可以通过该参数对不同终端设备进行区分。 |
customClientType |
int | 是 | 0 | 自定义客户端类型,小于或等于 0 表示无自定义类型。 |
clientId |
String | 否 | - | 客户端 ID,客户端唯一标识。 |
clientIP |
String | 是 | - | 登录客户端的 IP 信息。该字段 @since v10.5.0。 |
V2NIMReconnectDelayProvider
登录重连延时回调对象。
Javapublic interface V2NIMReconnectDelayProvider {
long getReconnectDelay(long delay);
}
Objective-C@protocol V2NIMReconnectDelayProvider <NSObject>
- (nullable uint32_t *)getReconnectDelay:(uint32_t *)delay;
@end
C++using V2NIMReconnectDelayProvider = nstd::function<nstd::optional<nstd::int>(nstd::int delay)>;
TypeScriptexport type V2NIMReconnectDelayProvider = (delay: number) => number
TypeScriptV2NIMReconnectDelayProvider: ((defaultDelay: number) => number)
TypeScriptexport type V2NIMReconnectDelayProvider = (delay: number) => number
成员参数
如果平台为 Android 或 iOS,则需要通过成员函数 getReconnectDelay
获取登录重连延时。
参数名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
delay |
视平台而定 | 是 | - | 登录重连延时。 |
返回值
登录重连延时时间,单位为毫秒。
V2NIMKickedOfflineDetail
登录客户端被踢详细信息。
Javapublic interface V2NIMKickedOfflineDetail {
V2NIMKickedOfflineReason getReason();
String getReasonDesc();
V2NIMLoginClientType getClientType();
Integer getCustomClientType();
}
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
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};
};
TypeScriptexport type V2NIMKickedOfflineDetail = {
reason: V2NIMKickedOfflineReason
reasonDesc: string
clientType: V2NIMLoginClientType
customClientType: number
}
TypeScriptinterface V2NIMKickedOfflineDetail {
reason?: V2NIMKickedOfflineReason;
reasonDesc?: string;
clientType?: V2NIMLoginClientType;
customClientType?: number;
}
TypeScriptexport interface V2NIMKickedOfflineDetail {
reason: V2NIMKickedOfflineReason
reasonDesc: string
clientType: V2NIMLoginClientType
customClientType: number
}
成员参数
如果平台为 Android,则需要通过成员函数 getReconnectDelay
获取登录重连延时。
参数名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
reason |
V2NIMKickedOfflineReason | - | - | 客户端被踢原因类型。 |
reasonDesc |
String | - | - | 客户端被踢原因详情。 |
clientType |
V2NIMLoginClientType | - | - | 踢端的客户端类型。 |
customClientType |
int | - | - | 踢端自定义客户端类型。 |
V2NIMDataSyncDetail
数据同步状态详细信息。
Javapublic interface V2NIMDataSyncDetail {
V2NIMDataSyncType getType();
V2NIMDataSyncState getState();
}
Objective-C@interface V2NIMDataSyncDetail : NSObject
@property(nonatomic,assign,readonly) V2NIMDataSyncType type;
@property(nonatomic,assign,readonly) V2NIMDataSyncState state;
@end
C++struct V2NIMDataSyncDetail {
V2NIMDataSyncType type{V2NIM_DATA_SYNC_MAIN};
V2NIMDataSyncState state{V2NIM_DATA_SYNC_STATE_WAITING};
};
TypeScriptexport type V2NIMDataSyncDetail = {
type: V2NIMDataSyncType
state: V2NIMDataSyncState
}
TypeScriptinterface V2NIMDataSyncDetail {
type?: V2NIMDataSyncType;
state?: V2NIMDataSyncState;
}
TypeScriptexport interface V2NIMDataSyncDetail {
type: V2NIMDataSyncType
state: V2NIMDataSyncState
}
成员参数
参数名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
type |
V2NIMDataSyncType | - | - | 同步数据类型。 |
state |
V2NIMDataSyncState | - | - | 同步数据状态类型。 |
V2NIMLoginListener
登录相关监听器。
Javapublic interface V2NIMLoginListener {
void onLoginStatus(V2NIMLoginStatus status);
void onLoginFailed(V2NIMError error);
void onKickedOffline(V2NIMKickedOfflineDetail detail);
void onLoginClientChanged(V2NIMLoginClientChange change, List<V2NIMLoginClient> clients);
}
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
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;
bool operator==(const V2NIMLoginListener& other) const {
return onLoginStatus == other.onLoginStatus && onLoginFailed == other.onLoginFailed && onKickedOffline == other.onKickedOffline &&
onLoginClientChanged == other.onLoginClientChanged;
}
};
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]
}
TypeScriptinterface V2NIMLoginListener {
loginStatus: [V2NIMLoginStatus];
loginFailed: [V2NIMError];
kickedOffline: [V2NIMKickedOfflineDetail];
loginClientChanged: [V2NIMLoginClientChange, V2NIMLoginClient[]];
connectStatus: [V2NIMConnectStatus];
disconnected: [null | V2NIMError];
connectFailed: [V2NIMError];
dataSync: [V2NIMDataSyncType, V2NIMDataSyncState, null | V2NIMError];
}
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
登录连接状态监听器。
Javapublic interface V2NIMLoginDetailListener {
void onConnectStatus(V2NIMConnectStatus status);
void onDisconnected(V2NIMError error);
void onConnectFailed(V2NIMError error);
void onDataSync(V2NIMDataSyncType type, V2NIMDataSyncState state, V2NIMError error);
}
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
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 端不区分 detail 事件,所以上文的 V2NIMLoginListener 包含 detail 相关的事件
Node.js/Electron 端不区分 detail 事件,所以上文的 V2NIMLoginListener 包含 detail 相关的事件
HarmonyOS 不区分 detail 事件,所以上文的 V2NIMLoginListener 包含 detail 相关的事件
成员函数
-
onConnectStatus
登录连接状态变化回调。
参数名称 类型 说明 status
V2NIMConnectStatus 登录连接状态 -
onDisconnected
登录连接断开回调。
参数名称 类型 说明 error
V2NIMError 登录连接断开错误码及错误信息 -
onConnectFailed
登录连接失败回调。
参数名称 类型 说明 error
V2NIMError 登录连接失败错误码及错误信息 -
onDataSync
数据同步状态变化回调。
参数名称 类型 说明 type
V2NIMDataSyncType 数据同步类型 state
V2NIMDataSyncState 数据同步状态 error
V2NIMError 数据同步失败错误码及错误信息
V2NIMConversationOption
云端会话查询选项。
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 +
'}';
}
}
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
C++struct V2NIMConversationOption {
nstd::vector<V2NIMConversationType> conversationTypes;
nstd::optional<nstd::vector<nstd::string>> conversationGroupIds;
bool onlyUnread{false};
};
TypeScriptexport type V2NIMConversationOption = {
conversationTypes?: V2NIMConversationType[]
onlyUnread?: boolean
conversationGroupIds?: string[]
}
TypeScriptinterface V2NIMConversationOption {
conversationTypes?: V2NIMConversationType[];
conversationGroupIds?: string[];
onlyUnread?: boolean;
}
TypeScriptexport interface V2NIMConversationOption {
conversationTypes?: V2NIMConversationType[]
onlyUnread?: boolean
conversationGroupIds?: string[]
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
conversationTypes |
List<V2NIMConversationType > |
否 | [] 或 null | 会话类型,null 表示不限制会话类型。 |
onlyUnread |
Bool | 否 | false | 是否仅查询未读会话: |
conversationGroupIds |
Optional<List |
否 | null | 会话分组 ID 列表。null 表示查询所有会话分组,empty 表示查询未添加到会话分组的会话。 |
V2NIMConversationResult
云端会话查询结果。
Javapublic interface V2NIMConversationResult extends Serializable {
long getOffset();
boolean isFinished();
List<V2NIMConversation> getConversationList();
}
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
C++struct V2NIMConversationResult {
uint64_t offset{0};
bool finished{false};
V2NIMConversationList conversationList;
};
TypeScriptexport type V2NIMConversationResult = {
offset: number
finished: boolean
conversationList: V2NIMConversation[]
}
TypeScriptinterface V2NIMConversationResult {
offset?: number;
finished?: boolean;
conversationList?: V2NIMConversation[];
}
TypeScriptexport interface V2NIMConversationResult {
offset: number
finished: boolean
conversationList: V2NIMConversation[]
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
offset |
long | 是 | 分页偏移。 |
finished |
Bool | 是 | 数据是否获取完毕: |
conversationList |
List<V2NIMConversation > |
是 | 会话对象列表。 |
V2NIMConversation
云端会话对象。
Javapublic interface V2NIMConversation extends Serializable {
String getConversationId();
V2NIMConversationType getType();
String getName();
String getAvatar();
boolean isMute();
boolean isStickTop();
List<String> getGroupIds();
String getLocalExtension();
String getServerExtension();
V2NIMLastMessage getLastMessage();
int getUnreadCount();
long getSortOrder();
long getCreateTime();
long getUpdateTime();
}
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) V2NIMLastMessage *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
C++struct V2NIMConversation {
nstd::string conversationId;
V2NIMConversationType type{V2NIM_CONVERSATION_TYPE_UNKNOWN};
nstd::optional<nstd::string> name;
nstd::optional<nstd::string> avatar;
bool mute{false};
bool stickTop{false};
nstd::vector<nstd::string> groupIds;
nstd::optional<nstd::string> localExtension;
nstd::optional<nstd::string> serverExtension;
nstd::optional<V2NIMLastMessage> lastMessage;
uint32_t unreadCount{0};
uint64_t sortOrder{0};
uint64_t createTime{0};
uint64_t updateTime{0};
};
TypeScriptexport type 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
}
TypeScriptinterface 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;
}
TypeScriptinterface V2NIMConversation {
avatar?: string;
conversationId: string;
createTime: number;
groupIds?: string[];
lastMessage?: V2NIMLastMessage;
localExtension?: string;
mute?: boolean;
name?: string;
serverExtension: string;
sortOrder: number;
stickTop: boolean;
type: V2NIMConversationType;
unreadCount: number;
updateTime: number;
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
conversationId |
String | 是 | - | 会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType )| 聊天对象账号(accountId)或群组 ID。 |
type |
V2NIMConversationType |
否 | V2NIM_CONVERSATION_TYPE_UNKNOWN |
会话类型。 |
name |
String | 否 | null | 会话名称。 |
avatar |
String | 否 | null | 会话头像。 |
mute |
boolean | 否 | null | 会话是否为静音状态。 |
stickTop |
boolean | 否 | false | 会话是否为置顶状态。 |
groupIds |
List<String> | 否 | null | 会话所属分组列表。 |
localExtension |
String | 否 | "" | 会话本地扩展字段,不会多端同步。长度上限为 1024 字节。 |
serverExtension |
String | 否 | "" | 会话服务端扩展字段,多端同步。长度上限为 1024 字节。 |
lastMessage |
V2NIMLastMessage |
否 | null | 会话中最后一条消息。 |
unreadCount |
int | 否 | 0 | 会话消息未读数。 |
createTime |
long | 否 | 0 | 会话创建时间戳(毫秒) |
updateTime |
long | 否 | 0 | 会话更新时间戳(毫秒) |
sortOrder |
long | 否 | 0 | 会话排序字段。默认将置顶会话排首位,如有多条置顶会话,则按其创建时间进行排序。 |
V2NIMConversationFilter
云端会话过滤器对象。
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;
}
}
Objective-C@interface V2NIMConversationFilter : NSObject <NSCopying>
@property(nullable,nonatomic,copy,readwrite) NSArray<NSNumber *> *conversationTypes;
@property(nullable,nonatomic,copy,readwrite) NSArray<NSString *> *conversationGroupIds;
@end
C++struct V2NIMConversationFilter {
nstd::set<V2NIMConversationType> conversationTypes;
nstd::string conversationGroupId;
bool ignoreMuted{false};
};
TypeScriptexport type V2NIMConversationFilter = {
conversationTypes?: V2NIMConversationType[]
conversationGroupId?: string
ignoreMuted?: boolean
}
TypeScriptinterface V2NIMConversationFilter {
conversationTypes?: V2NIMConversationType[];
conversationGroupId?: string;
ignoreMuted?: boolean;
}
TypeScriptexport interface V2NIMConversationFilter {
conversationTypes?: V2NIMConversationType[]
conversationGroupId?: string
ignoreMuted?: boolean
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
conversationTypes |
List |
否 | null | 会话类型列表,null 表示不按照会话类型过滤。 |
conversationGroupId |
String | 否 | null | 会话分组 ID,null 表示不按照会话 ID 过滤。 |
ignoreMuted |
Bool | 否 | false | 是否过滤具有免打扰属性(mute 为 true )的会话对象: |
V2NIMConversationOperationResult
单条云端会话操作结果。
Javapublic interface V2NIMConversationOperationResult {
String getConversationId();
V2NIMError getError();
}
C++struct V2NIMConversationOperationResult {
nstd::string conversationId;
V2NIMError error;
};
TypeScriptexport type V2NIMConversationOperationResult = {
conversationId: string
error: V2NIMError
}
TypeScriptinterface V2NIMConversationOperationResult {
conversationId?: string;
error?: V2NIMError;
}
TypeScriptexport interface V2NIMConversationOperationResult {
conversationId: string
error: V2NIMError
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
conversationId |
String | 是 | 操作失败的会话 ID。如果操作成功则为空。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType )| 聊天对象账号(accountId)或群组 ID。 |
error |
V2NIMError | 是 | 操作失败的错误码和错误信息,如果操作成功,则为空。 |
V2NIMConversationUpdate
云端会话更新对象。
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;
}
}
Objective-C@interface V2NIMConversationUpdate : NSObject
@property(nullable,nonatomic,copy,readwrite) NSString *serverExtension;
@end
C++struct V2NIMConversationUpdate {
nstd::optional<nstd::string> serverExtension;
};
TypeScriptexport type V2NIMConversationUpdate = {
serverExtension?: string
}
TypeScriptinterface V2NIMConversationUpdate {
serverExtension?: string;
}
TypeScriptexport interface V2NIMConversationUpdate {
serverExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
serverExtension |
String | 是 | "" | 服务端扩展字段,多端同步。长度上限为 1024 字节。 |
V2NIMConversationListener
云端会话相关监听器。
调用 addConversationListener
注册会话监听后,当会话相关事件发生时,会返回对应回调。
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);
}
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
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;
};
};
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
]
}
TypeScriptinterface V2NIMConversationListener {
syncStarted: [];
syncFinished: [];
syncFailed: [V2NIMError];
conversationCreated: [V2NIMConversation];
conversationDeleted: [string[]];
conversationChanged: [V2NIMConversation[]];
totalUnreadCountChanged: [number];
unreadCountChangedByFilter: [V2NIMConversationFilter, number];
conversationReadTimeUpdated: [string, number];
}
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
会话分组对象。
Javapublic interface V2NIMConversationGroup extends Serializable {
String getGroupId();
String getName();
String getServerExtension();
long getCreateTime();
long getUpdateTime();
}
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
C++struct V2NIMConversationGroup {
nstd::string groupId;
nstd::string name;
nstd::optional<nstd::string> serverExtension;
uint64_t createTime{0};
uint64_t updateTime{0};
};
TypeScriptexport type V2NIMConversationGroup = {
groupId: string
name: string
serverExtension: string
createTime: number
updateTime: number
}
TypeScriptinterface V2NIMConversationGroup {
groupId?: string;
name?: string;
serverExtension?: string;
createTime?: number;
updateTime?: number;
}
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
会话分组操作结果对象。
Javapublic interface V2NIMConversationGroupResult {
V2NIMConversationGroup getGroup();
List<V2NIMConversationOperationResult> getFailedList();
}
Objective-C@interface V2NIMConversationGroupResult : NSObject
@property(nullable,nonatomic,copy,readonly) V2NIMConversationGroup *group;
@property(nullable,nonatomic,copy,readonly) NSArray<V2NIMConversationOperationResult *> *failedList;
@end
C++struct V2NIMConversationGroupResult {
V2NIMConversationGroup group;
nstd::vector<V2NIMConversationOperationResult> failedList;
};
TypeScriptexport type V2NIMConversationGroupResult = {
group: V2NIMConversationGroup
failedList: V2NIMConversationOperationResult[]
}
TypeScriptinterface V2NIMConversationGroupResult {
group: V2NIMConversationGroup
failedList: V2NIMConversationOperationResult[]
}
TypeScriptexport type V2NIMConversationGroupResult = {
group: V2NIMConversationGroup
failedList: V2NIMConversationOperationResult[]
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
group |
V2NIMConversationGroup |
是 | 会话分组。 |
failedList |
List<V2NIMConversationOperationResult > |
是 | 失败结果列表,包含操作失败的会话分组列表和错误信息。 |
V2NIMConversationGroupListener
会话分组相关监听器。
调用 addConversationGroupListener
注册会话分组监听后,当会话分组相关事件发生时,会返回对应回调。
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);
}
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
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;
};
TypeScriptexport type V2NIMConversationGroupListener = {
onConversationGroupCreated: [conversationGroup: V2NIMConversationGroup]
onConversationGroupDeleted: [groupId: string]
onConversationGroupChanged: [conversationGroup: V2NIMConversationGroup]
onConversationsAddedToGroup: [groupId: string, list: V2NIMConversation[]]
onConversationsRemovedFromGroup: [groupId: string, list: string[]]
}
TypeScriptinterface V2NIMConversationGroupListener {
conversationGroupCreated: [V2NIMConversationGroup];
conversationGroupDeleted: [string];
conversationGroupChanged: [V2NIMConversationGroup];
conversationsAddedToGroup: [string, V2NIMConversation[]];
conversationsRemovedFromGroup: [string, string[]];
}
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 -
parseConversationTargetId
解析会话目标账号。提取拼接的最后一段。
参数名称 类型 说明 conversationId
String 会话 ID 返回值:String targetId
示例代码
Javapublic final class V2NIMConversationIdUtil {
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;
}
}
public static String p2pConversationId(String accountId){
return conversationId(accountId, V2NIMConversationType.V2NIM_CONVERSATION_TYPE_P2P);
}
public static String teamConversationId(String teamId){
return conversationId(teamId, V2NIMConversationType.V2NIM_CONVERSATION_TYPE_TEAM);
}
public static String superTeamConversationId(String superTeamId){
return conversationId(superTeamId, V2NIMConversationType.V2NIM_CONVERSATION_TYPE_SUPER_TEAM);
}
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;
}
}
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];
}
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;
}
}
}
Objective-C@interface V2NIMConversationIdUtil : NSObject
+ (nullable NSString *)p2pConversationId:(NSString *)accountId;
+ (nullable NSString *)teamConversationId:(NSString *)teamId;
+ (nullable NSString *)superTeamConversationId:(NSString *)teamId;
+ (V2NIMConversationType)conversationType:(NSString *)conversationId;
+ (nullable NSString *)conversationTargetId:(NSString *)conversationId;
@end
C++class V2NIMConversationIdUtil {
public:
static nstd::string p2pConversationId(const nstd::string& accountId);
static nstd::string teamConversationId(const nstd::string& teamId);
static nstd::string superTeamConversationId(const nstd::string& superTeamId);
static V2NIMConversationType parseConversationType(const nstd::string& conversationId);
static nstd::string parseConversationTargetId(const nstd::string& conversationId);
};
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')
TypeScriptconst conversationId = v2.conversationIdUtil.p2pConversationId(accountId)
const conversationId = v2.conversationIdUtil.teamConversationId(teamId)
const conversationId = v2.conversationIdUtil.superTeamConversationId(superTeamId)
const conversationType = v2.conversationIdUtil.parseConversationType(conversationId)
const targetId = v2.conversationIdUtil.parseConversationTargetId(conversationId)
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
消息相关监听器。
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);
}
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
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;
};
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[]]
}
TypeScriptinterface V2NIMMessageListener {
receiveMessages: [V2NIMMessage[]];
receiveP2PMessageReadReceipts: [V2NIMP2PMessageReadReceipt[]];
receiveTeamMessageReadReceipts: [V2NIMTeamMessageReadReceipt[]];
messageRevokeNotifications: [V2NIMMessageRevokeNotification[]];
messagePinNotification: [V2NIMMessagePinNotification];
messageQuickCommentNotification: [V2NIMMessageQuickCommentNotification];
messageDeletedNotifications: [V2NIMMessageDeletedNotification[]];
clearHistoryNotifications: [V2NIMClearHistoryNotification[]];
sendMessage: [V2NIMMessage];
receiveMessagesModified: [V2NIMMessage[]];
}
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: [message: V2NIMMessage]
}
成员函数
-
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
单聊、群组会话内消息对象。
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();
}
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
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;
}
};
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
}
TypeScriptinterface V2NIMMessage {
messageClientId?: string;
messageServerId?: string;
createTime?: number;
senderId?: string;
receiverId?: string;
conversationType?: V2NIMConversationType;
conversationId?: string;
messageType?: V2NIMMessageType;
subType?: number;
text?: string;
attachment?: V2NIMMessageAttachment;
serverExtension?: string;
localExtension?: string;
callbackExtension?: string;
sendingState?: V2NIMMessageSendingState;
attachmentUploadState?: V2NIMMessageAttachmentUploadState;
messageStatus?: V2NIMMessageStatus;
messageConfig?: V2NIMMessageConfig;
pushConfig?: V2NIMMessagePushConfig;
routeConfig?: V2NIMMessageRouteConfig;
antispamConfig?: V2NIMMessageAntispamConfig;
robotConfig?: V2NIMMessageRobotConfig;
threadRoot?: V2NIMMessageRefer;
threadReply?: V2NIMMessageRefer;
isSelf?: boolean;
aiConfig?: V2NIMAIModelConfig;
modifyTime?: number;
modifyAccountId?: string;
}
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 | 是 | 消息接收方账号 |
|
是 |
消息所属会话类型:
|
|
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
消息状态对象,包含消息发送失败的错误码以及是否已发送过已读回执。
Javapublic interface V2NIMMessageStatus {
int getErrorCode();
boolean getReadReceiptSent();
}
Objective-C@interface V2NIMMessageStatus : NSObject<NSCopying>
@property(nonatomic,assign,readwrite) NSInteger errorCode;
@property(nonatomic,assign,readwrite) BOOL readReceiptSent;
@end
C++struct V2NIMMessageStatus {
V2NIMErrorCode errorCode{V2NIM_ERROR_CODE_UNKNOWN};
bool readReceiptSent{false};
};
TypeScriptexport type V2NIMMessageStatus = {
errorCode: number
}
TypeScriptinterface V2NIMMessageStatus {
errorCode?: number;
readReceiptSent?: boolean;
}
TypeScriptinterface V2NIMMessageStatus {
errorCode: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
errorCode |
Integer | 是 | 200 | 消息发送失败的错误码。用户可以对该错误码做详细处理,以适配上层业务。
|
readReceiptSent |
Boolean | 否 | false | 是否已发送过已读回执。当用户开启群消息已读回执时,客户端收到消息后需要发送已读回执请求,为了避免重复发送,需要通过该字段判断是否已发送过已读回执。 |
V2NIMMessageConfig
消息相关配置。
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);
}
}
}
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
C++struct V2NIMMessageConfig {
bool readReceiptEnabled{false};
bool lastMessageUpdateEnabled{true};
bool historyEnabled{true};
bool roamingEnabled{true};
bool onlineSyncEnabled{true};
bool offlineEnabled{true};
bool unreadEnabled{true};
};
TypeScriptexport type V2NIMMessageConfig = {
readReceiptEnabled?: boolean
lastMessageUpdateEnabled?: boolean
historyEnabled?: boolean
roamingEnabled?: boolean
onlineSyncEnabled?: boolean
offlineEnabled?: boolean
unreadEnabled?: boolean
}
TypeScriptinterface V2NIMMessageConfig {
readReceiptEnabled?: boolean;
lastMessageUpdateEnabled?: boolean;
historyEnabled?: boolean;
roamingEnabled?: boolean;
onlineSyncEnabled?: boolean;
offlineEnabled?: boolean;
unreadEnabled?: boolean;
}
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
消息第三方推送相关配置。
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);
}
}
}
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
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;
};
TypeScriptexport interface V2NIMMessagePushConfig {
pushEnabled?: boolean
pushNickEnabled?: boolean
pushContent?: string
pushPayload?: string
forcePush?: boolean
forcePushContent?: string
forcePushAccountIds?: string[]
}
TypeScriptinterface V2NIMMessagePushConfig {
pushEnabled?: boolean;
pushNickEnabled?: boolean;
pushContent?: string;
pushPayload?: string;
forcePush?: boolean;
forcePushContent?: string;
forcePushAccountIds?: string[];
}
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
消息事件抄送相关配置。
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);
}
}
}
Objective-C@interface V2NIMMessageRouteConfig : NSObject <NSCopying>
@property(nonatomic,assign,readwrite) BOOL routeEnabled;
@property(nullable,nonatomic,strong,readwrite) NSString *routeEnvironment;
@end
C++struct V2NIMMessageRouteConfig {
bool routeEnabled{true};
nstd::optional<nstd::string> routeEnvironment;
};
TypeScriptexport interface V2NIMMessageRouteConfig {
routeEnabled?: boolean
routeEnvironment?: string
}
TypeScriptinterface V2NIMMessageRouteConfig {
routeEnabled?: boolean;
routeEnvironment?: string;
}
TypeScriptexport interface V2NIMMessageRouteConfig {
routeEnabled?: boolean
routeEnvironment?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
routeEnabled |
boolean | 否 | true | 是否需要消息事件抄送。 |
routeEnvironment |
String | routeEnabled 为 true 则为必填 |
- | 环境变量,用于指向不同消息事件抄送、第三方回调等配置。 |
V2NIMMessageAntispamConfig
消息反垃圾配置,包括客户端本地反垃圾和安全通的相关配置。
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);
}
}
}
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
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;
};
TypeScriptexport interface V2NIMMessageAntispamConfig {
antispamEnabled?: boolean
antispamBusinessId?: string
antispamCustomMessage?: string
antispamCheating?: string
antispamExtension?: string
}
TypeScriptinterface V2NIMMessageAntispamConfig {
antispamEnabled?: boolean;
antispamBusinessId?: string;
antispamCustomMessage?: string;
antispamCheating?: string;
antispamExtension?: string;
}
TypeScriptexport interface V2NIMMessageAntispamConfig {
antispamEnabled?: boolean
antispamBusinessId?: string
antispamCustomMessage?: string
antispamCheating?: string
antispamExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
|
boolean |
否 |
false |
是否启用本地反垃圾。
|
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
消息机器人相关配置
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);
}
}
}
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
C++struct V2NIMMessageRobotConfig {
nstd::optional<nstd::string> accountId;
nstd::optional<nstd::string> topic;
nstd::optional<nstd::string> function;
nstd::optional<nstd::string> customContent;
};
TypeScriptexport interface V2NIMMessageRobotConfig {
accountId?: string
topic?: string
function?: string
customContent?: string
}
TypeScriptinterface V2NIMMessageRobotConfig {
accountId?: string;
topic?: string;
function?: string;
customContent?: string;
}
TypeScriptexport interface V2NIMMessageRobotConfig {
accountId?: string
topic?: string
function?: string
customContent?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
accountId |
String | 是 | - | 机器人账号,必须与在 网易云信控制台 上配置的机器人账号一致。 该字段仅对群组消息有效。 |
topic |
String | 是 | - | 机器人消息话题。 |
function |
String | 否 | - | 机器人具体功能。 |
customContent |
String | 否 | - | 机器人自定义内容。 |
V2NIMLastMessage
会话最后一条消息。包含以下场景:
- 发送的最后一条消息
- 接受的最后一条消息
- 插入的最后一条消息
- 撤回消息的通知
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();
}
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
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;
};
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
}
TypeScriptinterface V2NIMLastMessage {
lastMessageState?: V2NIMLastMessageState;
messageRefer?: V2NIMMessageRefer;
messageType?: V2NIMMessageType;
subType?: number;
sendingState?: V2NIMMessageSendingState;
text?: string;
attachment?: V2NIMMessageAttachment;
revokeAccountId?: string;
revokeType?: V2NIMMessageRevokeType;
senderName?: string;
serverExtension?: string;
callbackExtension?: string;
}
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
消息快捷评论对象。
Javapublic interface V2NIMMessageQuickComment {
V2NIMMessageRefer getMessageRefer();
String getOperatorId();
long getIndex();
long getCreateTime();
String getServerExtension();
}
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
C++struct V2NIMMessageQuickComment {
V2NIMMessageRefer messageRefer;
nstd::string operatorId;
uint64_t index{0};
nstd::optional<nstd::string> serverExtension;
nstd::optional<uint64_t> createTime;
TypeScriptexport interface V2NIMMessageQuickComment {
messageRefer: V2NIMMessageRefer
operatorId: string
index: number
serverExtension: string
createTime: number
pushConfig?: V2NIMMessageQuickCommentPushConfig
}
TypeScriptinterface V2NIMMessageQuickComment {
messageRefer?: V2NIMMessageRefer;
operatorId?: string;
index?: number;
serverExtension?: string;
createTime?: number;
}
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 | 是 | 服务端扩展字段,多端同步。 |
V2NIMMessageQuickCommentPushConfig
快捷评论推送配置。
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);
}
}
}
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
C++struct V2NIMMessageQuickCommentPushConfig {
bool needPush{true};
bool needBadge{true};
nstd::string pushTitle;
nstd::string pushContent;
nstd::string pushPayload;
};
TypeScriptexport interface V2NIMMessageQuickCommentPushConfig {
pushEnabled?: boolean
needBadge?: boolean
title?: string
pushContent?: string
pushPayload?: string
}
TypeScriptinterface V2NIMMessageQuickCommentPushConfig {
needPush?: boolean;
needBadge?: boolean;
pushTitle?: string;
pushContent?: string;
pushPayload?: string;
}
TypeScriptexport interface V2NIMMessageQuickCommentPushConfig {
pushEnabled?: boolean
needBadge?: boolean
title?: string
pushContent?: string
pushPayload?: string
}
成员参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
pushEnabled |
boolean | 否 | 是否需要推送,默认为 true。 |
needBadge |
boolean | 否 | 是否需要角标,默认为 true。 |
pushTitle |
String | 否 | 推送标题。 |
pushContent |
String | 否 | 推送内容。 |
pushPayload |
String | 否 | 推送自定义字段。 |
V2NIMMessagePin
Pin 消息对象。
Javapublic interface V2NIMMessagePin {
V2NIMMessageRefer getMessageRefer();
String getOperatorId();
String getServerExtension();
long getCreateTime();
long getUpdateTime();
}
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
C++struct V2NIMMessagePin {
V2NIMMessageRefer messageRefer;
nstd::string operatorId;
nstd::optional<nstd::string> serverExtension;
uint64_t createTime{0};
uint64_t updateTime{0};
};
TypeScriptexport interface V2NIMMessagePin {
messageRefer: V2NIMMessageRefer
opeartorId: string
serverExtension?: string
createTime: number
updateTime: number
}
TypeScriptinterface V2NIMMessagePin {
messageRefer?: V2NIMMessageRefer;
operatorId?: string;
serverExtension?: string;
createTime?: number;
updateTime?: number;
}
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
消息收藏对象。
Javapublic interface V2NIMCollection {
String getCollectionId();
int getCollectionType();
String getCollectionData();
String getServerExtension();
long getCreateTime();
long getUpdateTime();
String getUniqueId();
}
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
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};
};
TypeScriptexport interface V2NIMCollection {
collectionId: string
collectionType: number
collectionData: string
serverExtension?: string
createTime: number
updateTime: number
uniqueId?: string
}
TypeScriptinterface V2NIMCollection {
collectionId?: string;
collectionType?: number;
collectionData?: string;
serverExtension?: string;
uniqueId?: string;
createTime?: number;
updateTime?: number;
}
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
消息收藏配置参数。
Javapublic class V2NIMAddCollectionParams {
public int getCollectionType() {
return collectionType;
}
public String getCollectionData() {
return collectionData;
}
public String getServerExtension() {
return serverExtension;
}
public String getUniqueId() {
return uniqueId;
}
@Override
public String toString() {
return "V2NIMAddCollectionParams{" +
"collectionType=" + collectionType +
", collectionData='" + collectionData + '\'' +
", serverExtension='" + serverExtension + '\'' +
", uniqueId='" + uniqueId + '\'' +
'}';
}
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);
}
}
}
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
C++struct V2NIMAddCollectionParams {
uint32_t collectionType{0};
nstd::string collectionData;
nstd::optional<nstd::string> serverExtension;
nstd::optional<nstd::string> uniqueId;
};
TypeScriptexport interface V2NIMAddCollectionParams {
collectionType: number
collectionData: string
serverExtension?: string
uniqueId?: string
}
TypeScriptinterface V2NIMAddCollectionParams {
collectionType?: number;
collectionData?: string;
serverExtension?: string;
uniqueId?: string;
}
TypeScriptexport interface V2NIMAddCollectionParams {
collectionType: number
collectionData: string
serverExtension?: string
uniqueId?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
collectionType |
int | 是 | - | 自定义收藏类型,必须大于 0,否则返回 191004 参数错误。 |
collectionData |
String | 是 | - | 收藏数据,上限为 20480 字节。 |
serverExtension |
String | 否 | - | 服务端扩展字段。必须为 JSON 格式封装,多端同步,长度上限为 1024 字节。 |
uniqueId |
String | 否 | - | 去重唯一 ID,如果 ID 相同,则不会新增收藏,只更新之前的收藏内容。 |
V2NIMCollectionOption
分页查询消息收藏选项。
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);
}
}
}
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
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};
};
TypeScriptexport interface V2NIMCollectionOption {
beginTime?: number
endTime?: number
anchorCollection?: V2NIMCollection
direction?: V2NIMQueryDirection
limit?: number
collectionType?: number
}
TypeScriptinterface V2NIMCollectionOption {
beginTime?: number;
endTime?: number;
anchorCollection?: V2NIMCollection;
direction?: V2NIMQueryDirection;
limit?: number;
collectionType?: number;
}
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 ] 为查询范围。
|
direction |
V2NIMQueryDirection |
否 | V2NIM_QUERY_DIRECTION_DESC |
查询方向:按照时间升序或降序。 |
limit |
int | 否 | 100 | 本次查询条数上限,取值范围为 [0,200)。大于等于 200 则返回 191004 参数错误,小于 0 则默认为 100。 |
collectionType |
int | 否 | 0,即查询所有类型 | 收藏类型。 |
V2NIMCollectionListResult
分页查询收藏信息结果。
Javapublic interface V2NIMCollectionListResult {
/**
* 总收藏条数
* @return 条数
*/
int getTotalCount();
/**
* 本次分页查询返回的收藏列表
* @return 收藏列表
*/
List<V2NIMCollection> getCollectionList();
}
C++struct V2NIMCollectionListResult {
uint32_t totalCount{0};
nstd::vector<V2NIMCollection> collectionList;
};
TypeScriptinterface V2NIMCollectionListResult {
totalCount: number;
collectionList: V2NIMCollection[];
}
TypeScriptinterface V2NIMCollectionListResult {
totalCount: number;
collectionList: V2NIMCollection[];
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
totalCount |
int | 是 | - | 总收藏条数。 |
collectionList |
List<V2NIMCollection> | 是 | - | 本次分页查询返回的收藏列表。 |
V2NIMSendMessageParams
消息发送参数配置。
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 = "";
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() {
}
public static V2NIMSendMessageParamsBuilder builder() {
return new V2NIMSendMessageParamsBuilder();
}
public V2NIMSendMessageParamsBuilder withMessageConfig(V2NIMMessageConfig messageConfig) {
this.messageConfig = messageConfig;
return this;
}
public V2NIMSendMessageParamsBuilder withRouteConfig(V2NIMMessageRouteConfig routeConfig) {
this.routeConfig = routeConfig;
return this;
}
public V2NIMSendMessageParamsBuilder withPushConfig(V2NIMMessagePushConfig pushConfig) {
this.pushConfig = pushConfig;
return this;
}
public V2NIMSendMessageParamsBuilder withAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
this.antispamConfig = antispamConfig;
return this;
}
public V2NIMSendMessageParamsBuilder withRobotConfig(V2NIMMessageRobotConfig robotConfig) {
this.robotConfig = robotConfig;
return this;
}
public V2NIMSendMessageParamsBuilder withClientAntispamEnabled(boolean clientAntispamEnabled) {
this.clientAntispamEnabled = clientAntispamEnabled;
return this;
}
public V2NIMSendMessageParamsBuilder withClientAntispamReplace(String clientAntispamReplace) {
this.clientAntispamReplace = clientAntispamReplace;
return this;
}
public V2NIMSendMessageParamsBuilder withAIConfig(V2NIMMessageAIConfigParams aiConfig) {
this.aiConfig = aiConfig;
return this;
}
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);
}
}
}
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
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;
};
TypeScriptinterface V2NIMSendMessageParams {
messageConfig?: V2NIMMessageConfig
routeConfig?: V2NIMMessageRouteConfig
pushConfig?: V2NIMMessagePushConfig
antispamConfig?: V2NIMMessageAntispamConfig
robotConfig?: V2NIMMessageRobotConfig
aiConfig?: V2NIMMessageAIConfigParams
targetConfig?: V2NIMMessageTargetConfig
clientAntispamEnabled?: boolean
clientAntispamReplace?: string
}
TypeScriptinterface V2NIMSendMessageParams {
messageConfig?: V2NIMMessageConfig;
routeConfig?: V2NIMMessageRouteConfig;
pushConfig?: V2NIMMessagePushConfig;
antispamConfig?: V2NIMMessageAntispamConfig;
robotConfig?: V2NIMMessageRobotConfig;
targetConfig?: V2NIMMessageTargetConfig;
clientAntispamEnabled?: boolean;
clientAntispamReplace?: string;
}
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 | 是否启用本地反垃圾。V2NIMClientAntispamOperateType :
|
clientAntispamReplace |
String | 若 clientAntispamEnabled 为 true 则必填 |
"" | 反垃圾命中后替换的文本。 |
aiConfig |
V2NIMMessageAIConfigParams |
否 | - | 数字人请求 LLM 大模型的相关参数。 |
targetConfig |
V2NIMMessageTargetConfig |
否 | - | 发送群消息时,需要指定接收者的定向消息配置参数。 |
V2NIMMessageTargetConfig
群定向消息数据结构。
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() {
if(CollectionUtil.isEmpty(receiverIds)){
return false;
}
return true;
}
}
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
C++struct V2NIMMessageTargetConfig {
bool inclusive{true};
nstd::vector<nstd::string> receiverIds;
bool newMemberVisible{false};
};
TypeScriptinterface V2NIMMessageTargetConfig {
receiverIds: string[]
inclusive: boolean
newMemberVisible?: boolean
}
TypeScriptinterface V2NIMMessageTargetConfig {
inclusive: boolean;
receiverIds: string[];
newMemberVisible?: boolean;
}
TypeScriptinterface V2NIMMessageTargetConfig {
inclusive: boolean;
newMemberVisible?: boolean;
receiverIds: string[];
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
inclusive |
Boolean | 是 | true | 群定向消息成员列表是否为可见列表。默认为 true,即 receiver_account_ids 为可见(接收)列表。receiver_account_ids 之外的成员为不可见列表。若设置为 false,则相反。inclusive 设置为 false。 |
receiverIds |
List<String> | 是 | - | 群定向消息成员列表,即指定接收群消息的群成员列表。inclusive 为 true,当前列表为可见(接收)列表。inclusive 为 false,当前列表为不可见(不接收)列表。 |
newMemberVisible |
Boolean | 否 | false | 新进群成员是否可见该消息。默认为 false,即新进群成员不可以查看该群定向消息。若设置为 true,则新进群成员若可以查询该定向消息,可以通过云端历史相关接口查询到该消息。inclusive 为 true 时,不能同时设置 visible_to_new_member 为 true。即发送定向列表为可见的定向消息时,只能由定向列表中成员接收和查看。visible_to_new_member 设置为 true。 |
V2NIMModifyMessageParams
消息更新参数配置。
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;
}
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() {
}
public static V2NIMModifyMessageParamsBuilder builder() {
return new V2NIMModifyMessageParamsBuilder();
}
public V2NIMModifyMessageParamsBuilder withSubType(int subType) {
this.subType = subType;
return this;
}
public V2NIMModifyMessageParamsBuilder withText(String text) {
this.text = text;
return this;
}
public V2NIMModifyMessageParamsBuilder withAttachment(V2NIMMessageAttachment attachment) {
this.attachment = attachment;
return this;
}
public V2NIMModifyMessageParamsBuilder withServerExtension(String serverExtension) {
this.serverExtension = serverExtension;
return this;
}
public V2NIMModifyMessageParamsBuilder withAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
this.antispamConfig = antispamConfig;
return this;
}
public V2NIMModifyMessageParamsBuilder withRouteConfig(V2NIMMessageRouteConfig routeConfig) {
this.routeConfig = routeConfig;
return this;
}
public V2NIMModifyMessageParamsBuilder withPushConfig(V2NIMMessagePushConfig pushConfig) {
this.pushConfig = pushConfig;
return this;
}
public V2NIMModifyMessageParamsBuilder withClientAntispamEnabled(boolean clientAntispamEnabled) {
this.clientAntispamEnabled = clientAntispamEnabled;
return this;
}
public V2NIMModifyMessageParamsBuilder withClientAntispamReplace(String clientAntispamReplace) {
this.clientAntispamReplace = clientAntispamReplace;
return this;
}
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;
}
}
}
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
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;
};
TypeScriptexport type V2NIMModifyMessageParams = {
subType?: number
text?: string
attachment?: V2NIMMessageAttachment
serverExtension?: string
antispamConfig?: V2NIMMessageAntispamConfig
routeConfig?: V2NIMMessageRouteConfig
pushConfig?: V2NIMMessagePushConfig
clientAntispamEnabled?: boolean
clientAntispamReplace?: string
}
TypeScriptinterface V2NIMModifyMessageParams {
subType?: number;
text?: string;
attachment?: V2NIMMessageAttachment;
serverExtension?: string;
antispamConfig?: V2NIMMessageAntispamConfig;
routeConfig?: V2NIMMessageRouteConfig;
clientAntispamEnabled?: boolean;
clientAntispamReplace?: string;
}
TypeScriptinterface V2NIMModifyMessageParams {
antispamConfig?: V2NIMMessageAntispamConfig;
attachment?: V2NIMMessageAttachment;
clientAntispamEnabled?: boolean;
clientAntispamReplace?: string;
pushConfig?: V2NIMMessagePushConfig;
routeConfig?: V2NIMMessageRouteConfig;
serverExtension?: string;
subType?: number;
text?: string;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
subType |
int/undefined | 否 | - | 自定义消息子类型,0 表示无消息子类型。 |
text |
String | 否 | - | 消息文本内容,仅文本类型的消息有该字段。 |
attachment |
V2NIMMessageAttachment |
否 | - | 消息附件,仅图片、语音、视频、文件类型消息有该字段。根据消息类型继承实现。 |
serverExtension |
String | 否 | - | 消息服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。 |
routeConfig |
V2NIMMessageRouteConfig |
否 | - | 消息事件抄送相关配置。 |
pushConfig |
V2NIMMessagePushConfig |
否 | - | 消息第三方推送相关配置。 第三方推送功能需要在 网易云信控制台 上 配置。 |
antispamConfig |
V2NIMMessageAntispamConfig |
否 | - | 消息反垃圾相关配置,包括本地反垃圾或安全通配置,均需要在 网易云信控制台 上 开通。 |
clientAntispamEnabled |
boolean | 否 | false | 是否启用本地反垃圾。V2NIMClientAntispamOperateType :
|
clientAntispamReplace |
String | 若 clientAntispamEnabled 为 true 则必填 |
"" | 反垃圾命中后替换的文本。 |
V2NIMMessageRefer
消息参考信息。
Javapublic interface V2NIMMessageRefer extends Serializable {
String getSenderId();
String getReceiverId();
String getMessageClientId();
String getMessageServerId();
V2NIMConversationType getConversationType();
String getConversationId();
long getCreateTime();
}
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
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};
};
TypeScriptexport interface V2NIMMessageRefer {
senderId: string
receiverId: string
messageClientId: string
messageServerId: string
createTime: number
conversationType: V2NIMConversationType
conversationId: string
}
TypeScriptinterface V2NIMMessageRefer {
senderId?: string;
receiverId?: string;
messageClientId?: string;
messageServerId?: string;
conversationType?: V2NIMConversationType;
conversationId?: string;
createTime?: number;
}
TypeScriptexport interface V2NIMMessageRefer {
senderId: string
receiverId: string
messageClientId: string
messageServerId: string
createTime: number
conversationType: V2NIMConversationType
conversationId: string
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
senderId |
String | 是 | 消息发送方账号(accountId) |
receiverId |
String | 是 | 消息接收方账号 |
messageClientId |
String | 是 | 客户端消息 ID,不多端同步。 |
messageServerId |
String | 是 | 服务端消息 ID,多端同步。 |
conversationType |
V2NIMConversationType |
是 | 会话类型。 |
conversationId |
String | 是 | 会话 ID |
createTime |
long | 是 | 消息时间戳,单位毫秒。 |
V2NIMMessageAttachment
消息附件对象。
Javapublic interface V2NIMMessageAttachment extends Serializable {
String getRaw();
}
Objective-C@interface V2NIMMessageAttachment: NSObject
@property(nonnull,nonatomic,strong) NSString *raw;
@end
C++struct V2NIMMessageAttachment {
nstd::string raw;
virtual ~V2NIMMessageAttachment() = default;
};
TypeScriptexport interface V2NIMMessageAttachment {
raw: string
}
TypeScriptinterface V2NIMMessageAttachment {
raw?: string;
}
TypeScriptexport interface V2NIMMessageAttachment {
raw: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
raw |
String | 是 | - | 消息附件,建议为 JSON 格式。 |
V2NIMMessageCustomAttachment
自定义消息附件对象。继承自 V2NIMMessageAttachment
Javapublic interface V2NIMMessageCustomAttachment extends V2NIMMessageAttachment {
void parse(String attach);
}
Objective-C@interface V2NIMMessageCustomAttachment : V2NIMMessageAttachment
- (void)parse:(NSString *)attach;
@end
C++struct V2NIMMessageCustomAttachment : public V2NIMMessageAttachment {
V2NIMMessageCustomAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CUSTOM; }
virtual void parse(const nstd::string& attach) = 0;
};
TypeScriptexport interface V2NIMMessageCustomAttachment {
raw: string
}
TypeScriptinterface V2NIMMessageCustomAttachment {
raw: string;
}
成员函数
- parse:解析自定义附件
参数名称 | 类型 | 说明 |
---|---|---|
attach |
String | 解析的自定义消息附件内容。 |
V2NIMMessageCustomAttachmentParser
自定义消息附件解析器。
Javapublic interface V2NIMMessageCustomAttachmentParser {
V2NIMMessageCustomAttachment parse(int subType,String attach);
}
Objective-C@protocol V2NIMMessageCustomAttachmentParser <NSObject>
@required
- (nullable id)parse:(int)subType attach:(NSString *)attach;
C++struct V2NIMMessageCustomAttachmentParser {
virtual nstd::shared_ptr<V2NIMMessageAttachment> parse(const nstd::string& attach, const int32_t& subType) = 0;
virtual ~V2NIMMessageCustomAttachmentParser() = default;
};
TypeScriptexport type V2NIMMessageCustomAttachmentParser = (subType: number, attachRaw: string) => V2NIMMessageCustomAttachment
TypeScriptV2NIMMessageCustomAttachmentParser: ((subType: number, attachRaw: string) => V2NIMMessageCustomAttachment)
成员函数
- parse:解析自定义附件
参数名称 | 类型 | 说明 |
---|---|---|
subType |
int | 自定义消息子类型。 |
attach |
String | 解析的自定义消息附件内容。 |
V2NIMDownloadMessageAttachmentParams
下载消息附件的请求配置参数。
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);
}
}
}
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
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;
};
TypeScriptinterface V2NIMDownloadMessageAttachmentParams {
attachment: V2NIMMessageAttachment;
type: V2NIMDownloadAttachmentType;
thumbSize?: V2NIMSize;
messageClientId?: string;
saveAs?: string;
}
TypeScriptinterface V2NIMDownloadMessageAttachmentParams {
attachment: V2NIMMessageAttachment;
messageClientId?: string;
saveAs?: string;
thumbSize?: V2NIMSize;
type: V2NIMDownloadAttachmentType;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
attachment |
V2NIMMessageAttachment | 是 | - | 需要下载的附件。 |
type |
V2NIMDownloadAttachmentType | 是 | V2NIM_DOWNLOAD_ATTACHMENT_TYPE_SOURCE(原始文件) | 下载附件的类型。包括原始文件、缩略图、视频封面。 |
thumbSize |
V2NIMSize | 否 | {150,0} 内置默认值,不是在声明时指定的,而是运行时根据用户情况判断 |
若下载的是缩略图或者视频封面,通过该参数指定缩略图大小或视频封面大小。 |
messageClientId |
String | 否 | - | 若指定该参数并且下载的是原始文件,则 SDK 会将下载完成后的本地附件保存路径更新到消息数据库中,下一次查询时将直接返回对应的路径。 |
saveAs |
String | 否 | - | 附件保存路径,如未指定 SDK 将下载到登录用户缓存目录,如指定该参数则以指定的路径为准。 |
V2NIMGetMediaResourceInfoResult
下载消息附件的返回结果。
Javapublic interface V2NIMGetMediaResourceInfoResult {
String getUrl();
Map<String, String> getAuthHeaders();
}
Objective-C@interface V2NIMGetMediaResourceInfoResult : NSObject
@property(nonatomic,copy,readonly)NSString *url;
@property(nonatomic,strong,readonly)NSDictionary *authHeaders;
@end
C++struct V2NIMGetMediaResourceInfoResult {
nstd::string url;
nstd::map<nstd::string, nstd::string> authHeaders;
};
TypeScriptexport type V2NIMGetMediaResourceInfoResult = {
url: string
}
TypeScriptinterface V2NIMGetMediaResourceInfoResult {
url: string;
authHeaders: object[];
}
TypeScriptinterface V2NIMGetMediaResourceInfoResult {
authHeaders?: Map<string, string>;
url: string;
}
成员参数
名称 | 类型 | 是否必填 | 是否只读 | 说明 |
---|---|---|---|---|
url |
String | 是 | 是 | 附件资源完整下载地址。 |
authHeaders |
Map<String, String> | 否 | 是 | 下载该资源所需的鉴权信息,当列表为空时则代表不需要鉴权,若不为空则需要将该列表添加到请求时的 Header 中。 |
V2NIMSize
二维平面大小。
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);
}
}
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
C++struct V2NIMSize {
int32_t width{0};
int32_t height{0};
};
TypeScriptexport type V2NIMSize = { height?: number; width?: number }
TypeScriptinterface V2NIMSize {
width: number;
height: number;
}
TypeScriptinterface V2NIMSize {
height?: number;
width?: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
width |
long | 是 | 0 | 二维平面宽度。 |
height |
long | 是 | 0 | 二维平面高度。 |
V2NIMMessageFileAttachment
文件类型消息的附件对象,继承自 V2NIMMessageAttachment。
Javapublic interface V2NIMMessageFileAttachment extends V2NIMMessageAttachment {
String getPath();
long getSize();
String getMd5();
String getUrl();
String getExt();
String getName();
@NonNull
String getSceneName();
V2NIMMessageAttachmentUploadState getUploadState();
}
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
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};
};
TypeScriptexport interface V2NIMMessageFileAttachment extends V2NIMMessageAttachment {
file?: File
path?: string
size: number
url: string
md5?: string
ext: string
name: string
sceneName: string
uploadState: V2NIMMessageAttachmentUploadState
}
TypeScriptinterface V2NIMMessageFileAttachment {
raw?: string;
size?: number;
md5?: string;
url?: string;
name?: string;
path?: string;
ext?: string;
sceneName?: string;
uploadState?: V2NIMMessageAttachmentUploadState;
}
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 对象。path 选其一设置。 |
size |
long | 是 | - | 文件大小。 |
md5 |
String | 是 | - | 文件内容 MD5 值。 |
url |
String | - | - | 文件服务器路径。 |
ext |
String | 否 | null | 文件扩展名,例如:.png 、.txt 等。 |
name |
String | 是 | - | 文件显示名。包含扩展名,例如:1.png 、2.txt 等。 |
sceneName |
String | - | V2NIMStorageSceneConfig.DEFAULT_IM 对应的场景名 |
网易对象存储 NOS 文件存储场景名。若使用自定义的存储场景,需要先调用 V2NIMStorageService.addCustomStorageScene 添加自定义存储场景。 |
uploadState |
V2NIMMessageAttachmentUploadState |
- | - | 消息附件上传状态。 |
V2NIMMessageImageAttachment
图片附件对象,继承自 V2NIMMessageFileAttachment
。
Javapublic interface V2NIMMessageImageAttachment extends V2NIMMessageFileAttachment {
int getWidth();
int getHeight();
}
Objective-C@interface V2NIMMessageImageAttachment : V2NIMMessageFileAttachment
@property(nonatomic,assign,readonly) int width;
@property(nonatomic,assign,readonly) int height;
@end
C++struct V2NIMMessageImageAttachment : public V2NIMMessageFileAttachment {
uint32_t width{0};
uint32_t height{0};
};
TypeScriptexport interface V2NIMMessagImageAttachment extends V2NIMMessageFileAttachment {
width: number
height: number
}
TypeScriptinterface V2NIMMessageImageAttachment {
raw?: string;
size?: number;
md5?: string;
url?: string;
name?: string;
path?: string;
ext?: string;
sceneName?: string;
uploadState?: V2NIMMessageAttachmentUploadState;
width?: number;
height?: number;
}
TypeScriptinterface V2NIMMessageImageAttachment {
ext?: string;
height: number;
md5?: string;
name?: string;
path?: string;
raw?: string;
sceneName?: string;
size?: number;
uploadState: V2NIMMessageAttachmentUploadState;
url?: string;
width: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
width |
int | 是 | - | 图片宽度,单位像素。 |
height |
int | 是 | - | 图片高度,单位像素。 |
V2NIMMessageAudioAttachment
语音附件对象,继承自 V2NIMMessageFileAttachment
。
Javapublic interface V2NIMMessageAudioAttachment extends V2NIMMessageFileAttachment {
int getDuration();
}
Objective-C@interface V2NIMMessageAudioAttachment : V2NIMMessageFileAttachment
@property(nonatomic,assign,readwrite) NSUInteger duration;
@end
C++struct V2NIMMessageAudioAttachment : public V2NIMMessageFileAttachment {
uint32_t duration{0};
};
TypeScriptexport interface V2NIMMessageAudioAttachment extends V2NIMMessageFileAttachment {
duration: number
}
TypeScriptinterface V2NIMMessageAudioAttachment {
raw?: string;
size?: number;
md5?: string;
url?: string;
name?: string;
path?: string;
ext?: string;
sceneName?: string;
uploadState?: V2NIMMessageAttachmentUploadState;
duration?: number;
}
TypeScriptexport interface V2NIMMessageAudioAttachment extends V2NIMMessageFileAttachment {
duration: number
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
duration |
int | 是 | - | 语音文件时长,单位为毫秒。 |
V2NIMMessageVideoAttachment
视频附件对象,继承自 V2NIMMessageFileAttachment
。
Javapublic interface V2NIMMessageVideoAttachment extends V2NIMMessageFileAttachment {
int getDuration();
int getWidth();
int getHeight();
}
Objective-C@interface V2NIMMessageVideoAttachment : V2NIMMessageFileAttachment
@property(nonatomic,assign) NSUInteger duration;
@property(nonatomic,assign) NSInteger width;
@property(nonatomic,assign) NSInteger height;
@end
C++struct V2NIMMessageVideoAttachment : public V2NIMMessageFileAttachment {
uint32_t duration{0};
uint32_t width{0};
uint32_t height{0};
};
TypeScriptexport interface V2NIMMessageVideoAttachment extends V2NIMMessageFileAttachment {
duration: number
width: number
height: number
}
TypeScriptnterface V2NIMMessageVideoAttachment {
raw?: string;
size?: number;
md5?: string;
url?: string;
name?: string;
path?: string;
ext?: string;
sceneName?: string;
uploadState?: V2NIMMessageAttachmentUploadState;
duration?: number;
width?: number;
height?: number;
}
TypeScriptexport interface V2NIMMessageVideoAttachment extends V2NIMMessageFileAttachment {
duration: number
width: number
height: number
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
duration |
int | 是 | - | 视频文件时长,单位为毫秒。 |
width |
int | 是 | - | 视频宽度,单位像素。 |
height |
int | 是 | - | 视频高度,单位像素。 |
V2NIMMessageCallAttachment
话单消息附件对象,继承自 V2NIMMessageAttachment
。
Javapublic interface V2NIMMessageCallAttachment extends V2NIMMessageAttachment {
int getType();
String getChannelId();
int getStatus();
List<V2NIMMessageCallDuration> getDurations();
}
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
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;
};
TypeScriptinterface V2NIMMessageCallAttachment extends V2NIMMessageAttachment {
type: number
channelId: string
status: number
durations: V2NIMMessageCallDuration[]
text: string
}
TypeScriptinterface V2NIMMessageCallAttachment {
raw?: string;
type: number;
channelId: string;
status: number;
durations: V2NIMMessageCallDuration[];
text: string;
}
TypeScriptinterface V2NIMMessageCallAttachment {
channelId: string;
durations: V2NIMMessageCallDuration[];
raw?: string;
status: number;
type: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
type |
Integer | 是 | - | 话单类型,业务侧可自定义,网易云信不校验内容。建议设置为: |
channelId |
String | 是 | - | 话单频道 ID,网易云信不校验内容。 |
status |
Integer | 是 | - | 通话状态,业务侧可自定义状态,网易云信不校验内容。建议设置为: |
duration |
List<V2NIMMessageCallDuration> | 是 | - | 通话成员时长列表,网易云信不校验内容。 |
V2NIMMessageCallDuration
话单消息单人通话时长数据结构。
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;
}
}
Objective-C@interface V2NIMMessageCallDuration : NSObject
@property(nullable,nonatomic,strong) NSString *accountId;
@property(nonatomic,assign) NSInteger duration;
@end
C++struct V2NIMMessageCallDuration {
nstd::string accountId;
uint32_t duration;
};
TypeScripttype V2NIMMessageCallDuration = {
accountId: string
duration: number
}
TypeScriptinterface V2NIMMessageCallDuration {
accountId: string;
duration: number;
}
TypeScriptinterface V2NIMMessageCallDuration {
accountId: string;
duration: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
accountId |
string | 是 | - | 话单对应成员的账号 ID。 |
duration |
Integer | 是 | - | 通话时长。 |
V2NIMMessageLocationAttachment
地理位置附件对象,继承自 V2NIMMessageAttachment
。
Javapublic interface V2NIMMessageLocationAttachment extends V2NIMMessageAttachment {
double getLatitude();
double getLongitude();
String getAddress();
}
Objective-C@interface V2NIMMessageLocationAttachment : V2NIMMessageAttachment
@property(nonatomic,assign) double longitude;
@property(nonatomic,assign) double latitude;
@property(nonnull,nonatomic,strong) NSString *address;
@end
C++struct V2NIMMessageLocationAttachment : public V2NIMMessageAttachment {
double latitude{0};
double longitude{0};
nstd::string address;
};
TypeScriptexport interface V2NIMMessageLocationAttachment extends V2NIMMessageAttachment {
latitude: number
longitude: number
address: string
}
TypeScriptinterface V2NIMMessageLocationAttachment {
raw?: string;
latitude?: number;
longitude?: number;
address?: string;
}
TypeScriptexport interface V2NIMMessageLocationAttachment extends V2NIMMessageAttachment {
latitude: number
longitude: number
address: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
latitude |
Double | 是 | - | 地理位置纬度。 |
longitude |
Double | 是 | - | 地理位置经度。 |
address |
String | 是 | - | 地理位置描述。 |
V2NIMMessageNotificationAttachment
通知附件对象,继承自 V2NIMMessageAttachment
。
Javapublic interface V2NIMMessageNotificationAttachment extends V2NIMMessageAttachment {
V2NIMMessageNotificationType getType();
String getServerExtension();
List<String> getTargetIds();
boolean isChatBanned();
V2NIMUpdatedTeamInfo getUpdatedTeamInfo();
}
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
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;
};
TypeScriptexport interface V2NIMMessageNotificationAttachment extends V2NIMMessageAttachment {
type: V2NIMMessageNotificationType
serverExtension?: string
targetIds?: string[]
chatBanned?: boolean
updatedTeamInfo?: V2NIMUpdatedTeamInfo
}
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
消息发送成功结果回包。
Javapublic interface V2NIMSendMessageResult {
V2NIMMessage getMessage();
String getAntispamResult();
V2NIMClientAntispamResult getClientAntispamResult();
}
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
C++struct V2NIMSendMessageResult {
V2NIMMessage message;
nstd::optional<nstd::string> antispamResult;
nstd::optional<V2NIMClientAntispamResult> clientAntispamResult;
};
TypeScriptexport interface V2NIMSendMessageResult {
message: V2NIMMessage
callbackExtension?: string
antispamResult?: string
clientAntispamResult?: V2NIMClientAntispamResult
}
TypeScriptinterface V2NIMSendMessageResult {
message?: V2NIMMessage;
antispamResult?: string;
clientAntispamResult?: V2NIMClientAntispamResult;
}
TypeScriptexport interface V2NIMSendMessageResult {
message: V2NIMMessage
callbackExtension?: string
antispamResult?: string
clientAntispamResult?: V2NIMClientAntispamResult
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
message |
V2NIMMessage |
是 | 消息对象。 |
antispamResult |
String | 是 | 安全通反垃圾检测结果。 |
clientAntispamResult |
V2NIMClientAntispamResult |
是 | 本地反垃圾结果。 |
V2NIMModifyMessageResult
消息更新成功结果回包。
Javapublic interface V2NIMModifyMessageResult {
V2NIMMessage getMessage();
int getErrorCode();
String getAntispamResult();
V2NIMClientAntispamResult getClientAntispamResult();
}
Objective-C@interface V2NIMModifyMessageResult: NSObject
@property (nonatomic,readonly,strong) V2NIMMessage *message;
@property (nonatomic,readonly,copy) NSString *antispamResult;
@property (nonatomic,readonly,strong) V2NIMClientAntispamResult *clientAntispamResult;
@end
C++struct V2NIMModifyMessageResult {
V2NIMMessage message;
int32_t errorCode{V2NIM_ERROR_CODE_SUCCESS};
nstd::string antispamResult;
V2NIMClientAntispamResult clientAntispamResult;
};
TypeScriptexport type V2NIMModifyMessageResult = {
errorCode: number
message?: V2NIMMessage
antispamResult?: string
clientAntispamResult?: V2NIMClientAntispamResult
}
TypeScriptinterface V2NIMModifyMessageResult {
message: V2NIMMessage;
errorCode: number;
antispamResult: string;
clientAntispamResult: V2NIMClientAntispamResult;
}
TypeScriptinterface V2NIMModifyMessageResult {
antispamResult?: string;
clientAntispamResult?: V2NIMClientAntispamResult;
errorCode: number;
message?: V2NIMMessage;
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
message |
V2NIMMessage |
是 | 更新成功后的消息对象。 |
errorCode |
Int | 是 | 默认为 200。如果此错误码为非 200,表示修改消息失败(例如触发云端反垃圾),此时修改成功后的消息体返回为 null。 |
antispamResult |
String | 是 | 安全通反垃圾检测结果。 |
clientAntispamResult |
V2NIMClientAntispamResult |
是 | 客户端本地反垃圾结果。 |
V2NIMMessageListOption
消息分页查询选项。
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);
}
}
}
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
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;
V2NIMQueryDirection direction{V2NIM_QUERY_DIRECTION_DESC};
bool strictMode{false};
};
TypeScriptexport interface V2NIMMessageListOption {
conversationId: string
messageTypes?: V2NIMMessageType[]
beginTime?: number
endTime?: number
limit?: number
anchorMessage?: V2NIMMessage
direction?: V2NIMQueryDirection
}
TypeScriptinterface V2NIMMessageListOption {
messageTypes?: V2NIMMessageType[];
conversationId?: string;
beginTime?: number;
endTime?: number;
limit?: number;
anchorMessage?: V2NIMMessage;
direction?: V2NIMQueryDirection;
strictMode?: boolean;
}
TypeScriptexport interface V2NIMMessageListOption {
conversationId: string
messageTypes?: V2NIMMessageType[]
beginTime?: number
endTime?: number
limit?: number
anchorMessage?: V2NIMMessage
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 ] 为查询范围。
|
direction |
V2NIMQueryDirection |
否 | V2NIM_QUERY_DIRECTION_DESC |
查询方向:按照时间升序或降序。 |
strictmode |
boolean | 否 | false | 严格模式。 |
onlyQueryLocal |
boolean | 否 | true | 是否只查询本地数据。 |
V2NIMThreadMessageListOption
Thread 消息分页查询选项。
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;
}
}
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
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};
};
TypeScriptinterface V2NIMThreadMessageListOption {
messageRefer: V2NIMMessageRefer
beginTime?: number
endTime?: number
limit?: number
direction?: V2NIMQueryDirection
excludeMessageServerId?: string
}
TypeScriptinterface V2NIMThreadMessageListOption {
messageRefer?: V2NIMMessageRefer;
begin?: number;
end?: number;
excludeMessageServerId?: string;
limit?: number;
direction?: V2NIMQueryDirection;
}
TypeScriptinterface V2NIMThreadMessageListOption {
beginTime?: number;
direction?: V2NIMQueryDirection;
endTime?: number;
excludeMessageServerId?: string;
limit?: number;
messageRefer: V2NIMMessageRefer;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
messageRefer |
V2NIMMessageRefer > |
是 | - | Thread 消息参考信息,支持根据 Thread 根消息的参考信息查询本地子消息。 |
beginTime |
long | 否 | 0 | 查询开始时间,该字段必须小于等于 endTime 。 |
endTime |
long | 否 | 0 | 查询结束时间,字段必须大于等于 beginTime ,默认为系统当前时间。 |
limit |
Integer | 否 | 50 | 本次查询条数上限,取值范围为 [0,100]。传入小于 0 则默认为 50。 |
excludeMessageServerId |
String | 否 | - | 锚点消息的 ServerId。该消息必须处于端点,即消息时间必须等于 beginTime 或 endTime 。如果是合法的消息 ID 则表示排除该消息,否则不排除。 |
direction |
V2NIMQueryDirection |
否 | V2NIM_QUERY_DIRECTION_DESC |
消息查询方向:按照时间升序(ASC)或降序(DESC)。 |
V2NIMThreadMessageListResult
Thread 消息查询结果。
Javapublic interface V2NIMThreadMessageListResult {
V2NIMMessage getMessage();
long getTimestamp();
int getReplyCount();
List<V2NIMMessage> getReplyList();
}
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
C++struct V2NIMThreadMessageListResult {
V2NIMMessage message;
uint64_t timestamp{0};
uint32_t replyCount{0};
nstd::vector<V2NIMMessage> replyList;
};
TypeScriptinterface V2NIMThreadMessageListResult {
message: V2NIMMessage
timestamp: number
replyCount: number
replyList: V2NIMMessage[]
}
TypeScriptinterface V2NIMThreadMessageListResult {
message?: V2NIMMessage;
timestamp?: number;
replyCount?: number;
replyList?: V2NIMMessage[];
}
TypeScriptinterface V2NIMThreadMessageListResult {
message: V2NIMMessage;
replyCount: number;
replyList: V2NIMMessage[];
timestamp: number;
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
message |
V2NIMMessage |
是 | - | Thread 消息根消息。 |
timestamp |
long | 是 | - | 获取 Thread 消息中最后一条消息的时间戳。 |
replyCount |
Integer | 是 | - | 获取 Thread 消息中的总回复数,Thread 消息不计入总数。 |
replyList |
List<V2NIMMessage > |
是 | - | 消息回复列表。 |
V2NIMP2PMessageReadReceipt
单聊消息已读回执对象。
Javapublic interface V2NIMP2PMessageReadReceipt {
String getConversationId();
long getTimestamp();
}
Objective-C@interface V2NIMP2PMessageReadReceipt : NSObject
@property(nullable,nonatomic,strong,readonly) NSString *conversationId;
@property(nonatomic,assign,readonly) NSTimeInterval timestamp;
@end
C++struct V2NIMP2PMessageReadReceipt {
nstd::string conversationId;
uint64_t timestamp{0};
};
TypeScriptexport interface V2NIMP2PMessageReadReceipt {
conversationId: string
timestamp: number
}
TypeScriptinterface V2NIMP2PMessageReadReceipt {
conversationId?: string;
timestamp?: number;
}
TypeScriptexport interface V2NIMP2PMessageReadReceipt {
conversationId: string
timestamp: number
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
conversationId |
String | 是 | 消息所属的会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType )| 聊天对象账号(accountId)或群组 ID。 |
timestamp |
long | 是 | 最后一条已读消息的时间戳,早于该消息都判定为已读消息。 |
V2NIMTeamMessageReadReceipt
群组消息已读回执对象。
Javapublic interface V2NIMTeamMessageReadReceipt {
String getConversationId();
String getMessageClientId();
String getMessageServerId();
int getReadCount();
int getUnreadCount();
String getLatestReadAccount();
}
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
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;
};
TypeScriptexport interface V2NIMTeamMessageReadReceipt {
conversationId: string
messageServerId: string
messageClientId: string
readCount: number
unreadCount: number
latestReadAccount?: string
}
TypeScriptinterface V2NIMTeamMessageReadReceipt {
conversationId?: string;
messageServerId?: string;
messageClientId?: string;
readCount?: number;
unreadCount?: number;
latestReadAccount?: string;
}
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
群组消息已读回执详情。
Javapublic interface V2NIMTeamMessageReadReceiptDetail {
V2NIMTeamMessageReadReceipt getReadReceipt();
List<String> getReadAccountList();
List<String> getUnreadAccountList();
}
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
C++struct V2NIMTeamMessageReadReceiptDetail {
V2NIMTeamMessageReadReceipt readReceipt;
nstd::vector<nstd::string> readAccountList;
nstd::vector<nstd::string> unreadAccountList;
};
TypeScriptexport interface V2NIMTeamMessageReadReceiptDetail {
readReceipt: V2NIMTeamMessageReadReceipt
readAccountList: string[]
unreadAccountList: string[]
}
TypeScriptinterface V2NIMTeamMessageReadReceiptDetail {
readReceipt?: V2NIMTeamMessageReadReceipt;
readAccountList?: string[];
unreadAccountList?: string[];
}
TypeScriptexport interface V2NIMTeamMessageReadReceiptDetail {
readReceipt: V2NIMTeamMessageReadReceipt
readAccountList: string[]
unreadAccountList: string[]
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
readReceipt |
V2NIMTeamMessageReadReceipt |
是 | 群组消息已读回执对象。 |
readAccountList |
List<String> | 是 | 群组消息已读账号列表。 |
unreadAccountList |
List<String> | 是 | 群组消息未读账号列表。 |
V2NIMMessageRevokeParams
消息撤回配置参数。
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);
}
}
}
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
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;
};
TypeScriptexport interface V2NIMMessageRevokeParams {
postscript?: string
serverExtension?: string
pushContent?: string
pushPayload?: string
env?: string
}
TypeScriptinterface V2NIMMessageRevokeParams {
postscript?: string;
serverExtension?: string;
pushContent?: string;
pushPayload?: string;
env?: string;
}
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
消息撤回通知。
Javapublic interface V2NIMMessageRevokeNotification extends Serializable {
V2NIMMessageRefer getMessageRefer();
String getServerExtension();
String getRevokeAccountId();
String getPostscript();
V2NIMMessageRevokeType getRevokeType();
String getCallbackExtension();
}
objective-c@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
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;
};
TypeScriptexport interface V2NIMMessageRevokeNotification {
messageRefer: V2NIMMessageRefer
serverExtension?: string
revokeAccountId: string
postscript?: string
revokeType: V2NIMMessageRevokeType
callbackExtension?: string
}
TypeScriptinterface V2NIMMessageRevokeNotification {
messageRefer?: V2NIMMessageRefer;
serverExtension?: string;
postscript?: string;
revokeAccountId?: string;
revokeType?: V2NIMMessageRevokeType;
callbackExtension?: string;
}
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
消息删除通知。
Javapublic interface V2NIMMessageDeletedNotification {
V2NIMMessageRefer getMessageRefer();
long getDeleteTime();
String getServerExtension();
}
Objective-C@interface V2NIMMessageDeletedNotification : NSObject
@property(nonatomic,strong,readonly) V2NIMMessageRefer *messageRefer;
@property(nonatomic,assign,readonly) NSTimeInterval deleteTime;
@property(nonatomic,strong,readonly) NSString *serverExtension;
@end
C++struct V2NIMMessageDeletedNotification {
V2NIMMessageRefer messageRefer;
uint64_t deleteTime{0};
nstd::optional<nstd::string> serverExtension;
};
TypeScriptexport interface V2NIMMessageDeletedNotification {
messageRefer: V2NIMMessageRefer
deleteTime: number
serverExtension?: string
}
TypeScriptinterface V2NIMMessageDeletedNotification {
messageRefer?: V2NIMMessageRefer;
deleteTime?: number;
serverExtension?: string;
}
TypeScriptexport interface V2NIMMessageDeletedNotification {
messageRefer: V2NIMMessageRefer
deleteTime: number
serverExtension?: string
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
messageRefer |
V2NIMMessageRefer |
是 | 被删除消息的参考信息。 |
deleteTime |
long | 是 | 删除时间戳。 |
serverExtension |
String | 是 | 删除时传入的服务端扩展字段,多端同步。 |
V2NIMMessageQuickCommentNotification
消息快捷评论操作通知。
Javapublic interface V2NIMMessageQuickCommentNotification {
V2NIMMessageQuickCommentType getOperationType();
V2NIMMessageQuickComment getQuickComment();
}
Objective-C@interface V2NIMMessageQuickCommentNotification : NSObject
@property(nonatomic,assign) V2NIMMessageQuickCommentType operationType;
@property(nonatomic,strong) V2NIMMessageQuickComment *quickComment;
@end
C++struct V2NIMMessageQuickCommentNotification {
V2NIMMessageQuickCommentType operationType{V2NIM_MESSAGE_QUICK_COMMENT_TYPE_ADD};
V2NIMMessageQuickComment quickComment;
};
TypeScriptexport interface V2NIMMessageQuickCommentNotification {
operationType: V2NIMMessageQuickCommentType
quickComment: V2NIMMessageQuickComment
}
TypeScriptinterface V2NIMMessageQuickCommentNotification {
operationType?: V2NIMMessageQuickCommentType;
quickComment?: V2NIMMessageQuickComment;
}
TypeScriptexport interface V2NIMMessageQuickCommentNotification {
operationType: V2NIMMessageQuickCommentType
quickComment: V2NIMMessageQuickComment
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
operationType |
V2NIMMessageQuickCommentType |
是 | 快捷评论操作类型。 |
quickComment |
V2NIMMessageQuickComment |
是 | 消息快捷评论信息。 |
V2NIMMessagePinNotification
Pin 消息通知。
Javapublic interface V2NIMMessagePinNotification {
V2NIMMessagePinState getPinState();
V2NIMMessagePin getPin();
}
Objective-C@interface V2NIMMessagePinNotification : NSObject
@property (nullable,nonatomic,strong, readonly) V2NIMMessagePin *pin;
@property (nonatomic,assign, readonly) V2NIMMessagePinState pinState;
@end
C++struct V2NIMMessagePinNotification {
V2NIMMessagePinState pinState{V2NIM_MESSAGE_PIN_STEATE_NOT_PINNED};
V2NIMMessagePin pin;
};
TypeScriptexport interface V2NIMMessagePinNotification {
pinState: V2NIMMessagePinState
pin: {
messageRefer: V2NIMMessageRefer
operatorId: string
serverExtension: string
createTime?: number
updateTime: number
}
}
TypeScriptinterface V2NIMMessagePinNotification {
pinState?: V2NIMMessagePinState;
pin?: V2NIMMessagePin;
}
TypeScriptexport interface V2NIMMessagePinNotification {
pinState: V2NIMMessagePinState
pin: {
messageRefer: V2NIMMessageRefer
operatorId: string
serverExtension: string
createTime?: number
updateTime: number
}
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
pinState |
V2NIMMessagePinState |
是 | Pin 消息状态。 |
pin |
V2NIMMessagePin |
是 | Pin 消息信息。 |
V2NIMClearHistoryMessageOption
历史消息清空选项。
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);
}
}
}
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
C++struct V2NIMClearHistoryMessageOption {
nstd::string conversationId;
bool deleteRoam{true};
bool onlineSync{false};
nstd::optional<nstd::string> serverExtension;
};
TypeScriptexport interface V2NIMClearHistoryMessageOption {
conversationId: string
deleteRoam?: boolean
onlineSync?: boolean
serverExtension?: string
}
TypeScriptinterface V2NIMClearHistoryMessageOption {
conversationId?: string
deleteRoam?: boolean
onlineSync?: boolean
serverExtension?: string
}
TypeScriptexport interface V2NIMClearHistoryMessageOption {
conversationId: string
deleteRoam?: boolean
onlineSync?: boolean
serverExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
conversationId |
String | 是 | - | 历史消息所属的会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType )| 聊天对象账号(accountId)或群组 ID。 |
deleteRoam |
boolean | 否 | true | 是否同步删除漫游消息: |
onlineSync |
boolean | 否 | false | 是否多端同步。 |
serverExtension |
String | 否 | null | 服务端扩展字段。必须为 JSON 格式封装,多端同步。 |
V2NIMClearHistoryNotification
会话历史消息清空通知。
Javapublic interface V2NIMClearHistoryNotification {
String getConversationId();
long getDeleteTime();
String getServerExtension();
}
Objective-C@interface V2NIMClearHistoryNotification : NSObject
@property(nonatomic,strong,readonly) NSString *conversationId;
@property(nonatomic,assign,readonly) NSTimeInterval deleteTime;
@property(nonatomic,strong,readonly) NSString *serverExtension;
@end
C++struct V2NIMClearHistoryNotification {
nstd::string conversationId;
uint64_t deleteTime{0};
nstd::optional<nstd::string> serverExtension;
};
TypeScriptexport interface V2NIMClearHistoryNotification {
conversationId: string
deleteTime: number
serverExtension?: string
}
TypeScriptinterface V2NIMClearHistoryNotification {
conversationId?: string
deleteTime?: number
serverExtension?: string
}
TypeScriptexport interface V2NIMClearHistoryNotification {
conversationId: string
deleteTime: number
serverExtension?: string
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
conversationId |
String | 是 | 会话 ID |
deleteTime |
long | 是 | 清空的时间戳。 |
serverExtension |
String | 是 | 清空时传入的服务端扩展字段,多端同步。 |
V2NIMMessageSearchParams
云端历史消息全文检索查询参数。
超大群不支持历史消息全文检索功能。
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);
}
}
}
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
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;
};
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[]
}
TypeScriptinterface V2NIMMessageSearchParams {
keyword?: string;
beginTime?: number;
endTime?: number;
conversationLimit?: number;
messageLimit?: number;
sortOrder?: V2NIMSortOrder;
p2pAccountIds?: string[];
teamIds?: string[];
senderAccountIds?: string[];
messageTypes?: V2NIMMessageType[];
messageSubTypes?: number[];
}
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 | 本次检索的会话条数上限,最高支持 100 条会话。 |
messageLimit |
int | 否 | 10 | 本次检索返回的消息条数上限:conversationLimit 参数,最高支持 10 条消息。conversationLimit 参数,最高支持 100 条消息。 |
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 或空,即查询所有消息子类型。 | 自定义消息子类型。 |
V2NIMMessageSearchExParams
本地历史消息全文检索查询参数。
Javapublic class V2NIMMessageSearchExParams {
// 搜索 “全部会话” 还是搜索 “指定的会话”
// conversationID 为空(null),搜索全部会话;
// conversationID 不为空,搜索指定会话。
private final String conversationId;
// 最多支持 5 个。当消息发送者以及消息类型均未指定时,必须设置关键字列表;否则,关键字列表可以为空。
private final List<String> keywordList;
// 指定关键字列表匹配类型
// 可设置为 “或” 关系搜索,或 “与” 关系搜索。取值分别为 V2TIM_KEYWORD_MATCH_TYPE_OR 和 V2TIM_KEYWORD_MATCH_TYPE_AND。默认为 “或” 关系搜索。
// 关键字列表为空或为数量为1, 该字段无效
private final V2NIMSearchKeywordMathType keywordMatchType;
// 指定 accountId 发送的消息
// 最多支持 5 个。
// 超过返回参数错误, accountid默认只检查数量, 不检查是否重复
private final List<String> senderAccountIds;
// 根据消息类型检索消息,
// 为null或空列表, 则表示查询所有消息类型
// 关键字不为空时, 不支持检索通知类消息
// 非文本消息,只检索对应检索字段,如果检索字段为空则该消息不回被检索到
private final List<V2NIMMessageType> messageTypes;
// 搜索的起始时间点,
// 默认为 0(从现在开始搜索)。UTC 时间戳,单位:毫秒。
private final long searchStartTime;
// 从起始时间点开始的过去时间范围
// 默认为 0(不限制时间范围)。24 x 60 x 60 x 1000 代表过去一天,单位:毫秒。
private final long searchTimePeriod;
// 搜索的数量
// 最大100
private final int limit;
// 搜索的起始位置,第一次填写空字符串,续拉时填写上一次返回的 V2NIMMessageSearchResult 中的 nextPageToken。
// 两次查询参数必须一致
private final String pageToken;
}
Objective-C/// 消息检索参数
@interface V2NIMMessageSearchExParams : NSObject
/// 搜索 “全部会话” 还是搜索 “指定的会话” conversationId 为空(nil),搜索全部会话;conversationId 不为空,搜索指定会话。
@property (nonatomic,strong,nullable) NSString *conversationId;
/// 最多支持 5 个。当消息发送者以及消息类型均未指定时,必须设置关键字列表;否则,关键字列表可以为空。nil 和count==0 都表示为空
@property (nonatomic,strong,nullable) NSArray<NSString *> *keywordList;
/// 指定关键字列表匹配类型。可设置为 “或” 关系搜索,或 “与” 关系搜索。取值分别为 V2NIM_SEARCH_KEYWORD_MATH_TYPE_OR 和 V2NIM_SEARCH_KEYWORD_MATH_TYPE_AND。默认为 “或” 关系搜索。
@property (nonatomic,assign) V2NIMSearchKeywordMathType keywordMatchType;
/// 指定 accountId 发送的消息。最多支持 5 个。超过返回参数错误, accountid默认只检查数量, 不检查是否重复。nil 和count==0 都表示没有指定人数
///
@property (nonatomic,strong,nullable) NSArray<NSString *> *senderAccountIds;
/// 根据消息类型检索消息,为nil或空列表, 则表示查询所有消息类型。关键字不为空时, 不支持检索通知类消息。非文本消息,只检索对应检索字段,如果检索字段为空则该消息不回被检索到
@property (nonatomic,strong,nullable) NSArray<NSNumber *> *messageTypes;
/// 搜索的起始时间点,默认为 0(从现在开始搜索)。UTC 时间戳,单位:毫秒。
@property (nonatomic,assign) int64_t searchStartTime;
/// 从起始时间点开始的过去时间范围。默认为 0(不限制时间范围)。24 x 60 x 60 x 1000 代表过去一天,单位:毫秒。
@property (nonatomic,assign) int64_t searchTimePeriod;
/// 搜索的数量。最大100
@property (nonatomic,assign) NSInteger limit;
/// 搜索的起始位置,第一次填写空字符串,续拉时填写上一次返回的 V2NIMMessageSearchResult 中的 nextPageToken。两次查询参数必须一致
@property (nonatomic,strong,nullable) NSString *pageToken;
@end
C++struct V2NIMMessageSearchExParams {
nstd::optional<nstd::string> conversationId;
nstd::optional<nstd::vector<nstd::string>> keywordList;
V2NIMSearchKeywordMathType keywordMatchType{V2NIM_SEARCH_KEYWORD_MATH_TYPE_OR};
nstd::optional<nstd::vector<nstd::string>> senderAccountIds;
nstd::optional<nstd::vector<V2NIMMessageType>> messageTypes;
time_t searchStartTime{0};
int64_t searchTimePeriod{0};
uint32_t limit{V2NIM_DEFAULT_SEARCH_LOCAL_MESSAGE_LIST_LIMIT};
nstd::optional<nstd::string> pageToken;
};
TypeScriptinterface V2NIMMessageSearchExParams {
conversationId?: string;
keywordList?: string[];
keywordMatchType: V2NIMSearchKeywordMathType;
senderAccountIds?: string[];
messageTypes?: V2NIMMessageType[];
searchStartTime: number;
searchTimePeriod: number;
limit: number;
pageToken?: string;
}
TypeScriptinterface V2NIMMessageSearchExParams {
conversationId?: string;
keywordList?: string[];
keywordMatchType?: V2NIMSearchKeywordMathType;
limit?: number;
messageTypes?: V2NIMMessageType[];
pageToken?: string;
searchStartTime?: number;
searchTimePeriod?: number;
senderAccountIds?: string[];
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
conversationId |
String | 否 | - | 若为空,则搜索全部会话;若不为空,则搜索传入的指定会话。 |
keywordList |
List<String> | 否 | - | 检索关键字列表,最多支持 5 个。当消息发送者以及消息类型均未指定时,必须设置关键字列表;否则,关键字列表可以为空。 |
keywordMatchType |
V2NIMSearchKeywordMathType |
否 | V2NIM_SEARCH_KEYWORD_MATH_TYPE_OR | 指定关键字列表匹配类型。 可设置为 “或” 关系(V2NIM_SEARCH_KEYWORD_MATH_TYPE_OR,默认)搜索,或 “与” 关系(V2NIM_SEARCH_KEYWORD_MATH_TYPE_AND)搜索。 关键字列表为空或为数量为 1,该字段无效。 |
limit |
int | 否 | 20 | 本次检索返回的消息条数上限,最大为 100。 |
messageTypes |
List<V2NIMMessageType > |
否 | - | 根据消息类型检索消息,为 null 或空列表,则表示查询所有消息类型。 关键字不为空时,不支持检索通知类消息。 非文本消息,只检索对应检索字段,如果检索字段为空则该消息不会被检索到。 |
senderAccountIds |
List<String> | 否 | - | 发送方账号列表。最多传入 5 个账号,否则返回 191004 参数错误。 |
searchStartTime |
long | 否 | 0 | 查询开始时间,UTC 时间戳,单位:毫秒。该字段必须小于等于 endTime 。 |
searchTimePeriod |
long | 否 | 0 | 从起始时间点开始的过去时间范围,UTC 时间戳,单位:毫秒。该字段必须大于等于 beginTime 。 |
pageToken |
String | 否 | - | 搜索的起始位置。第一次填传入空字符串,后续填写上一次返回结果中的 nextPageToken 。 |
V2NIMMessageSearchResult
本地历史消息全文检索查询结果。
Javapublic interface V2NIMMessageSearchResult {
// 满足检索条件的所有消息数量
int getCount();
// 单个会话的返回结果
// 如果查询会话id不会空, 则返回items会对应会话按指定条数检索出来的消息
// 如果会话id为空,则为每一个会话检索出来的内容
List<V2NIMMessageSearchItem> getItems();
// 下次请求的token
// 两次查询参数必须一致
String getNextPageToken();
}
Objective-C/// 检索返回结果
@interface V2NIMMessageSearchResult : NSObject
/// 满足检索条件的所有消息数量
@property (nonatomic,assign,readonly) NSInteger count;
/// 单个会话的返回结果:如果查询会话id不会空, 则返回items会对应会话按指定条数检索出来的消息。如果会话id为空,则为每一个会话检索出来的内容。单个items查出的消息按从新到旧排序。多个会话的返回结果:按每个会话的最新消息从新到旧排序
@property (nonatomic,strong,readonly) NSArray<V2NIMMessageSearchItem *> *items;
/// 下次请求的token,两次查询参数必须一致
@property (nonatomic,strong,nullable,readonly) NSString *nextPageToken;
@end
C++struct V2NIMMessageSearchResult {
uint32_t count{0};
nstd::vector<V2NIMMessageSearchItem> items;
nstd::string nextPageToken;
};
TypeScriptinterface V2NIMMessageSearchResult {
count: number;
items: V2NIMMessageSearchItem[];
nextPageToken: string;
}
TypeScriptinterface V2NIMMessageSearchResult {
count: number;
items: V2NIMMessageSearchItem[];
nextPageToken: string;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
count |
int | 是 | - | 满足检索条件的所有消息数量。 |
items |
List<V2NIMMessageSearchItem > |
是 | - |
|
nextPageToken |
String | 否 | - | 下一次查询的分页 Token。 |
V2NIMMessageSearchItem
消息检索单条会话的返回结果。
Java// 消息检索单条会话的返回结果
interface V2NIMMessageSearchItem {
// 会话id
String getConversationId();
// 返回的消息列表
List<V2NIMMessage> getMessages();
// 单个会话的返回数量
int getCount();
}
Objective-C@interface V2NIMMessageSearchItem : NSObject
/// 会话id
@property (nonatomic,strong,readonly) NSString *conversationId;
/// 返回的消息列表
@property (nonatomic,strong,readonly) NSArray<V2NIMMessage *> *messages;
/// 单个会话的返回数量
@property (nonatomic,assign,readonly) NSInteger count;
@end
C++struct V2NIMMessageSearchItem {
nstd::string conversationId;
nstd::vector<V2NIMMessage> messages;
uint32_t count{0};
};
TypeScriptinterface V2NIMMessageSearchItem {
conversationId: string;
messages: V2NIMMessage[];
count: number;
}
TypeScriptinterface V2NIMMessageSearchItem {
conversationId: string;
count: number;
messages: V2NIMMessage[];
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
count |
int | 是 | - | 单个会话的返回消息数量。 |
messages |
List<V2NIMMessage > |
是 | - | 返回的消息列表。 |
conversationId |
String | 是 | - | 查询的会话 ID。 |
V2NIMClientAntispamResult
文本消息客户端本地反垃圾结果。
Javapublic interface V2NIMClientAntispamResult {
V2NIMClientAntispamOperateType getOperateType();
String getReplacedText();
}
Objective-C@interface V2NIMClientAntispamResult : NSObject
@property (nonatomic, assign) V2NIMClientAntispamOperateType operateType;
@property (nonatomic, copy) NSString *replacedText;
@end
C++struct V2NIMClientAntispamResult {
V2NIMClientAntispamOperateType operateType{V2NIM_CLIENT_ANTISPAM_OPERATE_NONE};
nstd::string replacedText;
};
TypeScriptexport interface V2NIMClientAntispamResult {
operateType: V2NIMClientAntispamOperateType
replacedText: string
}
TypeScriptinterface V2NIMClientAntispamResult {
operateType?: V2NIMClientAntispamOperateType;
replacedText?: string;
}
TypeScriptexport interface V2NIMClientAntispamResult {
operateType: V2NIMClientAntispamOperateType
replacedText: string
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
operateType |
V2NIMClientAntispamOperateType |
是 | 反垃圾命中后的操作类型。 |
replacedText |
String | 是 | 替换处理后的文本内容。 |
V2NIMVoiceToTextParams
语音转文字配置参数。
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);
}
}
}
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
C++struct V2NIMVoiceToTextParams {
nstd::string voicePath;
nstd::string voiceUrl;
nstd::string mimeType;
nstd::string sampleRate;
uint64_t duration{0};
nstd::string sceneName;
};
TypeScriptexport interface V2NIMVoiceToTextParams {
voicePath?: string
file?: File
voiceUrl?: string
duration: number
mimeType?: string
sampleRate?: string
sceneName?: string
}
TypeScriptinterface V2NIMVoiceToTextParams {
voicePath?: string;
voiceUrl?: string;
mimeType?: string;
sampleRate?: string;
duration?: number;
sceneName?: string;
}
TypeScriptexport interface V2NIMVoiceToTextParams {
voicePath?: string
voiceUrl?: string
duration: number
mimeType?: string
sampleRate?: string
sceneName?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
voicePath |
String | 与 voiceUrl 必须设置其一 |
- | 语音文件本地路径。 请确保该路径存在且可用。 |
file |
Web File | 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 文件存储场景信息。
Javapublic interface V2NIMStorageScene {
String getSceneName();
long getExpireTime();
}
Objective-C@interface V2NIMStorageScene : NSObject
@property (nullable,nonatomic,strong) NSString *sceneName;
@property (nonatomic,assign) NSUInteger expireTime;
@end
C++struct V2NIMStorageScene {
nstd::string sceneName;
uint64_t expireTime{0};
};
TypeScriptexport interface V2NIMStorageScene {
sceneName: string
expireTime?: number
}
TypeScriptinterface V2NIMStorageScene {
sceneName?: string
expireTime?: number
}
TypeScriptexport interface V2NIMStorageScene {
sceneName: string
expireTime?: number
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
sceneName |
String | 是 | 网易对象存储 NOS 文件存储场景名称。 |
expireTime |
long | 是 | 该场景下文件资源的过期时间,单位秒。必须大于等于 0,0 表示永不过期。 |
V2NIMStorageSceneConfig
网易对象存储 NOS 文件存储场景配置。
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);
}
Objective-C@interface V2NIMStorageSceneConfig : NSObject
+ (V2NIMStorageScene *)DEFAULT_PROFILE;
+ (V2NIMStorageScene *)DEFAULT_IM;
+ (V2NIMStorageScene *)DEFAULT_SYSTEM;
+ (V2NIMStorageScene *)SECURITY_LINK;
@end
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"};
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
}
}
}
TypeScriptinterface V2NIMStorageScene {
sceneName?: string;
expireTime?: number;
}
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 |
是 | 默认场景,用于用户、群组资料的上传场景。 | |
DEFAULT_IM |
V2NIMStorageScene |
是 | IM 场景,用于文件的上传场景。 | |
DEFAULT_SYSTEM |
V2NIMStorageScene |
是 | 系统场景,用于 SDK 内部文件的上传场景。 | |
SECURITY_LINK |
V2NIMStorageScene |
是 | 安全链接场景,查看该场景的上传文件需要密钥。 |
V2NIMCustomNotification
自定义通知。
Javapublic interface V2NIMCustomNotification {
String getSenderId();
String getReceiverId();
V2NIMConversationType getConversationType();
long getTimestamp();
String getContent();
V2NIMNotificationConfig getNotificationConfig();
V2NIMNotificationPushConfig getPushConfig();
V2NIMNotificationAntispamConfig getAntispamConfig();
V2NIMNotificationRouteConfig getRouteConfig();
}
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
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;
};
TypeScriptexport interface V2NIMCustomNotification {
senderId: string
receiverId: string
conversationType: V2NIMConversationType
timestamp: number
content: string
notificationConfig?: V2NIMNotificationConfig
pushConfig?: V2NIMNotificationPushConfig
antispamConfig?: V2NIMNotificationAntispamConfig
routeConfig?: V2NIMNotificationRouteConfig
}
TypeScriptinterface V2NIMCustomNotification {
senderId?: string;
receiverId?: string;
conversationType?: V2NIMConversationType;
timestamp?: number;
content?: string;
notificationConfig?: V2NIMNotificationConfig;
pushConfig?: V2NIMNotificationPushConfig;
antispamConfig?: V2NIMNotificationAntispamConfig;
routeConfig?: V2NIMNotificationRouteConfig;
}
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) |
conversationType |
V2NIMConversationType |
是 | 消息所属会话类型:单聊/高级群/超大群。 |
timestamp |
long | 是 | 自定义通知时间戳。 |
content |
String | 是 | 自定义通知内容,必须封装为 JSON 格式,长度上限为 4096 字节。 |
notificationConfig |
V2NIMNotificationConfig |
是 | 通知相关配置。 |
pushConfig |
V2NIMNotificationPushConfig |
是 | 第三方推送相关配置。 第三方推送功能需要在 网易云信控制台 上 配置。 |
antispamConfig |
V2NIMNotificationAntispamConfig |
是 | 反垃圾相关配置。 反垃圾功能包括客户端反垃圾和安全通,均需要在 网易云信控制台 上 开通。 |
routeConfig |
V2NIMNotificationRouteConfig |
是 | 系统通知事件抄送相关配置。 消息抄送功能需要在 网易云信控制台 上 开通。 |
V2NIMNotificationConfig
系统通知相关配置。
Javapublic class V2NIMNotificationConfig {
public boolean isOfflineEnabled() {
return offlineEnabled;
}
public boolean isUnreadEnabled() {
return unreadEnabled;
}
public String getClientNotificationId() {
return clientNotificationId;
}
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 V2NIMNotificationConfigBuilder withClientNotificationId(String clientNotificationId) {
this.clientNotificationId = clientNotificationId;
return this;
}
public V2NIMNotificationConfig build() {
return new V2NIMNotificationConfig(offlineEnabled, unreadEnabled, clientNotificationId);
}
}
}
Objective-C@interface V2NIMNotificationConfig : NSObject
@property(nonatomic,assign,readwrite) BOOL offlineEnabled;
@property(nonatomic,assign,readwrite) BOOL unreadEnabled;
@property(nonatomic,copy,nullable,readwrite) NSString *clientNotificationId;
@end
C++struct V2NIMNotificationConfig {
bool offlineEnabled{true};
bool unreadEnabled{true};
nstd::optional<nstd::string> clientNotificationId;
};
TypeScriptexport interface V2NIMNotificationConfig {
offlineEnabled: boolean
unreadEnabled: boolean
clientNotificationId?: string
}
TypeScriptinterface V2NIMNotificationConfig {
offlineEnabled?: boolean;
unreadEnabled?: boolean;
clientNotificationId?: string;
}
TypeScriptinterface V2NIMNotificationConfig {
clientNotificationId?: string;
offlineEnabled: boolean;
unreadEnabled: boolean;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
offlineEnabled |
boolean | 否 | true | 是否需要保存离线通知: |
unreadEnabled |
boolean | 否 | true | 是否需要计入通知未读数。 |
clientNotificationId |
string | 否 | - | 外部输入标识字段,建议输入时保证其唯一。长度不超过 32 个字符。 建议使用 uuid.toString() ,也可以采用业务对应的唯一 ID,直接串联业务逻辑,不用再做映射关系。 |
V2NIMNotificationPushConfig
系统通知第三方推送相关配置。
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);
}
}
}
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
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;
};
TypeScriptexport interface V2NIMNotificationPushConfig {
pushEnabled: boolean
pushNickEnabled: boolean
pushContent: string
pushPayload: string
forcePush: boolean
forcePushContent: string
forcePushAccounts: string[]
}
TypeScriptinterface V2NIMNotificationPushConfig {
pushEnabled?: boolean;
pushNickEnabled?: boolean;
pushContent?: string;
pushPayload?: string;
forcePush?: boolean;
forcePushContent?: string;
forcePushAccountIds?: string[];
}
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
系统通知事件抄送相关配置。
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);
}
}
}
Objective-C@interface V2NIMNotificationRouteConfig : NSObject
@property(nonatomic,assign,readwrite) BOOL routeEnabled;
@property(nonatomic,strong,readwrite) NSString *routeEnvironment;
@end
C++struct V2NIMNotificationRouteConfig {
bool routeEnabled{true};
nstd::optional<nstd::string> routeEnvironment;
};
TypeScriptexport interface V2NIMNotificationRouteConfig {
routeEnabled: boolean
routeEnvironment: string
}
TypeScriptinterface V2NIMNotificationRouteConfig {
routeEnabled?: boolean;
routeEnvironment?: string;
}
TypeScriptexport interface V2NIMNotificationRouteConfig {
routeEnabled: boolean
routeEnvironment: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
routeEnabled |
boolean | 否 | true | 是否需要系统通知事件抄送。 |
routeEnvironment |
String | routeEnabled 为 true 则为必填 |
- | 环境变量,用于指向不同系统通知事件抄送、第三方回调等配置。 |
V2NIMNotificationAntispamConfig
系统通知反垃圾配置,包括本地反垃圾和安全通的相关配置。
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);
}
}
}
Objective-C@interface V2NIMNotificationAntispamConfig : NSObject
@property(nonatomic,assign,readwrite) BOOL antispamEnabled;
@property(nonatomic,strong,readwrite) NSString *antispamCustomNotification;
@end
C++struct V2NIMNotificationAntispamConfig {
nstd::optional<bool> antispamEnabled;
nstd::optional<nstd::string> antispamCustomMessage;
};
TypeScriptexport interface V2NIMNotificationAntispamConfig {
antispamEnabled: boolean
antispamCustomNotification: string
}
TypeScriptinterface V2NIMNotificationAntispamConfig {
antispamEnabled?: boolean;
antispamCustomMessage?: string;
}
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
自定义通知发送参数。
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);
}
}
}
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
C++struct V2NIMSendCustomNotificationParams {
V2NIMNotificationConfig notificationConfig;
V2NIMNotificationPushConfig pushConfig;
V2NIMNotificationAntispamConfig antispamConfig;
V2NIMNotificationRouteConfig routeConfig;
};
TypeScriptexport interface V2NIMSendCustomNotificationParams {
notificationConfig?: V2NIMNotificationConfig
pushConfig?: V2NIMNotificationPushConfig
antispamConfig?: V2NIMNotificationAntispamConfig
routeConfig?: V2NIMNotificationRouteConfig
}
TypeScriptinterface V2NIMSendCustomNotificationParams {
notificationConfig?: V2NIMNotificationConfig;
pushConfig?: V2NIMNotificationPushConfig;
antispamConfig?: V2NIMNotificationAntispamConfig;
routeConfig?: V2NIMNotificationRouteConfig;
}
TypeScriptexport interface V2NIMSendCustomNotificationParams {
notificationConfig?: V2NIMNotificationConfig
pushConfig?: V2NIMNotificationPushConfig
antispamConfig?: V2NIMNotificationAntispamConfig
routeConfig?: V2NIMNotificationRouteConfig
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
notificationConfig |
V2NIMNotificationConfig |
是 | 通知相关配置。 |
pushConfig |
V2NIMNotificationPushConfig |
是 | 第三方推送相关配置。 第三方推送功能需要在 网易云信控制台 上 配置。 |
antispamConfig |
V2NIMNotificationAntispamConfig |
是 | 反垃圾相关配置。 反垃圾功能包括客户端反垃圾和安全通,均需要在 网易云信控制台 上 开通。 |
routeConfig |
V2NIMNotificationRouteConfig |
是 | 系统通知事件抄送相关配置。 消息抄送功能需要在 网易云信控制台 上 开通。 |
V2NIMBroadcastNotification
广播通知。
Javapublic interface V2NIMBroadcastNotification {
long getId();
String getSenderId();
long getTimestamp();
String getContent();
}
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
C++struct V2NIMBroadcastNotification {
uint64_t id;
nstd::string senderId;
uint64_t timestamp;
nstd::string content;
};
TypeScriptexport interface V2NIMBroadcastNotification {
id: string
senderId: string
time: number
content: string
}
TypeScriptinterface V2NIMBroadcastNotification {
id?: number;
senderId?: string;
timestamp?: number;
content?: string;
}
TypeScriptexport interface V2NIMBroadcastNotification {
id: string
senderId: string
time: number
content: string
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
id |
String | 是 | 广播通知 ID |
senderId |
String | 是 | 广播通知发送方账号(accountId) |
timestamp |
long | 是 | 广播通知时间戳。 |
content |
String | 是 | 广播通知内容,必须为 JSON 格式。 |
V2NIMNotificationListener
系统通知相关监听器。
Javapublic interface V2NIMNotificationListener {
void onReceiveCustomNotifications(List<V2NIMCustomNotification> customNotifications);
void onReceiveBroadcastNotifications(List<V2NIMBroadcastNotification> broadcastNotifications);
}
Objective-C@protocol V2NIMNotificationListener <NSObject>
- (void)onReceiveCustomNotifications:(NSArray <V2NIMCustomNotification *> *)customNotifications;
- (void)onReceiveBroadcastNotifications:(NSArray <V2NIMBroadcastNotification *> *)boradcastNotifications;
@end
C++V2NIMNotificationListener {
nstd::function< void(nstd::vector< V2NIMCustomNotification > customNotification)> onReceiveCustomNotifications;
nstd::function<void(nstd::vector<V2NIMBroadcastNotification> broadcastNotification)> onReceiveBroadcastNotifications;
};
TypeScriptV2NIMNotificationListener {
onReceiveBroadcastNotifications: [broadcastNotification: V2NIMBroadcastNotification[]]
onReceiveCustomNotifications: [customNotification: V2NIMCustomNotification[]]
}
TypeScriptinterface V2NIMNotificationListener {
receiveCustomNotifications: [V2NIMCustomNotification[]];
receiveBroadcastNotifications: [V2NIMBroadcastNotification[]];
}
TypeScriptinterface V2NIMNotificationListener {
onReceiveBroadcastNotifications: [broadcastNotification: V2NIMBroadcastNotification[]];
onReceiveCustomNotifications: [customNotification: V2NIMCustomNotification[]];
}
成员函数
-
onReceiveCustomNotifications
自定义通知接收回调,本端接收到发送方自定义通知,或其他端同步的自定义通知时会触发该回调。
参数名称 类型 说明 customNotifications
List< V2NIMCustomNotification
>自定义通知列表 -
onReceiveBroadcastNotifications
广播通知接收回调。
本端接收到服务端下发的广播通知时会触发该回调。
参数名称 类型 说明 boradcastNotifications
List< V2NIMBroadcastNotification
>广播通知列表
V2NIMTeam
群组对象。
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();
}
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
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};
};
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
}
TypeScriptinterface 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;
}
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,否则返回参数错误。 |
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
群成员对象。
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();
List<String> getFollowAccountIds();
}
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;
@property(nullable,nonatomic,copy,readonly) NSArray<NSString *> *followAccountIds;
@end
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;
nstd::vector<nstd::string> followAccountIds;
};
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
followAccountIds?: Array<string>
}
TypeScriptinterface V2NIMTeamMember {
teamId?: string;
teamType?: V2NIMTeamType;
accountId?: string;
memberRole?: V2NIMTeamMemberRole;
teamNick?: string;
serverExtension?: string;
joinTime?: number;
updateTime?: number;
invitorAccountId?: string;
inTeam?: boolean;
chatBanned?: boolean;
followAccountIds?: string[];
}
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 | 是 | 是 | 是否在群组中。 |
followAccountIds |
List<String> | 否 | 是 | 特别关注的群成员账号列表。 |
V2NIMCreateTeamParams
群组创建参数。
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;
}
}
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
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};
};
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
}
TypeScriptinterface 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;
}
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 | 否 | 群组人数上限。必须大于 0,否则返回参数错误。 |
|
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
群成员分页查询选项。
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;
}
}
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
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};
};
TypeScriptexport type V2NIMTeamMemberQueryOption = {
roleQueryType?: V2NIMTeamMemberRoleQueryType
onlyChatBanned?: boolean
direction?: V2NIMQueryDirection
limit?: number
nextToken?: string
}
TypeScriptinterface V2NIMTeamMemberQueryOption {
roleQueryType?: V2NIMTeamMemberRoleQueryType;
onlyChatBanned?: boolean;
direction?: V2NIMQueryDirection;
nextToken?: string;
limit?: number;
}
TypeScriptexport type V2NIMTeamMemberQueryOption = {
roleQueryType?: V2NIMTeamMemberRoleQueryType
onlyChatBanned?: boolean
direction?: V2NIMQueryDirection
limit?: number
nextToken?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
roleQueryType |
V2NIMTeamMemberRoleQueryType |
是 | - | 群成员查询类型。 |
onlyChatBanned |
boolean | 否 | false | 是否只返回聊天禁言成员列表 |
direction |
V2NIMQueryDirection |
否 | V2NIM_QUERY_DIRECTION_DESC |
消息查询方向(同时也是查询结果的排序方向): |
nextToken |
String | 否 | "" | 分页偏移,首次查询传空,下一次查询传入上一次查询返回值中的 nextToken 。 |
limit |
int | 否 | 100 | 单次查询群成员最大数量。不建议超过 100,设置小于等于 0 则默认为 100。 |
V2NIMUpdateTeamInfoParams
群组信息更新参数。
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;
}
}
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
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;
};
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
}
TypeScriptinterface V2NIMUpdateTeamInfoParams {
name?: string;
memberLimit?: number;
intro?: string;
announcement?: string;
avatar?: string;
serverExtension?: string;
joinMode?: V2NIMTeamJoinMode;
agreeMode?: V2NIMTeamAgreeMode;
inviteMode?: V2NIMTeamInviteMode;
updateInfoMode?: V2NIMTeamUpdateInfoMode;
updateExtensionMode?: V2NIMTeamUpdateExtensionMode;
}
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
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
name |
String | 否 | null | 群组名称。 设置为 null,表示不修改该字段。设置为 "",则返回参数错误。 |
memberLimit |
int | 否 | 群组人数上限。 必须大于 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
创建群组返回结果。
Javapublic interface V2NIMCreateTeamResult {
V2NIMTeam getTeam();
List<String> getFailedList();
}
Objective-C@interface V2NIMCreateTeamResult : NSObject
@property(nullable,nonatomic,copy,readonly) V2NIMTeam *team;
@property(nullable,nonatomic,copy,readonly) NSArray<NSString *> *failedList;
@end
C++struct V2NIMCreateTeamResult {
V2NIMTeam team;
nstd::vector<nstd::string> failedList;
};
TypeScriptexport type V2NIMCreateTeamResult = {
team: V2NIMTeam
failedList: string[]
}
TypeScriptinterface V2NIMCreateTeamResult {
team?: V2NIMTeam;
failedList?: string[];
}
TypeScriptexport type V2NIMCreateTeamResult = {
team: V2NIMTeam
failedList: string[]
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
team |
V2NIMTeam |
是 | 已创建的群组对象。 |
failedList |
List<String> | 是 | 被邀请入群失败的成员列表。 |
V2NIMUpdateSelfMemberInfoParams
修改本人群成员信息参数。
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;
}
}
Objective-C@interface V2NIMUpdateSelfMemberInfoParams : NSObject
@property(nullable,nonatomic,copy) NSString *teamNick;
@property(nullable,nonatomic,copy) NSString *serverExtension;
@end
C++struct V2NIMUpdateSelfMemberInfoParams {
nstd::optional<nstd::string> teamNick;
nstd::optional<nstd::string> serverExtension;
};
TypeScriptexport type V2NIMUpdateSelfMemberInfoParams = {
teamNick?: string
serverExtension?: string
}
TypeScriptinterface V2NIMUpdateSelfMemberInfoParams {
teamNick?: string;
serverExtension?: string;
}
TypeScriptexport type V2NIMUpdateSelfMemberInfoParams = {
teamNick?: string
serverExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
teamNick |
String | 否 | null | 群组内昵称。 设置为 null,表示不修改该字段。 |
serverExtension |
String | 否 | null | 群成员服务端扩展字段。必须为 JSON 格式封装,长度上限为 2048 字节,多端同步。 设置为 null,表示不修改该字段。 |
V2NIMTeamMemberListResult
分页获取群成员列表返回结果。
Javapublic interface V2NIMTeamMemberListResult {
String getNextToken();
boolean isFinished();
List<V2NIMTeamMember> getMemberList();
}
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
C++struct V2NIMTeamMemberListResult {
bool finished{false};
nstd::string nextToken;
nstd::vector<V2NIMTeamMember> memberList;
};
TypeScriptexport type V2NIMTeamMemberListResult = {
finished: boolean
nextToken: string
memberList: V2NIMTeamMember[]
}
TypeScriptinterface V2NIMTeamMemberListResult {
finished?: boolean;
nextToken?: string;
memberList?: V2NIMTeamMember[];
}
TypeScriptexport type V2NIMTeamMemberListResult = {
finished: boolean
nextToken: string
memberList: V2NIMTeamMember[]
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
nextToken |
String | 是 | 分页偏移。 |
finished |
boolean | 是 | 群成员是否全部获取: |
memberList |
List<V2NIMTeamMember > |
是 | 分页获取的群成员列表。 |
V2NIMTeamJoinActionInfo
入群操作信息。
Javapublic interface V2NIMTeamJoinActionInfo {
V2NIMTeamJoinActionType getActionType();
String getTeamId();
V2NIMTeamType getTeamType();
String getOperatorAccountId();
String getPostscript();
long getTimestamp();
V2NIMTeamJoinActionStatus getActionStatus();
}
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
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};
};
TypeScriptexport type V2NIMTeamJoinActionInfo = {
actionType: V2NIMTeamJoinActionType
teamId: string
teamType: V2NIMTeamType
operatorAccountId: string
postscript?: string
timestamp: number
actionStatus: V2NIMTeamJoinActionStatus
}
TypeScriptinterface V2NIMTeamJoinActionInfo {
actionType?: V2NIMTeamJoinActionType;
teamId?: string;
teamType?: V2NIMTeamType;
operatorAccountId?: string;
postscript?: string;
timestamp?: number;
actionStatus?: V2NIMTeamJoinActionStatus;
}
TypeScriptinterface V2NIMTeamJoinActionInfo {
actionStatus: V2NIMTeamJoinActionStatus;
actionType: V2NIMTeamJoinActionType;
operatorAccountId: string;
postscript?: string;
teamId: string;
teamType: V2NIMTeamType;
timestamp: number;
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
actionType |
V2NIMTeamJoinActionType |
是 | 入群操作类型。 |
teamId |
String | 是 | 群组 ID |
teamType |
V2NIMTeamType |
是 | 群组类型。 |
operatorAccountId |
String | 是 | 操作者账号。 |
postscript |
String | 是 | 操作附言。 |
timestamp |
long | 是 | 操作时间戳。 |
actionStatus |
V2NIMTeamJoinActionStatus |
是 | 操作处理状态。 |
V2NIMTeamJoinActionInfoQueryOption
入群操作信息分页查询选项。
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;
}
}
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
C++struct V2NIMTeamJoinActionInfoQueryOption {
nstd::vector<V2NIMTeamJoinActionType> types;
uint64_t offset;
uint32_t limit{V2NIM_DEFAULT_JOIN_ACTION_QUERY_LIMIT};
nstd::vector<V2NIMTeamJoinActionStatus> status;
};
TypeScriptexport type V2NIMTeamJoinActionInfoQueryOption = {
types?: V2NIMTeamJoinActionType[]
status?: V2NIMTeamJoinActionStatus[]
offset?: number
limit?: number
}
TypeScriptinterface V2NIMTeamJoinActionInfoQueryOption {
types?: V2NIMTeamJoinActionType[];
offset?: number;
limit?: number;
status?: V2NIMTeamJoinActionStatus[];
}
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
入群操作信息分页查询结果。
Javapublic interface V2NIMTeamJoinActionInfoResult {
List<V2NIMTeamJoinActionInfo> getInfos();
long getOffset();
boolean isFinished();
}
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
C++struct V2NIMTeamJoinActionInfoResult {
nstd::vector<V2NIMTeamJoinActionInfo> infos;
uint64_t offset{0};
bool finished{false};
};
TypeScriptexport type V2NIMTeamJoinActionInfoResult = {
infos: V2NIMTeamJoinActionInfo[]
offset: number
finished: boolean
}
TypeScriptinterface V2NIMTeamJoinActionInfoResult {
infos?: V2NIMTeamJoinActionInfo[];
offset?: number;
finished?: boolean;
}
TypeScriptexport type V2NIMTeamJoinActionInfoResult = {
infos: V2NIMTeamJoinActionInfo[]
offset: number
finished: boolean
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
infos |
List<V2NIMTeamJoinActionInfo > |
是 | 入群操作信息列表。 |
offset |
long | 是 | 分页查询偏移。 下一次查询传入上一次查询返回值中的 offset 。 |
finished |
bool | 是 | 数据是否全部获取: |
V2NIMTeamMemberSearchOption
根据关键字搜索群成员信息的配置参数。
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);
}
}
}
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
C++struct V2NIMTeamMemberSearchOption {
nstd::string keyword;
V2NIMTeamType teamType{V2NIM_TEAM_TYPE_NORMAL};
nstd::optional<nstd::string> teamId;
nstd::string nextToken;
V2NIMSortOrder order{V2NIM_SORT_ORDER_DESC};
uint32_t limit{V2NIM_DEFAULT_SEARCH_MESSAGE_LIST_LIMIT};
};
TypeScriptinterface V2NIMTeamMemberSearchOption {
keyword: string;
teamType: V2NIMTeamType;
teamId?: string;
nextToken: string;
order: V2NIMSortOrder;
limit: number;
}
TypeScriptinterface V2NIMTeamMemberSearchOption {
keyword: string;
limit?: number;
nextToken: string;
order?: V2NIMSortOrder;
teamId?: string;
teamType: V2NIMTeamType;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
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
根据关键字搜索群成员信息的搜索结果。
Javapublic interface V2NIMTeamMemberSearchResult {
List<V2NIMTeamMember> getMemberList();
String getNextToken();
boolean isFinished();
}
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
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
注册群组监听后,当群组相关事件发生时,会返回对应回调。
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);
}
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
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;
};
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]
}
TypeScriptinterface V2NIMTeamListener {
syncStarted: [];
syncFinished: [];
syncFailed: [V2NIMError];
teamCreated: [V2NIMTeam];
teamDismissed: [V2NIMTeam];
teamJoined: [V2NIMTeam];
teamLeft: [team: V2NIMTeam, isKicked: boolean];
teamInfoUpdated: [V2NIMTeam];
teamMemberJoined: [V2NIMTeamMember[]];
teamMemberKicked: [operateAccountId: string, teamMembers: V2NIMTeamMember[]];
teamMemberLeft: [V2NIMTeamMember[]];
teamMemberInfoUpdated: [V2NIMTeamMember[]];
receiveTeamJoinActionInfo: [V2NIMTeamJoinActionInfo];
}
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
推送全局免打扰配置信息。
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);
}
}
}
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
cppstruct V2NIMDndConfig {
bool showDetail{false};
bool dndOn{false};
uint32_t fromH{0};
uint32_t fromM{0};
uint32_t toH{0};
uint32_t toM{0};
};
TypeScriptinterface V2NIMDndConfig {
showDetail: boolean;
dndOn: boolean;
fromH: number;
fromM: number;
toH: number;
toM: number;
}
TypeScriptexport interface V2NIMDndConfig {
showDetail: boolean
dndOn: boolean
fromH: number
fromM: number
toH: number
toM: number
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
showDetail |
boolean | 否 | false | 是否显示推送详情。 |
dndOn |
boolean | 否 | false | APNs 推送全局免打扰是否开启。 |
fromH |
int | 如果 dndOn 为 true (开启免打扰)则必填 |
- | 免打扰开始时间(小时数) |
fromM |
int | 如果 dndOn 为 true (开启免打扰)则必填 |
- | 免打扰开始时间(分钟数) |
toH |
int | 如果 dndOn 为 true (开启免打扰)则必填 |
- | 免打扰结束时间(小时数) |
toM |
int | 如果 dndOn 为 true (开启免打扰)则必填 |
- | 免打扰结束时间(分钟数) |
V2NIMOfflinePushConfig(仅 Web)
离线推送配置信息。
TypeScriptexport interface V2NIMOfflinePushConfig {
apns?: V2NIMManufacturerPushConfig
hwPush?: V2NIMManufacturerPushConfig
miPush?: V2NIMManufacturerPushConfig
vivoPush?: V2NIMManufacturerPushConfig
oppoPush?: V2NIMManufacturerPushConfig
honorPush?: V2NIMManufacturerPushConfig
fcmPush?: V2NIMManufacturerPushConfig
mzPush?: V2NIMManufacturerPushConfig
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
miPush |
V2NIMManufacturerPushConfig |
否 | - | 小米推送:appId 、appKey 、certificateName 。 |
vivoPush |
V2NIMManufacturerPushConfig |
否 | - | vivo 推送:appId 、appKey 、certificateName 。 |
oppoPush |
V2NIMManufacturerPushConfig |
否 | - | OPPO 推送:appId 、appKey 、certificateName 、secret 。 |
hwPush |
V2NIMManufacturerPushConfig |
否 | - | 华为推送:appId 、appKey 。 |
fcmPush |
V2NIMManufacturerPushConfig |
否 | - | FCM 推送:certificateName 。 |
honorPush |
V2NIMManufacturerPushConfig |
否 | - | 荣耀推送:appId :在 AndroidManifest.xml 中配置。certificateName |
mzPush |
V2NIMManufacturerPushConfig |
否 | - | 魅族推送:appId 、appKey 、certificateName 。 |
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
注册系统设置监听后,当系统设置相关事件发生时,会返回对应回调。
Javapublic interface V2NIMSettingListener {
void onTeamMessageMuteModeChanged(String teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode);
void onP2PMessageMuteModeChanged(String accountId, V2NIMP2PMessageMuteMode muteMode);
}
Objective-C- (void)onTeamMessageMuteModeChanged:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
muteMode:(V2NIMTeamMessageMuteMode)muteMode;
- (void)onP2PMessageMuteModeChanged:(NSString *)accountId
muteMode:(V2NIMP2PMessageMuteMode)muteMode;
C++struct V2NIMSettingListener {
nstd::function<void(nstd::string teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode)> onTeamMessageMuteModeChanged;
nstd::function<void(nstd::string accountId, V2NIMP2PMessageMuteMode muteMode)> onP2PMessageMuteModeChanged;
};
TypeScriptexport type V2NIMSettingListener = {
onTeamMessageMuteModeChanged: [teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode]
onP2PMessageMuteModeChanged: [accountId: string, muteMode: V2NIMP2PMessageMuteMode]
}
TypeScriptinterface V2NIMSettingListener {
teamMessageMuteModeChanged: [string, V2NIMTeamType, V2NIMTeamMessageMuteMode];
p2pMessageMuteModeChanged: [string, V2NIMP2PMessageMuteMode];
}
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
用户资料对象。
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();
}
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
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};
};
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;
};
TypeScriptinterface V2NIMUser {
accountId?: string;
name?: string;
avatar?: string;
sign?: string;
email?: string;
birthday?: string;
mobile?: string;
gender?: number;
serverExtension?: string;
createTime?: number;
updateTime?: number;
}
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)模型类型及相关配置。
Javapublic interface V2NIMAIUser extends V2NIMUser {
V2NIMAIModelType getModelType();
V2NIMAIModelConfig getModelConfig();
}
Objective-C@interface V2NIMAIUser : V2NIMUser
@property(nonatomic,assign) V2NIMAIModelType modelType;
@property(nullable,nonatomic) V2NIMAIModelConfig *modelConfig;
@end
C++struct V2NIMAIUser : public V2NIMUser {
V2NIMAIModelType modelType;
V2NIMAIModelConfig modelConfig;
};
TypeScriptinterface V2NIMAIUser extends V2NIMUser {
modelType: V2NIMAIModelType
modelConfig?: V2NIMAIModelConfig
}
TypeScriptinterface V2NIMAIUser {
modelType?: V2NIMAIModelType;
modelConfig?: V2NIMAIModelConfig;
accountId?: string;
name?: string;
avatar?: string;
sign?: string;
email?: string;
birthday?: string;
mobile?: string;
gender?: number;
serverExtension?: string;
createTime?: number;
updateTime?: number;
}
TypeScriptinterface V2NIMAIUser {
accountId: string;
avatar?: string;
birthday?: string;
createTime: number;
email?: string;
gender?: number;
mobile?: string;
modelConfig?: V2NIMAIModelConfig;
modelType: V2NIMAIModelType;
name: string;
serverExtension?: string;
sign?: string;
updateTime?: number;
}
成员参数
除以下参数外,V2NIMAIUser 还继承了 V2NIMUser 的成员参数。
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
|
是 |
|
数字人配置的 LLM(Large Language Models)模型类型:
|
|
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,//可选
///....
}
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)模型的配置。
Javapublic class V2NIMAIModelConfig implements Serializable {
private String model;
private String prompt;
private List<String> promptKeys;
private int maxTokens = 0;
private double topP = 0.5;
private double temperature = 1;
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getPrompt() {
return prompt;
}
public void setPrompt(String prompt) {
this.prompt = prompt;
}
public List<String> getPromptKeys() {
return promptKeys;
}
public void setPromptKeys(List<String> promptKeys) {
this.promptKeys = promptKeys;
}
public int getMaxTokens() {
return maxTokens;
}
public void setMaxTokens(int maxTokens) {
this.maxTokens = maxTokens;
}
public double getTopP() {
return topP;
}
public void setTopP(double topP) {
this.topP = topP;
}
public double getTemperature() {
return temperature;
}
public void setTemperature(double temperature) {
this.temperature = temperature;
}
}
Objective-C@interface V2NIMAIModelConfig : NSObject
@property(nonatomic,copy) NSString *model;
@property(nonatomic,copy) NSString *prompt;
@property(nonatomic,assign) NSInteger maxTokens;
@property(nonatomic,assign) CGFloat topP;
@property(nonatomic,assign) CGFloat temperature;
@end
C++struct V2NIMAIModelConfig {
nstd::string model;
nstd::string prompt;
nstd::optional<nstd::vector<nstd::string>> promptKeys;
nstd::optional<uint32_t> maxTokens;
nstd::optional<nstd::string> topP;
nstd::optional<nstd::string> temperature;
};
TypeScripttype V2NIMAIModelConfig = {
model: string
prompt: string
promptKeys?: string[]
maxTokens?: number
topP?: string
temperature?: string
}
TypeScriptinterface V2NIMAIModelConfig {
model?: string;
prompt?: string;
maxTokens?: number;
topP?: number;
temperature?: number;
}
TypeScriptinterface V2NIMAIModelConfig {
maxTokens?: number;
model: string;
prompt: string;
promptKeys?: string[];
temperature?: string;
topP?: string;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
model |
String | 是 | - | LLM 模型供应商提供的具体大模型版本模型名。 |
prompt |
String | 是 | - | 提示词。 |
promptKeys |
Array<String> | 否 | - | 提示词对应的变量,格式如: ["country", "suchAsChina"]。 |
maxTokens |
Int | 否 | 0 | 模型最大 token 数量。 |
|
double |
否 |
0.5 |
一种称为核(Nucleus)抽样的策略,用来限制考虑用于生成的最高概率 token 的集合。
|
|
double |
否 |
1 |
用于调整模型输出的随机性,取值范围为 [0,2)。
|
V2NIMProxyAIModelCallParams
数字人发起 LLM(Large Language Models)模型请求的配置参数。
Javaimport android.text.TextUtils;
import com.netease.nimlib.sdk.v2.ai.config.V2NIMProxyAICallAntispamConfig;
import java.util.List;
public class V2NIMProxyAIModelCallParams {
private final String accountId;
private final String requestId;
private final V2NIMAIModelCallContent content;
private List<V2NIMAIModelCallMessage> messages;
private String promptVariables;
private V2NIMAIModelConfigParams modelConfigParams;
private V2NIMProxyAICallAntispamConfig antispamConfig;
private V2NIMProxyAIModelCallParams() {
this(null, null, null);
}
public V2NIMProxyAIModelCallParams(String accountId, String requestId, V2NIMAIModelCallContent content) {
this.accountId = accountId;
this.requestId = requestId;
this.content = content;
}
public String getAccountId() {
return accountId;
}
public String getRequestId() {
return requestId;
}
public V2NIMAIModelCallContent getContent() {
return content;
}
public List<V2NIMAIModelCallMessage> getMessages() {
return messages;
}
public void setMessages(List<V2NIMAIModelCallMessage> messages) {
this.messages = messages;
}
public String getPromptVariables() {
return promptVariables;
}
public void setPromptVariables(String promptVariables) {
this.promptVariables = promptVariables;
}
public V2NIMAIModelConfigParams getModelConfigParams() {
return modelConfigParams;
}
public void setModelConfigParams(V2NIMAIModelConfigParams modelConfigParams) {
this.modelConfigParams = modelConfigParams;
}
public V2NIMProxyAICallAntispamConfig getAntispamConfig() {
return antispamConfig;
}
public void setAntispamConfig(V2NIMProxyAICallAntispamConfig antispamConfig) {
this.antispamConfig = antispamConfig;
}
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;
public Builder accountId(String accountId) {
this.accountId = accountId;
return this;
}
public Builder requestId(String requestId) {
this.requestId = requestId;
return this;
}
public Builder content(V2NIMAIModelCallContent content) {
this.content = content;
return this;
}
public Builder messages(List<V2NIMAIModelCallMessage> messages) {
this.messages = messages;
return this;
}
public Builder promptVariables(String promptVariables) {
this.promptVariables = promptVariables;
return this;
}
public Builder modelConfigParams(V2NIMAIModelConfigParams modelConfigParams) {
this.modelConfigParams = modelConfigParams;
return this;
}
public Builder antispamConfig(V2NIMProxyAICallAntispamConfig antispamConfig) {
this.antispamConfig = antispamConfig;
return this;
}
public V2NIMProxyAIModelCallParams build() {
V2NIMProxyAIModelCallParams params = new V2NIMProxyAIModelCallParams(accountId, requestId, content);
params.messages = messages;
params.promptVariables = promptVariables;
params.modelConfigParams = modelConfigParams;
params.antispamConfig = antispamConfig;
return params;
}
}
}
Objective-C@interface V2NIMProxyAIModelCallParams : NSObject
@property(nonatomic,copy) NSString *accountId;
@property(nonatomic,copy) NSString *requestId;
@property(nonatomic,strong) V2NIMAIModelCallContent *content;
@property(nullable,nonatomic,strong) NSArray<V2NIMAIModelCallMessage *> *messages;
@property(nullable,nonatomic,copy) NSString *promptVariables;
@property(nullable,nonatomic,strong) V2NIMAIModelConfigParams *modelConfigParams;
@property(nullable,nonatomic,strong) V2NIMProxyAICallAntispamConfig *antispamConfig;
@end
C++struct V2NIMProxyAIModelCallParams {
nstd::string accountId;
nstd::string requestId;
V2NIMAIModelCallContent content;
nstd::optional<nstd::vector<V2NIMAIModelCallMessage>> messages;
nstd::optional<nstd::string> promptVariables;
nstd::optional<V2NIMAIModelConfigParams> modelConfigParams;
nstd::optional<V2NIMProxyAICallAntispamConfig> antispamConfig;
};
TypeScripttype V2NIMProxyAIModelCallParams = {
accountId: string
requestId: string
content: V2NIMAIModelCallContent
messages?: V2NIMAIModelCallMessage[]
promptVariables?: string
modelConfigParams?: V2NIMAIModelConfigParams
antispamConfig?: V2NIMProxyAICallAntispamConfig
}
TypeScriptinterface V2NIMProxyAIModelCallParams {
accountId?: string;
requestId?: string;
content?: V2NIMAIModelCallContent;
messages?: V2NIMMessage[];
promptVariables?: string;
modelConfigParams?: V2NIMAIModelConfigParams;
}
TypeScriptinterface V2NIMProxyAIModelCallParams {
accountId: string;
antispamConfig?: V2NIMProxyAICallAntispamConfig;
content: V2NIMAIModelCallContent;
messages?: V2NIMAIModelCallMessage[];
modelConfigParams?: V2NIMAIModelConfigParams;
promptVariables?: string;
requestId: string;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
accountId |
String | 是 | - | 数字人(AIUser)对应的账号 ID。 |
requestId |
String | 是 | - | 请求 ID。 |
content |
V2NIMAIModelCallContent | 是 | - | 数字人请求 LLM 模型的具体内容。 |
messages |
List<V2NIMAIModelCallMessage> | 否 | - | 数字人请求 LLM 模型的上下文内容。 |
|
String |
否 |
|
提示词变量占位符替换内容,用于填充
|
modelConfigParams |
V2NIMAIModelConfigParams | 否 | - | 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置。 |
antispamConfig |
V2NIMProxyAICallAntispamConfig | 否 | - | 反垃圾配置,可复用消息体里的部分反垃圾字段。 |
V2NIMProxyAICallAntispamConfig
数字人收发消息,是否需要经过安全通校验,即透传反垃圾内容配置。
Javapublic class V2NIMProxyAICallAntispamConfig {
private boolean antispamEnabled = true;
private String antispamBusinessId;
public boolean isAntispamEnabled() {
return antispamEnabled;
}
public void setAntispamEnabled(boolean antispamEnabled) {
this.antispamEnabled = antispamEnabled;
}
public String getAntispamBusinessId() {
return antispamBusinessId;
}
public void setAntispamBusinessId(String antispamBusinessId) {
this.antispamBusinessId = antispamBusinessId;
}
}
Objective-C@interface V2NIMProxyAICallAntispamConfig : NSObject
@property(nonatomic,assign) BOOL antispamEnabled;
@property(nullable,nonatomic,copy) NSString *antispamBusinessId;
@end
C++struct V2NIMProxyAICallAntispamConfig {
nstd::optional<bool> antispamEnabled{true};
nstd::optional<nstd::string> antispamBusinessId;
};
TypeScripttype V2NIMProxyAICallAntispamConfig = {
antispamEnabled?: boolean
antispamBusinessId?: string
}
TypeScriptinterface V2NIMProxyAICallAntispamConfig {
antispamBusinessId?: string;
antispamEnabled?: boolean;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
|
Boolean |
否 |
|
指定消息是否需要经过安全通校验。
|
antispamBusinessId |
String | 否 | - | 指定网易易盾业务 ID。 |
V2NIMAIModelCallContent
数字人请求大模型或者大模型响应的消息内容。
Javapublic class V2NIMAIModelCallContent implements Serializable {
private static final String TAG = "V2NIMAIModelCallContent";
private String msg;
private Integer type;
public V2NIMAIModelCallContent() {
this(null, null);
}
public V2NIMAIModelCallContent(String msg, Integer type) {
this.msg = msg;
this.type = type;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}
Objective-C@interface V2NIMAIModelCallContent : NSObject<NSCopying>
@property(nonatomic,copy) NSString *msg;
@property(nonatomic,assign) V2NIMAIModelCallContentType type;
@end
C++struct V2NIMAIModelCallContent {
nstd::string msg;
int32_t type;
};
TypeScriptinterface V2NIMAIModelCallContent {
msg: string
type: number
}
TypeScriptinterface V2NIMAIModelCallContent {
msg?: string;
type?: number;
}
TypeScriptinterface V2NIMAIModelCallContent {
msg: string;
type: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
msg |
String | 是 | - | 数字人请求或者响应的内容。 |
type |
Number | 是 | - | 请求或者响应的内容类型。暂时只有 0,代表文本,待后续扩展为其他内容类型。 |
V2NIMAIModelCallMessage
数字人请求大模型或者大模型响应的消息的上下文内容。
Javapublic class V2NIMAIModelCallMessage implements Serializable {
private V2NIMAIModelRoleType role;
private String msg;
private int type;
public V2NIMAIModelRoleType getRole() {
return role;
}
public void setRole(V2NIMAIModelRoleType role) {
this.role = role;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public int getType() {
return 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();
}
}
Objective-C@interface V2NIMAIModelCallMessage : NSObject
@property(nonatomic,assign) V2NIMAIModelRoleType role;
@property(nonatomic,copy) NSString *msg;
@property(nonatomic,assign) V2NIMAIModelCallContentType type;
@end
C++struct V2NIMAIModelCallMessage {
V2NIMAIModelRoleType role;
nstd::string msg;
int32_t type;
};
TypeScriptinterface V2NIMAIModelCallMessage {
role: V2NIMAIModelRoleType
msg: string
type: number
}
TypeScriptinterface V2NIMAIModelCallMessage {
msg: string;
role: V2NIMAIModelRoleType;
type: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
role |
V2NIMAIModelRoleType | 是 | - | 上下文内容的角色。 |
msg |
String | 是 | - | 数字人请求或者响应的上下文内容。 |
type |
Number | 是 | - | 请求或者响应的上下文内容类型。暂时只有 0,代表文本,待后续扩展为其他内容类型。 |
V2NIMAIModelConfigParams
数字人请求的 LLM 大模型配置覆盖设置。配置了该字段后,默认覆盖您在网易云信控制台上的相关配置。
- 如果所有字段均为空,则以您在网易云信控制台上的配置为准,本地不做格式校验。
- 如果设置参数超过范围,则会主动纠正到正确范围。
Javapublic class V2NIMAIModelConfigParams implements Serializable {
private String prompt;
private Integer maxTokens;
private Double topP;
private Double temperature;
public String getPrompt() {
return prompt;
}
public void setPrompt(String prompt) {
this.prompt = prompt;
}
public Integer getMaxTokens() {
return maxTokens;
}
public void setMaxTokens(Integer maxTokens) {
this.maxTokens = maxTokens;
}
public Double getTopP() {
return topP;
}
public void setTopP(Double topP) {
this.topP = topP;
}
public Double getTemperature() {
return temperature;
}
public void setTemperature(Double temperature) {
this.temperature = temperature;
}
}
Objective-C@interface V2NIMAIModelConfigParams : NSObject<NSCopying>
@property(nullable,nonatomic,copy) NSString *prompt;
@property(nonatomic,assign) NSInteger maxTokens;
@property(nonatomic,assign) CGFloat topP;
@property(nonatomic,assign) CGFloat temperature;
@end
C++struct V2NIMAIModelConfigParams {
nstd::optional<nstd::string> prompt;
nstd::optional<int32_t> maxTokens;
nstd::optional<double> topP;
nstd::optional<double> temperature;
};
TypeScripttype V2NIMAIModelConfigParams = {
prompt?: string
maxTokens?: number
topP?: string
temperature?: string
}
TypeScriptinterface V2NIMAIModelConfigParams = {
prompt?: string;
maxTokens?: number;
topP?: string;
temperature?: string;
}
TypeScriptinterface V2NIMAIModelConfigParams {
maxTokens?: number;
prompt?: string;
temperature?: string;
topP?: string;
}
成员参数
以下参数取值的详细说明,可参考 V2NIMAIModelConfig。
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
prompt |
String | 否 | - | 提示词。 |
maxTokens |
int | 否 | - | 模型最大 token 数量。 |
topP |
double | 否 | - | 采样 P 参数,取值范围 (0,1)。 |
temperature |
double | 否 | - | 温度参数,取值范围 (0,2)。 |
V2NIMMessageAIConfigParams
消息体中数字人配置的 LLM 大模型相关配置字段。
Javapublic class V2NIMMessageAIConfigParams implements Serializable {
private String accountId;
private V2NIMAIModelCallContent content;
private List<V2NIMAIModelCallMessage> messages;
private String promptVariables;
private V2NIMAIModelConfigParams modelConfigParams;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public V2NIMAIModelCallContent getContent() {
return content;
}
public void setContent(V2NIMAIModelCallContent content) {
this.content = content;
}
public List<V2NIMAIModelCallMessage> getMessages() {
return messages;
}
public void setMessages(List<V2NIMAIModelCallMessage> messages) {
this.messages = messages;
}
public String getPromptVariables() {
return promptVariables;
}
public void setPromptVariables(String promptVariables) {
this.promptVariables = promptVariables;
}
public V2NIMAIModelConfigParams getModelConfigParams() {
return modelConfigParams;
}
public void setModelConfigParams(V2NIMAIModelConfigParams modelConfigParams) {
this.modelConfigParams = modelConfigParams;
}
}
Objective-C@interface V2NIMMessageAIConfigParams : NSObject<NSCopying>
@property(nullable,nonatomic,strong,readwrite) NSString *accountId;
@property(nullable,nonatomic,strong,readwrite) V2NIMAIModelCallContent *content;
@property(nullable,nonatomic,strong,readwrite) NSArray<V2NIMAIModelCallMessage *> *messages;
@property(nullable,nonatomic,strong,readwrite) NSString *promptVariables;
@property(nullable,nonatomic,strong,readwrite) V2NIMAIModelConfigParams *modelConfigParams;
@end
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;
};
TypeScripttype V2NIMMessageAIConfigParams = {
accountId: string
content?: V2NIMAIModelCallContent
messages?: V2NIMAIModelCallMessage[]
promptVariables?: string
modelConfigParams?: V2NIMAIModelConfigParams
}
TypeScriptinterface V2NIMProxyAIModelCallParams {
accountId?: string;
requestId?: string;
content?: V2NIMAIModelCallContent;
messages?: V2NIMMessage[];
promptVariables?: string;
modelConfigParams?: V2NIMAIModelConfigParams;
}
TypeScriptinterface V2NIMMessageAIConfigParams {
accountId: string;
content?: V2NIMAIModelCallContent;
messages?: V2NIMAIModelCallMessage[];
modelConfigParams?: V2NIMAIModelConfigParams;
promptVariables?: string;
}
成员参数
以下参数取值的详细说明,可参考 V2NIMAIModelConfig。
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
accountId |
String | 是 | - | 数字人(AIUser)对应的账号 ID。 |
content |
V2NIMAIModelCallContent | 否 | - | 数字人请求 LLM 模型的具体内容。 |
messages |
List<V2NIMAIModelCallMessage> | 否 | - | 数字人请求 LLM 模型的上下文内容。 |
|
String |
否 |
|
提示词变量占位符替换内容,用于填充
|
modelConfigParams |
V2NIMAIModelConfigParams | 否 | - | 请求接口模型相关参数配置,如果参数不为空,则默认覆盖控制相关配置。 |
V2NIMAIModelCallResult
透传接口下数字人回复消息的的结构体。
javapublic interface V2NIMAIModelCallResult {
int getCode();
String getAccountId();
String getRequestId();
V2NIMAIModelCallContent getContent();
}
Objective-C@interface V2NIMAIModelCallResult : NSObject
@property(nonatomic,copy) NSString *accountId;
@property(nonatomic,copy) NSString *requestId;
@property(nonatomic,strong) V2NIMAIModelCallContent *content;
@property(nonatomic,assign) NSInteger code;
@end
C++struct V2NIMAIModelCallResult {
uint32_t code{V2NIM_ERROR_CODE_SUCCESS};
nstd::string accountId;
nstd::string requestId;
nstd::optional<V2NIMAIModelCallContent> content;
};
TypeScriptinterface V2NIMAIModelCallResult {
code: number
accountId: string
requestId: string
content: V2NIMAIModelCallContent
}
TypeScriptinterface V2NIMAIModelCallResponse {
code?: number;
accountId?: string;
requestId?: string;
content?: V2NIMAIModelCallContent;
}
TypeScriptinterface V2NIMAIModelCallResult {
accountId: string;
code: number;
content: V2NIMAIModelCallContent;
requestId: string;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
code |
Int | 是 | 200 | 数字人响应消息的状态码。 |
accountId |
String | 是 | - | 收发消息的数字人的账号 ID(accountId)。 |
requestId |
String | 是 | - | 本次响应的标识。 |
content |
V2NIMAIModelCallContent | 否 | - | 请求 LLM 模型的回复消息。 |
V2NIMAIListener
AI 透传接口的响应的回调。接口 proxyAIModelCall
调用完毕后,服务端响应以通知的形式下发,客户端需要触发回调提供响应。
Javapublic interface V2NIMAIListener {
void onProxyAIModelCall(V2NIMAIModelCallResult result);
}
Objective-C- (void)onProxyAIModelCall:(V2NIMAIModelCallResult *)data{
}
C++struct V2NIMAIListener {
nstd::function<void(V2NIMAIModelCallResult response)> onProxyAIModelCall;
};
TypeScriptinterface V2NIMAIListener {
onProxyAIModelCall: [response: V2NIMAIModelCallResponse]
}
TypeScriptinterface V2NIMAIListener {
proxyAIModelCall: [response: V2NIMAIModelCallResponse]
}
TypeScriptinterface V2NIMAIListener {
onProxyAIModelCall: [response: V2NIMAIModelCallResult];
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
data |
V2NIMAIModelCallResult | 是 | - | 本次响应的结构体。 |
V2NIMMessageAIConfig
消息体中数字人消息收发相关配置字段。
Javapublic class V2NIMMessageAIConfig implements Serializable {
private String accountId;
private V2NIMMessageAIStatus aiStatus;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public V2NIMMessageAIStatus getAIStatus() {
return aiStatus;
}
public void setAIStatus(V2NIMMessageAIStatus aiStatus) {
this.aiStatus = aiStatus;
}
}
Objective-C@interface V2NIMMessageAIConfig : NSObject<NSCopying>
@property(nullable,nonatomic,strong,readwrite) NSString *accountId;
@property(nonatomic,assign,readwrite) V2NIMMessageAIStatus aiStatus;
@end
C++struct V2NIMMessageAIConfig {
nstd::string accountId;
V2NIMMessageAIStatus aiStatus{V2NIM_MESSAGE_AI_STATUS_UNKNOW};
};
TypeScripttype V2NIMMessageAIConfig = {
accountId: string
aiStatus?: V2NIMMessageAIStatus
}
TypeScriptinterface V2NIMMessageAIConfig {
accountId: string;
aiStatus?: V2NIMMessageAIStatus;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
accountId |
String | 是 | - | 收发消息的数字人的账号 ID(accountId)。 |
|
是 |
|
该数字人收发的消息的询问和应答标识
|
V2NIMUserUpdateParams
用户资料更新参数。
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);
}
}
}
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
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;
};
TypeScriptexport type V2NIMUserUpdateParams = {
name?: string;
avatar?: string;
sign?: string;
email?: string;
birthday?: string;
mobile?: string;
gender?: number;
serverExtension?: string;
};
TypeScriptinterface V2NIMUserUpdateParams {
name?: string;
avatar?: string;
sign?: string;
email?: string;
birthday?: string;
mobile?: string;
gender?: number;
serverExtension?: string;
}
TypeScriptexport type V2NIMUserUpdateParams = {
name?: string
avatar?: string
sign?: string
email?: string
birthday?: string
mobile?: string
gender?: number
serverExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
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:未知。1:男。2:女 设置为其它值会返回参数错误。 |
serverExtension |
String | 否 | 用户资料扩展字段,建议使用 JSON 格式,长度上限为 1024 字符 |
V2NIMUserSearchOption
根据关键字搜索用户信息的配置参数。
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);
}
}
}
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
cppstruct V2NIMUserSearchOption {
nstd::string keyword;
bool searchName{true};
bool searchAccountId{false};
bool searchMobile{false};
};
TypeScriptexport type V2NIMUserSearchOption = {
keyword: string
searchName?: boolean
searchAccountId?: boolean
searchMobile?: boolean
}
TypeScriptinterface V2NIMUserSearchOption {
keyword?: string;
searchName?: boolean;
searchAccountId?: boolean;
searchMobile?: boolean;
}
TypeScriptinterface V2NIMUserSearchOption {
keyword: string;
searchAccountId?: boolean;
searchMobile?: boolean;
searchName?: boolean;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
keyword |
String | 是 | - | 搜索关键字,默认搜索用户的昵称,可以指定是否同时搜索用户账号或手机号。 |
searchName |
Boolean | 否 | true | 是否搜索用户的昵称。 |
searchAccountId |
Boolean | 否 | false | 是否搜索用户账号。 |
searchMobile |
Boolean | 否 | false | 是否搜索用户的手机号。 |
V2NIMUserListener
用户资料相关监听器。
Javapublic interface V2NIMUserListener {
void onUserProfileChanged(List<V2NIMUser> users);
void onBlockListAdded(V2NIMUser user);
void onBlockListRemoved(String accountId);
}
Objective-C@protocol V2NIMUserListener <NSObject>
- (void)onUserProfileChanged:(NSArray <V2NIMUser *> *)users;
- (void)onBlockListAdded:(V2NIMUser*)user;
- (void)onBlockListRemoved:(NSString *)accountId;
@end
C++struct V2NIMUserListener {
std::function<void(std::vector<V2NIMUser> users)> onUserProfileChanged;
std::function<void(V2NIMUser user)> onBlockListAdded;
std::function<void(std::string accountId)> onBlockListRemoved;
};
TypeScriptexport type V2NIMUserListener = {
onUserProfileChanged: [users: V2NIMUser[]]
onBlockListAdded: [user: V2NIMUser]
onBlockListRemoved: [accountId: string]
}
TypeScriptinterface V2NIMUserListener {
userProfileChanged: [V2NIMUser[]];
blockListAdded: [V2NIMUser];
blockListRemoved: [string];
}
TypeScriptexport type V2NIMUserListener = {
onUserProfileChanged: [users: V2NIMUser[]]
onBlockListAdded: [user: V2NIMUser]
onBlockListRemoved: [accountId: string]
}
成员函数
-
onUserProfileChanged
用户资料变更回调。
参数名称 类型 说明 users
List<V2NIMUser> 用户资料 -
onBlockListAdded
黑名单新增用户回调。
当客户端本端添加用户到黑名单,或者其他端同步添加用户到黑名单时触发该回调。
参数名称 类型 说明 user
V2NIMUser 添加进黑名单的用户资料 -
onBlockListRemoved
黑名单移除用户回调。
当客户端本端从黑名单移除用户,或者其他端同步从黑名单移除用户时触发该回调。
参数名称 类型 说明 accountId
String 移出黑名单的用户账号 ID
V2NIMFriend
好友信息对象。
Javapublic interface V2NIMFriend {
String getAccountId();
String getAlias();
String getServerExtension();
String getCustomerExtension();
long getCreateTime();
long getUpdateTime();
V2NIMUser getUserProfile();
}
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
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;
};
TypeScriptexport type V2NIMFriend = {
accountId: string;
alias?: string;
serverExtension: string;
customerExtension: string;
createTime?: number;
updateTime?: number;
};
TypeScriptinterface V2NIMFriend {
accountId?: string;
alias?: string;
serverExtension?: string;
customerExtension?: string;
createTime?: number;
updateTime?: number;
userProfile: V2NIMUser;
}
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
添加好友的配置参数。
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);
}
}
}
Objective-C@interface V2NIMFriendAddParams : NSObject
@property (nonatomic, assign) V2NIMFriendAddMode addMode;
@property (nullable,nonatomic,strong) NSString *postscript;
@end
C++struct V2NIMFriendAddParams {
V2NIMFriendAddMode addMode{V2NIM_FRIEND_MODE_TYPE_ADD};
nstd::optional<nstd::string> postscript;
};
TypeScriptexport type V2NIMFriendAddParams = {
addMode: V2NIMFriendAddMode
postscript: string
}
TypeScriptinterface V2NIMFriendAddParams {
addMode?: V2NIMFriendAddMode;
postscript?: string;
}
TypeScriptexport type V2NIMFriendAddParams = {
addMode: V2NIMFriendAddMode
postscript: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
addMode |
V2NIMFriendAddMode |
是 | V2NIMFriendAddMode.V2NIM_FRIEND_MODE_TYPE_ADD:直接添加为好友,无需验证 | 添加好友模式。 |
postscript |
String | 否 | - | 添加/申请添加好友的附言。 |
V2NIMFriendAddApplication
申请添加好友相关操作信息。
Javapublic interface V2NIMFriendAddApplication {
String getApplicantAccountId();
String getRecipientAccountId();
String getOperatorAccountId();
String getPostscript();
V2NIMFriendAddApplicationStatus getStatus();
long getTimestamp();
boolean isRead();
}
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
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};
};
TypeScriptexport type V2NIMFriendAddApplication = {
applicantAccountId: string
recipientAccountId: string
operatorAccountId: string
postscript?: string
status: V2NIMFriendAddApplicationStatus
timestamp: number
read: boolean
}
TypeScriptinterface V2NIMFriendAddApplication {
applicantAccountId: string;
recipientAccountId: string;
operatorAccountId?: string;
postscript?: string;
status?: V2NIMFriendAddApplicationStatus;
timestamp?: number;
read?: boolean;
}
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
删除好友的配置参数。
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);
}
}
}
Objective-C@interface V2NIMFriendDeleteParams : NSObject
@property (nonatomic, assign) BOOL deleteAlias;
@end
C++struct V2NIMFriendDeleteParams {
bool deleteAlias{false};
};
TypeScriptexport type V2NIMFriendDeleteParams = {
deleteAlias: boolean;
};
TypeScriptinterface V2NIMFriendDeleteParams {
deleteAlias?: boolean;
}
TypeScriptexport type V2NIMFriendDeleteParams = {
deleteAlias: boolean
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
deleteAlias |
boolean | 否 | false | 是否删除备注,false:不删除。true:删除。 |
V2NIMFriendSetParams
设置好友信息的配置参数。可以设置别名和扩展字段,两字段都可选,但是不能都不传,都不传回返回参数错误。
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);
}
}
}
Objective-C@interface V2NIMFriendSetParams : NSObject
@property (nullable,nonatomic,strong) NSString *alias;
@property (nullable,nonatomic,strong) NSString *serverExtension;
@end
C++struct V2NIMFriendSetParams {
nstd::optional<nstd::string> alias;
nstd::optional<nstd::string> serverExtension;
};
TypeScriptexport type V2NIMFriendSetParams = {
alias?: string;
serverExtension?: string;
};
TypeScriptinterface V2NIMFriendSetParams {
alias?: string;
serverExtension?: string;
}
TypeScriptexport type V2NIMFriendSetParams = {
alias?: string
serverExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
alias |
String | 否 | - | 别名 |
serverExtension |
String | 否 | - | 扩展字段 |
V2NIMFriendAddApplicationQueryOption
申请添加好友相关操作信息的查询参数。
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);
}
}
}
Objective-C@interface V2NIMFriendAddApplicationQueryOption : NSObject
@property (nonatomic,nonatomic,assign) NSUInteger offset;
@property (nonatomic,nonatomic,assign) NSUInteger limit;
@property (nonatomic, strong) NSArray <NSNumber *> *status;
@end
C++struct V2NIMFriendAddApplicationQueryOption {
uint64_t offset;
uint32_t limit{V2NIM_DEFAULT_FRIEND_APPLICATION_QUERY_LIMIT};
nstd::vector<V2NIMFriendAddApplicationStatus> status;
};
TypeScriptexport type V2NIMFriendAddApplicationQueryOption = {
offset?: number
limit?: number
status: Array<V2NIMFriendAddApplicationStatus>
}
TypeScriptinterface V2NIMFriendAddApplicationQueryOption {
offset?: number;
limit?: number;
status?: V2NIMFriendAddApplicationStatus[];
}
TypeScriptexport type V2NIMFriendAddApplicationQueryOption = {
offset?: number
limit?: number
status: Array<V2NIMFriendAddApplicationStatus>
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
offset |
long | 否 | - | 分页查询偏移。首次查询传 0,下一次查询传入上一次查询返回值中的 offset(不包含 offset) |
limit |
Integer | 否 | 50 | 单次查询的最大数量。 |
status |
List<V2NIMFriendAddApplicationStatus > |
否 | - | 申请添加好友相关操作状态列表。如果列表为空或 size 为 0 则表示查询所有申请添加好友相关操作信息。 |
V2NIMFriendAddApplicationResult
查询申请添加好友相关操作信息列表的返回结果。
Javapublic interface V2NIMFriendAddApplicationResult {
List<V2NIMFriendAddApplication> getInfos();
long getOffset();
boolean isFinished();
}
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
C++struct V2NIMFriendAddApplicationResult {
nstd::vector<V2NIMFriendAddApplication> infos;
uint64_t offset{0};
bool finished{false};
};
TypeScriptexport type V2NIMFriendAddApplicationResult = {
infos: Array<V2NIMFriendAddApplication>;
offset: number;
finished: boolean;
};
TypeScriptinterface V2NIMFriendAddApplicationResult {
infos?: V2NIMFriendAddApplication[];
offset?: number;
finished?: boolean;
}
TypeScriptexport type V2NIMFriendAddApplicationResult = {
infos: Array<V2NIMFriendAddApplication>
offset: number
finished: boolean
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
infos |
List<V2NIMFriendAddApplication > |
是 | 查询返回的申请添加好友相关操作信息列表。 |
offset |
long | 是 | 下一下查询的偏移量。 |
finished |
boolean | 是 | 是否分页结束。 |
V2NIMFriendSearchOption
根据关键字搜索好友信息的配置参数。
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);
}
}
}
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
cppstruct V2NIMFriendSearchOption {
nstd::string keyword;
bool searchAlias{true};
bool searchAccountId{false};
};
TypeScriptexport type V2NIMFriendSearchOption = {
keyword: string
searchAlias?: boolean
searchAccountId?: boolean
}
TypeScriptinterface V2NIMFriendSearchOption {
keyword?: string;
searchAlias?: boolean;
searchAccountId?: boolean;
}
TypeScriptinterface V2NIMFriendSearchOption {
keyword: string;
searchAccountId?: boolean;
searchAlias?: boolean;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
keyword |
String | 是 | - | 搜索关键字,默认搜索好友的备注,可以指定是否同时搜索用户账号。 |
searchAlias |
Boolean | 否 | true | 是否搜索好友的备注。 |
searchAccountId |
Boolean | 否 | false | 是否搜索用户账号。 |
V2NIMFriendListener
好友信息相关监听器。
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);
}
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
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;
};
TypeScriptexport type V2NIMFriendListener = {
onFriendAdded: [friend: V2NIMFriend]
onFriendDeleted: [accountId: string, deletionType: V2NIMFriendDeletionType]
onFriendAddApplication: [application: V2NIMFriendAddApplication]
onFriendAddRejected: [rejection: V2NIMFriendAddApplication]
onFriendInfoChanged: [friend: V2NIMFriend]
}
TypeScriptinterface V2NIMFriendListener {
friendAdded: [V2NIMFriend];
friendDeleted: [string, V2NIMFriendDeletionType];
friendAddApplication: [V2NIMFriendAddApplication];
friendAddRejected: [V2NIMFriendAddApplication];
friendInfoChanged: [V2NIMFriend];
}
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 |
成员函数
getChatroomInfo
:获取聊天室信息。getChatroomService
:获取聊天室服务。后续聊天室相关操作(聊天室成员、消息等)均在返回的V2NIMChatroomService
类中实现。getChatroomQueueService
:获取聊天室队列服务。后续聊天室队列相关操作均在返回的V2NIMChatroomQueueService
类中实现。enter
:进入聊天室。exit
:退出聊天室。getInstanceId
:获取实例 ID。
V2NIMChatroomInitParams(仅 Web & HarmonyOS)
创建聊天室实例时的初始化参数。
TypeScriptexport interface V2NIMChatroomInitParams {
appkey: string
customClientType?: number
}
TypeScriptexport interface V2NIMChatroomInitParams {
appkey: string
customClientType?: number
}
成员参数
参数名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
appkey |
string | 是 | - | 应用 appkey |
customClientType |
int | 否 | null | 自定义设备类型。 |
V2NIMChatroomEnterParams
进入聊天室相关参数。
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);
}
}
}
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
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;
};
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
}
TypeScriptinterface V2NIMChatroomEnterParams {
accountId?: string;
token?: string;
roomNick?: string;
roomAvatar?: string;
timeout?: number;
loginOption?: V2NIMChatroomLoginOption;
anonymousMode?: boolean;
linkProvider?: V2NIMChatroomLinkProvider;
serverExtension?: string;
notificationExtension?: string;
tagConfig?: V2NIMChatroomTagConfig;
locationConfig?: V2NIMChatroomLocationConfig;
antispamConfig?: V2NIMAntispamConfig;
[x: string]: any;
}
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 | 用户账号。 |
token |
String | 否 | null | 静态 token,可以不填。 |
roomNick |
String | 否 | 账号对应信息 | 进入聊天室后显示的昵称。 可以不填,默认显示账号对应相关信息,例如:匿名模式则默认昵称为账号名称。 |
roomAvatar |
String | 否 | 账号对应信息 | 进入聊天室后显示的头像,可通过 V2NIMStorageService.uploadFile 方法上传头像。可以不填,默认显示账号对应相关信息,例如:匿名模式则默认头像为空。 |
timeout |
int | 否 | 60 | 调用 enter 方法进入聊天室超时时间。若超过该时间未成功进入聊天室,则返回失败回调。 |
loginOption |
V2NIMChatroomLoginOption |
否 | null | 聊天室登录配置。 |
linkProvider |
V2NIMChatroomLinkProvider |
是 | - | 获取聊天室连接链接地址回调,SDK 通过两种方式获取:V2NIMLoginService.getChatroomLinkAddress 方法获取聊天室连接地址。 |
serverExtension |
String | 否 | null | 服务端扩展字段,建议使用 JSON 格式,多端同步。长度上限为 4096。 |
notificationExtension |
String | 否 | null | 进入聊天室通知的扩展字段,长度上限为 2048。 |
tagConfig |
V2NIMChatroomTagConfig |
否 | null | 进入聊天室的标签信息配置。 |
locationConfig |
V2NIMChatroomLocationConfig |
否 | null | 进入聊天室的空间位置信息配置。 |
antispamConfig |
V2NIMAntispamConfig |
否 | null | 易盾反垃圾检测。 |
V2NIMChatroomLoginOption
聊天室登录配置。
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);
}
}
}
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
C++struct V2NIMChatroomLoginOption {
V2NIMLoginAuthType authType{V2NIM_LOGIN_AUTH_TYPE_DEFAULT};
V2NIMChatroomTokenProvider tokenProvider{nullptr};
V2NIMChatroomLoginExtensionProvider loginExtensionProvider{nullptr};
};
TypeScriptexport interface V2NIMChatroomLoginOption {
authType?: V2NIMLoginAuthType
tokenProvider?: (appkey: string, roomId: string, accountId: string) => Promise<string>
loginExtensionProvider?: (appkey: string, roomId: string, accountId: string) => Promise<string>
}
TypeScriptinterface V2NIMChatroomLoginOption {
authType?: V2NIMLoginAuthType;
tokenProvider?: V2NIMChatroomTokenProvider;
loginExtensionProvider?: V2NIMChatroomLoginExtensionProvider;
[x: string]: any;
}
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 回调。
Javapublic interface V2NIMChatroomTokenProvider {
String getToken(String roomId, String accountId);
}
Objective-C@protocol V2NIMChatroomTokenProvider <NSObject>
- (nullable NSString *)getToken:(NSString *)roomId
accountId:(NSString *)accountId;
@end
C++using V2NIMChatroomTokenProvider = nstd::function<nstd::optional<nstd::string>(nstd::string roomId, nstd::string account)>;
TypeScript(appkey: string, roomId: string, accountId: string) => Promise<string>
TypeScriptV2NIMChatroomTokenProvider: ((roomId: string, account: string) => string)
成员参数
名称 | 类型 | 说明 |
---|---|---|
roomId |
String | 聊天室 ID |
accountId |
String | 用户登录账号 |
V2NIMChatroomLoginExtensionProvider
聊天室用户登录业务扩展数据回调。
Javapublic interface V2NIMLoginExtensionProvider {
String getLoginExtension(String accountId);
}
Objective-C@protocol V2NIMLoginExtensionProvider <NSObject>
- (nullable NSString *)getLoginExtension:(NSString *)accountId;
@end
C++using V2NIMLoginExtensionProvider = nstd::function<nstd::optional<nstd::string>(nstd::string accountId)>;
TypeScriptexport type V2NIMLoginExtensionProvider = (accountId: string) => Promise<string> | string
TypeScriptV2NIMLoginExtensionProvider: ((accountId: string) => string)
成员参数
名称 | 类型 | 说明 |
---|---|---|
roomId |
String | 聊天室 ID |
accountId |
String | 用户登录账号 |
V2NIMChatroomLinkProvider
聊天室连接链接地址回调。
Javapublic interface V2NIMChatroomLinkProvider {
List<String> getLinkAddress(String roomId, String accountId);
}
Objective-C@protocol V2NIMChatroomLinkProvider <NSObject>
- (nullable NSArray<NSString *> *)getLinkAddress:(NSString *)roomId
accountId:(NSString *)accountId;
@end
C++using V2NIMChatroomLinkProvider = nstd::function<nstd::vector<nstd::string>(nstd::string roomId, nstd::string account)>;
TypeScript(roomId: string, accountId: string) => Promise<Array<string>>
TypeScriptV2NIMChatroomLinkProvider: ((roomId: string, account: string) => string[])
成员参数
名称 | 类型 | 说明 |
---|---|---|
roomId |
String | 聊天室 ID |
accountId |
String | 用户登录账号 |
V2NIMChatroomTagConfig
进入聊天室标签信息配置。
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);
}
}
}
Objective-C@interface V2NIMChatroomTagConfig : NSObject
@property(nullable,nonatomic,copy,readwrite) NSArray<NSString *> *tags;
@property(nullable,nonatomic,copy,readwrite) NSString *notifyTargetTags;
@end
C++struct V2NIMChatroomTagConfig {
nstd::vector<nstd::string> tags;
nstd::string notifyTargetTags;
};
TypeScriptexport interface V2NIMChatroomTagConfig {
notifyTargetTags: string
tags: string[]
}
TypeScriptinterface V2NIMChatroomTagConfig {
tags?: string[];
notifyTargetTags?: string;
}
TypeScriptexport interface V2NIMChatroomTagConfig {
notifyTargetTags: string
tags: string[]
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
tags |
List<String> | 否 | null | 进入聊天室标签列表。 |
notifyTargetTags |
String | 否 | null | 进入/退出聊天室通知标签信息,标签表达式请参考 聊天室标签管理。 |
V2NIMChatroomLocationConfig
聊天室空间坐标信息及订阅范围配置。
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;
}
}
Objective-C@interface V2NIMChatroomLocationConfig : NSObject
@property(nullable,nonatomic,copy,readwrite) V2NIMLocationInfo *locationInfo;
@property(nonatomic,assign,readwrite) double distance;
@end
C++struct V2NIMChatroomLocationConfig {
V2NIMLocationInfo locationInfo;
nstd::optional<double> distance;
};
TypeScriptexport interface V2NIMChatroomLocationConfig {
locationInfo?: V2NIMLocationInfo
distance: number
}
TypeScriptinterface V2NIMChatroomLocationConfig {
locationInfo?: V2NIMLocationInfo;
distance?: number;
}
TypeScriptexport interface V2NIMChatroomLocationConfig {
locationInfo?: V2NIMLocationInfo
distance: number
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
locationInfo |
V2NIMLocationInfo |
是 | - | 聊天室空间位置坐标信息。 |
distance |
double | 是 | - | 基于空间位置订阅聊天室消息的距离。 |
V2NIMLocationInfo
聊天室空间坐标信息。
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;
}
}
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
C++struct V2NIMLocationInfo {
nstd::optional<double> x;
nstd::optional<double> y;
nstd::optional<double> z;
};
TypeScriptexport interface V2NIMLocationInfo {
x?: number
y?: number
z?: number
}
TypeScriptinterface V2NIMLocationInfo {
x?: number;
y?: number;
z?: number;
}
TypeScriptexport interface V2NIMLocationInfo {
x?: number
y?: number
z?: number
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
x |
double | 是 | - | 聊天室空间 x 坐标。 |
y |
double | 是 | - | 聊天室空间 y 坐标。 |
z |
double | 是 | - | 聊天室空间 z 坐标。 |
V2NIMChatroomEnterResult
进入聊天室结果回包。
Javapublic interface V2NIMChatroomEnterResult {
V2NIMChatroomInfo getChatroom();
V2NIMChatroomMember getSelfMember();
}
Objective-C@interface V2NIMChatroomEnterResult : NSObject
@property(nonatomic,copy,readonly) V2NIMChatroomInfo *chatroom;
@property(nonatomic,copy,readonly) V2NIMChatroomMember *selfMember;
@end
C++struct V2NIMChatroomEnterResult {
V2NIMChatroomInfo chatroom;
V2NIMChatroomMember selfMember;
};
TypeScriptexport interface V2NIMChatroomEnterResult {
chatroom: V2NIMChatroomInfo
selfMember: V2NIMChatroomMember
}
TypeScriptinterface V2NIMChatroomEnterResult {
chatroom?: V2NIMChatroomInfo;
selfMember?: V2NIMChatroomMember;
}
TypeScriptexport interface V2NIMChatroomEnterResult {
chatroom: V2NIMChatroomInfo
selfMember: V2NIMChatroomMember
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
chatroom |
V2NIMChatroomInfo |
是 | 聊天室信息。 |
selfMember |
V2NIMChatroomMember |
是 | 聊天室成员用户信息: |
V2NIMChatroomInfo
聊天室信息。
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();
}
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
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};
};
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
}
TypeScriptinterface V2NIMChatroomInfo {
roomId?: string;
roomName?: string;
announcement?: string;
liveUrl?: string;
isValidRoom?: boolean;
serverExtension?: string;
queueLevelMode?: V2NIMChatroomQueueLevelMode;
creatorAccountId?: string;
onlineUserCount?: number;
chatBanned?: boolean;
}
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 | 是 | 聊天室是否处于禁言状态: |
tempChatBanned |
boolean | 是 | 聊天室是否处于临时禁言状态: |
V2NIMChatroomMember
聊天室成员信息。
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();
}
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
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;
};
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[]
}
TypeScriptinterface 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[];
}
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
进入聊天室信息。
Javapublic interface V2NIMChatroomEnterInfo extends Serializable {
String getRoomNick();
String getRoomAvatar();
long getEnterTime();
int getClientType();
}
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
C++struct V2NIMChatroomEnterInfo {
nstd::string roomNick;
nstd::string roomAvatar;
uint64_t enterTime{0};
uint32_t clientType{0};
};
TypeScriptexport interface V2NIMChatroomEnterInfo {
roomNick: string
roomAvatar: string
enterTime: number
clientType: number
}
TypeScriptinterface V2NIMChatroomEnterInfo {
roomNick?: string;
roomAvatar?: string;
enterTime?: number;
clientType?: number;
}
TypeScriptexport interface V2NIMChatroomEnterInfo {
roomNick: string
roomAvatar: string
enterTime: number
clientType: number
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
roomNick |
String | 是 | - | 进入聊天室后显示的昵称。 |
roomAvatar |
String | 是 | - | 进入聊天室后显示的头像。 |
enterTime |
long | 是 | 0 | 用户进入聊天室时间戳。离线成员该字段为 0。 |
clientType |
int | 是 | 0,表示未设置 | 进入聊天室终端类型。 |
V2NIMChatroomKickedInfo
被踢出聊天室信息。
Javapublic interface V2NIMChatroomKickedInfo extends Serializable {
V2NIMChatroomKickedReason getKickedReason();
String getServerExtension();
}
Objective-C@interface V2NIMChatroomKickedInfo : NSObject
@property(nonatomic,assign,readonly) V2NIMChatroomKickedReason kickedReason;
@property(nullable,nonatomic,copy,readonly) NSString *serverExtension;
@end
C++struct V2NIMChatroomKickedInfo {
V2NIMChatroomKickedReason kickedReason{V2NIM_CHATROOM_KICKED_REASON_UNKNOWN};
nstd::string serverExtension;
};
TypeScriptexport interface V2NIMChatroomKickedInfo {
kickedReason: V2NIMChatroomKickedReason
serverExtension: string
}
TypeScriptinterface V2NIMChatroomKickedInfo {
kickedReason?: V2NIMChatroomKickedReason;
serverExtension?: string;
}
TypeScriptexport interface V2NIMChatroomKickedInfo {
kickedReason: V2NIMChatroomKickedReason
serverExtension: string
}
成员参数
名称 | 类型 | 是否只读 | 是否必填 | 说明 |
---|---|---|---|---|
kickedReason |
V2NIMChatroomKickedReason |
是 | 是 | 被踢原因。 |
serverExtension |
String | 否 | 是 | 被踢信息的服务端扩展字段,多端同步。 |
V2NIMUserInfoConfig
消息发送方的用户信息配置。
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;
}
}
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
C++struct V2NIMUserInfoConfig {
uint64_t userInfoTimestamp{0};
nstd::string senderNick;
nstd::string senderAvatar;
nstd::string senderExtension;
};
TypeScriptexport type V2NIMUserInfoConfig = {
userInfoTimestamp?: number
senderNick?: string
senderAvatar?: string
senderExtension?: string
}
TypeScriptinterface V2NIMUserInfoConfig {
userInfoTimestamp?: number;
senderNick?: string;
senderAvatar?: string;
senderExtension?: string;
}
TypeScriptexport type V2NIMUserInfoConfig = {
userInfoTimestamp?: number
senderNick?: string
senderAvatar?: string
senderExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
userInfoTimestamp |
long | 否 | null | 消息发送方用户信息的最后更新时间。 |
senderNick |
String | 否 | null | 消息发送方的昵称。 |
senderAvatar |
String | 否 | null | 消息发送方的头像。 |
senderExtension |
String | 否 | null | 消息发送方的服务端扩展字段,多端同步。 |
V2NIMChatroomMessageConfig
聊天室消息配置。
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;
}
}
Objective-C@interface V2NIMChatroomMessageConfig : NSObject <NSCopying>
@property(nonatomic,assign,readwrite) BOOL historyEnabled;
@property(nonatomic,assign,readwrite) BOOL highPriority;
@end
C++struct V2NIMChatroomMessageConfig {
bool historyEnabled{true};
bool highPriority{false};
};
TypeScriptexport type V2NIMChatroomMessageConfig = {
historyEnabled?: boolean
highPriority?: boolean
}
TypeScriptinterface V2NIMChatroomMessageConfig {
historyEnabled?: boolean;
highPriority?: boolean;
}
TypeScriptexport type V2NIMChatroomMessageConfig = {
historyEnabled?: boolean
highPriority?: boolean
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
historyEnabled |
boolean | 否 | true | 是否需要在服务端保存历史消息。 |
highPriority |
boolean | 否 | false | 是否是高优先级消息。 在超频情况下,默认先流控低优先级消息。 |
V2NIMChatroomMessage
聊天室消息。
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();
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
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;
};
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
}
TypeScriptinterface V2NIMChatroomMessage {
messageClientId?: string;
senderClientType?: V2NIMLoginClientType;
createTime?: number;
senderId?: string;
roomId?: string;
isSelf?: boolean;
attachmentUploadState?: V2NIMMessageAttachmentUploadState;
sendingState?: V2NIMMessageSendingState;
messageType?: V2NIMMessageType;
subType?: number;
text?: string;
attachment?: V2NIMMessageAttachment;
serverExtension?: string;
callbackExtension?: string;
routeConfig?: V2NIMMessageRouteConfig;
antispamConfig?: V2NIMMessageAntispamConfig;
notifyTargetTags?: string;
messageConfig?: V2NIMChatroomMessageConfig;
userInfoConfig?: V2NIMUserInfoConfig;
locationInfo?: V2NIMLocationInfo;
}
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 |
否 | 是 | 消息发送方用户信息配置。 |
locationInfo |
V2NIMLocationInfo |
否 | - | 消息空间位置信息配置。 |
V2NIMChatroomNotificationAttachment
聊天室通知消息附件对象,继承自 V2NIMMessageAttachment
。
Javapublic interface V2NIMChatroomNotificationAttachment extends V2NIMMessageAttachment {
V2NIMChatroomMessageNotificationType getType();
List<String> getTargetIds();
List<String> getTargetNicks();
String getTargetTag();
String getOperatorId();
String getOperatorNick();
String getNotificationExtension();
List<String> getTags();
}
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
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;
};
TypeScriptexport interface V2NIMChatroomNotificationAttachment extends V2NIMMessageAttachment {
type: V2NIMChatroomMessageNotificationType
targetIds?: string[]
targetNicks?: string
targetTag?: string
operatorId?: string
operatorNick?: string
notificationExtension?: string
tags?: string[]
}
TypeScriptinterface V2NIMChatroomNotificationAttachment {
raw?: string;
type?: V2NIMChatroomMessageNotificationType;
targetIds?: string[];
targetNicks?: string[];
targetTag?: string;
operatorId?: string;
operatorNick?: string;
notificationExtension?: string;
tags?: string[];
}
TypeScriptinterface V2NIMChatroomNotificationAttachment {
notificationExtension?: string;
operatorId?: string;
operatorNick?: string;
tags?: string[];
targetIds?: string[];
targetNicks?: string;
targetTag?: string;
type: V2NIMChatroomMessageNotificationType;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
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
。
Javapublic interface V2NIMChatroomMessageRevokeNotificationAttachment extends V2NIMChatroomNotificationAttachment {
String getMessageClientId();
long getMessageTime();
}
Objective-C@interface V2NIMChatroomMessageRevokeNotificationAttachment: V2NIMChatroomNotificationAttachment
@property(nonatomic, strong, readonly) NSString *messageClientId;
@property(nonatomic, assign, readonly) NSTimeInterval messageTime;
@end
C++struct V2NIMChatroomMessageRevokeNotificationAttachment : public V2NIMChatroomNotificationAttachment {
V2NIMChatroomMessageRevokeNotificationAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MESSAGE_REVOKE_NOTIFICATION; }
nstd::string messageClientId;
uint64_t messageTime{0};
};
TypeScriptexport interface V2NIMChatroomMessageRevokeNotificationAttachment extends V2NIMChatroomNotificationAttachment {
messageClientId?: string
messageTime?: string
}
TypeScriptinterface V2NIMChatroomMessageRevokeNotificationAttachment {
raw?: string;
type?: V2NIMChatroomMessageNotificationType;
targetIds?: string[];
targetNicks?: string[];
targetTag?: string;
operatorId?: string;
operatorNick?: string;
notificationExtension?: string;
tags?: string[];
messageClientId?: string;
messageTime?: number;
}
TypeScriptexport interface V2NIMChatroomMessageRevokeNotificationAttachment extends V2NIMChatroomNotificationAttachment {
messageClientId?: string
messageTime?: string
}
成员参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
messageClientId |
String | 否 | 撤回的消息客户端 ID。 客户端生成的 UUID,不多端同步。 |
messageTime |
long | 否 | 消息撤回时间戳。 |
V2NIMChatroomChatBannedNotificationAttachment
聊天室禁言通知附件对象,继承自 V2NIMMessageAttachment
。
Javapublic interface V2NIMChatroomChatBannedNotificationAttachment extends V2NIMChatroomNotificationAttachment {
boolean isChatBanned();
boolean isTempChatBanned();
long getTempChatBannedDuration();
}
Objective-C@interface V2NIMChatroomChatBannedNotificationAttachment: V2NIMChatroomNotificationAttachment
@property(nonatomic, assign, readonly) BOOL chatBanned;
@property(nonatomic, assign, readonly) BOOL tempChatBanned;
@property(nonatomic, assign, readonly) NSTimeInterval tempChatBannedDuration;
@end
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};
};
TypeScriptexport interface V2NIMChatroomChatBannedNotificationAttachment extends V2NIMChatroomNotificationAttachment {
chatBanned?: boolean
tempChatBanned?: boolean
tempChatBannedDuration?: number
}
TypeScriptinterface V2NIMChatroomChatBannedNotificationAttachment {
raw?: string;
type?: V2NIMChatroomMessageNotificationType;
targetIds?: string[];
targetNicks?: string[];
targetTag?: string;
operatorId?: string;
operatorNick?: string;
notificationExtension?: string;
tags?: string[];
chatBanned?: boolean;
tempChatBanned?: boolean;
tempChatBannedDuration?: number;
}
TypeScriptexport interface V2NIMChatroomChatBannedNotificationAttachment extends V2NIMChatroomNotificationAttachment {
chatBanned?: boolean
tempChatBanned?: boolean
tempChatBannedDuration?: number
}
成员参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
chatBanned |
boolean | 否 | 聊天室成员是否被禁言。 |
tempChatBanned |
boolean | 否 | 聊天室成员是否被临时禁言。 |
tempChatBannedDuration |
long | 否 | 聊天室成员被临时禁言时长(毫秒)。0 表示已解除禁言。 |
V2NIMChatroomMemberEnterNotificationAttachment
成员进出聊天室通知附件对象,继承自 V2NIMMessageAttachment
。
Javapublic interface V2NIMChatroomMemberEnterNotificationAttachment extends V2NIMChatroomNotificationAttachment {
boolean isChatBanned();
boolean isTempChatBanned();
long getTempChatBannedDuration();
}
Objective-C@interface V2NIMChatroomMemberEnterNotificationAttachment: V2NIMChatroomNotificationAttachment
@property(nonatomic, assign, readonly) BOOL chatBanned;
@property(nonatomic, assign, readonly) BOOL tempChatBanned;
@property(nonatomic, assign, readonly) NSTimeInterval tempChatBannedDuration;
@end
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};
};
TypeScriptexport interface V2NIMChatroomMemberEnterNotificationAttachment extends V2NIMChatroomNotificationAttachment {
chatBanned?: boolean
tempChatBanned?: boolean
tempChatBannedDuration?: number
}
TypeScriptinterface V2NIMChatroomMemberEnterNotificationAttachment {
raw?: string;
type?: V2NIMChatroomMessageNotificationType;
targetIds?: string[];
targetNicks?: string[];
targetTag?: string;
operatorId?: string;
operatorNick?: string;
notificationExtension?: string;
tags?: string[];
chatBanned?: boolean;
tempChatBanned?: boolean;
tempChatBannedDuration?: number;
}
TypeScriptexport interface V2NIMChatroomMemberEnterNotificationAttachment extends V2NIMChatroomNotificationAttachment {
chatBanned?: boolean
tempChatBanned?: boolean
tempChatBannedDuration?: number
}
成员参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
chatBanned |
boolean | 否 | 聊天室成员是否被禁言。 管理员、普通成员、普通游客离开后再次进入聊天室时,保持之前设置的状态不变。 |
tempChatBanned |
boolean | 否 | 聊天室成员是否被临时禁言。 管理员、普通成员、普通游客离开后再次进入聊天室时,保持之前设置的状态不变。 |
tempChatBannedDuration |
long | 否 | 聊天室成员被禁言时长(毫秒)。 成员离开后再次进入聊天室时,禁言时长不会重新计算。 |
V2NIMChatroomMemberRoleUpdateAttachment
聊天室成员角色变更通知附件对象,继承自 V2NIMMessageAttachment
。
Javapublic interface V2NIMChatroomMemberRoleUpdateAttachment extends V2NIMChatroomNotificationAttachment {
V2NIMChatroomMemberRole getPreviousRole();
V2NIMChatroomMember getCurrentMember();
}
Objective-C@interface V2NIMChatroomMemberRoleUpdateAttachment: V2NIMChatroomNotificationAttachment
@property(nonatomic, assign, readonly) V2NIMChatroomMemberRole previousRole;
@property(nonatomic, strong, readonly) V2NIMChatroomMember *currentMember;
@end
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;
};
TypeScriptexport interface V2NIMChatroomMemberRoleUpdateAttachment extends V2NIMChatroomNotificationAttachment {
previousRole: V2NIMChatroomMemberRole
currentMember: V2NIMChatroomMember
}
TypeScriptinterface V2NIMChatroomMemberRoleUpdateAttachment {
raw?: string;
type?: V2NIMChatroomMessageNotificationType;
targetIds?: string[];
targetNicks?: string[];
targetTag?: string;
operatorId?: string;
operatorNick?: string;
notificationExtension?: string;
tags?: string[];
previousRole?: V2NIMChatroomMemberRole;
currentMember?: V2NIMChatroomMember;
}
TypeScriptexport interface V2NIMChatroomMemberRoleUpdateAttachment extends V2NIMChatroomNotificationAttachment {
previousRole: V2NIMChatroomMemberRole
currentMember: V2NIMChatroomMember
}
成员参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
previousRole |
V2NIMChatroomMemberRole |
是 | 变更前的角色类型。 |
currentMember |
V2NIMChatroomMember |
是 | 变更后的成员信息。 |
V2NIMSendChatroomMessageParams
聊天室消息发送参数配置。
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;
}
}
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
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;
};
TypeScriptexport type V2NIMSendChatroomMessageParams = {
messageConfig?: V2NIMChatroomMessageConfig
routeConfig?: V2NIMMessageRouteConfig
antispamConfig?: V2NIMMessageAntispamConfig
clientAntispamEnabled?: boolean
clientAntispamReplace?: string
receiverIds?: string[]
notifyTargetTags?: string
locationInfo?: V2NIMLocationInfo
}
TypeScriptinterface V2NIMSendChatroomMessageParams {
messageConfig?: V2NIMChatroomMessageConfig;
routeConfig?: V2NIMMessageRouteConfig;
antispamConfig?: V2NIMMessageAntispamConfig;
clientAntispamEnabled?: boolean;
clientAntispamReplace?: string;
receiverIds?: string[];
notifyTargetTags?: string;
locationInfo?: V2NIMLocationInfo;
}
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 | 是否启用本地反垃圾。V2NIMClientAntispamOperateType :
|
clientAntispamReplace |
String | 若 clientAntispamEnabled 为 true 则必填 |
"" | 反垃圾命中后替换的文本。 |
receiverIds |
List<String> | 否 | null | 定向消息接收者账号列表,最多支持指定 100 个接收者。 若该字段不为空,则表示该消息为聊天室定向消息,不在服务端进行存储。 |
notifyTargetTags |
String | 否 | null | 消息接收通知的标签,请参考 标签表达式。 |
locationInfo |
V2NIMLocationInfo |
否 | null | 消息空间位置信息配置。 |
V2NIMSendChatroomMessageResult
聊天室消息发送成功结果回包。
Javapublic interface V2NIMSendChatroomMessageResult {
V2NIMChatroomMessage getMessage();
String getAntispamResult();
V2NIMClientAntispamResult getClientAntispamResult();
}
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
C++struct V2NIMSendChatroomMessageResult {
V2NIMChatroomMessage message;
nstd::string antispamResult;
nstd::optional<V2NIMClientAntispamResult> clientAntispamResult;
};
TypeScriptexport type V2NIMSendChatroomMessageResult = {
message: V2NIMChatroomMessage
antispamResult?: string
clientAntispamResult?: V2NIMClientAntispamResult
}
TypeScriptinterface V2NIMSendChatroomMessageResult {
message?: V2NIMChatroomMessage;
antispamResult?: string;
clientAntispamResult?: V2NIMClientAntispamResult;
}
TypeScriptexport type V2NIMSendChatroomMessageResult = {
message: V2NIMChatroomMessage
antispamResult?: string
clientAntispamResult?: V2NIMClientAntispamResult
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
message |
V2NIMChatroomMessage |
是 | 聊天室消息对象。 |
antispamResult |
String | 是 | 安全通反垃圾检测结果。 |
clientAntispamResult |
V2NIMClientAntispamResult |
是 | 本地反垃圾结果。 |
V2NIMChatroomMemberQueryOption
聊天室成员分页查询选项。
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;
}
}
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
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};
};
TypeScriptexport type V2NIMChatroomMemberQueryOption = {
memberRoles?: V2NIMChatroomMemberRole[]
onlyBlocked?: boolean
onlyChatBanned?: boolean
onlyOnline?: boolean
pageToken: string
limit: number
}
TypeScriptinterface V2NIMChatroomMemberQueryOption {
memberRoles?: V2NIMChatroomMemberRole[];
onlyBlocked?: boolean;
onlyChatBanned?: boolean;
onlyOnline?: boolean;
pageToken?: string;
limit?: number;
}
TypeScriptexport type V2NIMChatroomMemberQueryOption = {
memberRoles?: V2NIMChatroomMemberRole[]
onlyBlocked?: boolean
onlyChatBanned?: boolean
onlyOnline?: boolean
pageToken: string
limit: number
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
memberRoles |
List<V2NIMChatroomMemberRole > |
否 | - | 聊天室成员类型。如果不设置或为空则表示查询所有类型的成员。 |
onlyBlocked |
boolean | 否 | false | 是否只返回黑名单成员: |
onlyChatBanned |
boolean | 否 | false | 是否只返回聊天禁言成员列表: |
onlyOnline |
boolean | 否 | false | 是否只返回在线的固定成员(创建者、管理员、普通成员): |
pageToken |
String | 否 | "" | 分页偏移,首次查询传空,下一次查询传入上一次查询返回值中的 nextToken 。 |
limit |
int | 否 | 100 | 单次查询聊天室成员最大数量。不建议超过 200,设置小于等于 0 则默认为 200。 |
V2NIMChatroomMemberListResult
分页获取聊天室成员列表返回结果。
Javapublic interface V2NIMChatroomMemberListResult {
String getPageToken();
boolean isFinished();
List<V2NIMChatroomMember> getMemberList();
}
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
C++struct V2NIMChatroomMemberListResult {
nstd::string pageToken;
bool finished{false};
nstd::vector<V2NIMChatroomMember> memberList;
};
TypeScriptexport type V2NIMChatroomMemberListResult = {
pageToken: string
finished: boolean
memberList: V2NIMChatroomMember
}
TypeScriptinterface V2NIMChatroomMemberListResult {
pageToken?: string;
finished?: boolean;
memberList?: V2NIMChatroomMember[];
}
TypeScriptexport type V2NIMChatroomMemberListResult = {
pageToken: string
finished: boolean
memberList: V2NIMChatroomMember
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
pageToken |
String | 是 | 分页偏移。 |
finished |
boolean | 是 | 群成员是否全部获取: |
memberList |
List<V2NIMChatroomMember > |
是 | 分页获取的聊天室成员列表。 |
V2NIMChatroomMessageListOption
聊天室历史消息分页查询选项。
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;
}
}
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
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};
};
TypeScriptexport type V2NIMChatroomMessageListOption = {
direction?: V2NIMQueryDirection
messageTypes?: V2NIMMessageType[]
beginTime?: number
limit?: number
}
TypeScriptinterface V2NIMChatroomMessageListOption {
direction?: V2NIMQueryDirection;
messageTypes?: V2NIMMessageType[];
beginTime?: number;
limit?: number;
}
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
聊天室成员角色更新参数。
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;
}
}
Objective-C@interface V2NIMChatroomMemberRoleUpdateParams: NSObject
@property (nonatomic, assign) V2NIMChatroomMemberRole memberRole;
@property (nonatomic, assign) NSInteger memberLevel;
@property (nullable, nonatomic, copy) NSString *notificationExtension;
@end
C++struct V2NIMChatroomMemberRoleUpdateParams {
V2NIMChatroomMemberRole memberRole{V2NIM_CHATROOM_MEMBER_ROLE_NORMAL};
nstd::optional<uint32_t> memberLevel;
nstd::optional<nstd::string> notificationExtension;
};
TypeScriptexport type V2NIMChatroomMemberRoleUpdateParams = {
memberRole: V2NIMChatroomMemberRole
memberLevel?: number
notificationExtension?: string
}
TypeScriptinterface V2NIMChatroomMemberRoleUpdateParams {
memberRole?: V2NIMChatroomMemberRole;
memberLevel?: number;
notificationExtension?: string;
}
TypeScriptexport type V2NIMChatroomMemberRoleUpdateParams = {
memberRole: V2NIMChatroomMemberRole
memberLevel?: number
notificationExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
memberRole |
V2NIMChatroomMemberRole |
是 | - | 聊天室成员角色类型: |
memberLevel |
int | 否 | 0,表示未设置 | 聊天室成员等级,大于或等于 0 的整数。 |
notificationExtension |
String | 否 | null | 聊天室成员角色变更通知的扩展字段。 |
V2NIMChatroomUpdateParams
聊天室信息更新参数。
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;
}
}
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
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;
};
TypeScriptexport interface V2NIMChatroomUpdateParams {
roomName?: string;
announcement?: string;
liveUrl?: string;
serverExtension?: string;
notificationEnabled?: boolean;
notificationExtension?: string;
}
TypeScriptinterface V2NIMChatroomUpdateParams {
roomName?: string;
announcement?: string;
liveUrl?: string;
serverExtension?: string;
notificationEnabled?: boolean;
notificationExtension?: string;
}
TypeScriptexport interface V2NIMChatroomUpdateParams {
roomName?: string
announcement?: string
liveUrl?: string
serverExtension?: string
notificationEnabled?: boolean
notificationExtension?: string
}
成员参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
roomName |
String | 否 | 聊天室名称。设置为空表示不更新该字段,不可设置为 "",否则返回参数错误。 |
announcement |
String | 否 | 聊天室公告。设置为空表示不更新该字段。 |
liveUrl |
String | 否 | 视频直播拉流地址。设置为空表示不更新该字段。 |
serverExtension |
String | 否 | 聊天室服务端扩展字段。必须为 JSON 格式封装,长度上限为 4096 字节,多端同步。 设置为空表示不更新该字段。 |
notificationEnabled |
boolean | 否,默认 true | 操作后是否需要通知。 |
notificationExtension |
String | 否 | 聊天室信息变更通知的扩展字段。 |
V2NIMChatroomSelfMemberUpdateParams
聊天室成员更新本人信息参数。
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;
}
}
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
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};
};
TypeScriptexport type V2NIMChatroomSelfMemberUpdateParams = {
roomNick?: string
roomAvatar?: string
serverExtension?: string
notificationEnabled?: boolean
notificationExtension?: string
persistence?: boolean
}
TypeScriptinterface V2NIMChatroomSelfMemberUpdateParams {
roomNick?: string;
roomAvatar?: string;
serverExtension?: string;
notificationEnabled?: boolean;
notificationExtension?: string;
persistence?: boolean;
}
TypeScriptexport type V2NIMChatroomSelfMemberUpdateParams = {
roomNick?: string
roomAvatar?: string
serverExtension?: string
notificationEnabled?: boolean
notificationExtension?: string
persistence?: boolean
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
roomNick |
String | 否 | - | 聊天室中显示昵称。设置为空表示不更新该字段,不可设置为 "",否则返回参数错误。 |
roomAvatar |
String | 否 | - | 聊天室中显示头像。设置为空表示不更新该字段。 |
serverExtension |
String | 否 | - | 聊天室成员服务端扩展字段,多端同步。建议 JSON 格式,长度上限为 2048。 设置为空表示不更新该字段。 |
notificationEnabled |
boolean | 否 | true | 操作后是否需要通知。 |
notificationExtension |
String | 否 | - | 操作后通知的扩展字段。 |
persistence |
String | 否 | false | 更新信息是否持久化,即是否将数据保存在本地数据库中。 |
V2NIMChatroomTagTempChatBannedParams
聊天室标签用户临时禁言参数。
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;
}
}
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
C++struct V2NIMChatroomTagTempChatBannedParams {
nstd::string targetTag;
nstd::string notifyTargetTags;
uint64_t duration{0};
bool notificationEnabled{true};
nstd::string notificationExtension;
};
TypeScriptexport interface V2NIMChatroomTagTempChatBannedParams {
targetTag: string
notifyTargetTags: string
duration: number
notificationEnabled: boolean
notificationExtension: string
}
TypeScriptinterface V2NIMChatroomTagTempChatBannedParams {
targetTag?: string;
notifyTargetTags?: string;
duration?: number;
notificationEnabled?: boolean;
notificationExtension?: string;
}
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
聊天室标签信息更新参数。
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;
}
}
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
C++struct V2NIMChatroomTagsUpdateParams {
nstd::optional<nstd::vector<nstd::string>> tags;
nstd::optional<nstd::string> notifyTargetTags;
bool notificationEnabled{true};
nstd::string notificationExtension;
};
TypeScriptexport interface V2NIMChatroomtagsUpdateParams {
tags?: string[]
notifyTargetTags?: string
notificationEnabled?: boolean
notificationExtension?: string
}
TypeScriptinterface V2NIMChatroomTagsUpdateParams {
tags?: string[];
notifyTargetTags?: string;
notificationEnabled?: boolean;
notificationExtension?: string;
}
TypeScriptexport interface V2NIMChatroomtagsUpdateParams {
tags?: string[]
notifyTargetTags?: string
notificationEnabled?: boolean
notificationExtension?: string
}
成员参数
tags
和 notifyTargetTags
必须设置其一,否则返回参数错误。
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
tags |
List<String> | 否 | 聊天室标签信息。 设置为空表示不更新,设置为 [] 表示清空原有标签。 |
notifyTargetTags |
String | 否 | 操作后通知的标签信息,标签表达式请参考 聊天室标签管理。 设置为空表示不更新,设置为 "" 表示清空原有通知标签信息。 |
notificationEnabled |
boolean | 否,默认 true | 操作后是否需要通知。 |
notificationExtension |
String | 否 | 操作后通知的扩展字段。 |
V2NIMChatroomTagMemberOption
聊天室标签成员查询选项。
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;
}
}
Objective-C@interface V2NIMChatroomTagMemberOption: NSObject
@property (nonnull, nonatomic, copy) NSString *tag;
@property (nonatomic, copy) NSString *pageToken;
@property (nonatomic, assign) NSInteger limit;
@end
C++struct V2NIMChatroomTagMemberOption {
nstd::string tag;
nstd::string pageToken;
uint32_t limit{V2NIM_DEFAULT_CHATROOM_QUERY_LIMIT};
};
TypeScriptexport type V2NIMChatroomTagMemberOption = {
tag: string
pageToken?: number
limit?: number
}
TypeScriptinterface V2NIMChatroomTagMemberOption {
tag?: string;
pageToken?: string;
limit?: number;
}
TypeScriptexport type V2NIMChatroomTagMemberOption = {
tag: string
pageToken?: number
limit?: number
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
tag |
String | 是 | - | 聊天室标签信息。 |
pageToken |
String | 否 | "" | 分页偏移,首次查询传空,下一次查询传入上一次查询返回值中的 nextToken 。 |
limit |
int | 否 | 100 | 单次查询最大数量。必须大于 0,否则返回参数错误。 |
V2NIMChatroomTagMessageOption
按标签分页查询聊天室消息选项。
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;
}
}
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
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};
};
TypeScriptexport type V2NIMChatroomTagMessageOption = {
tags?: string[]
messageTypes?: V2NIMMessageType[]
beginTime?: number
endTime?: number
limit?: number
direction?: V2NIMQueryDirection
}
TypeScriptinterface V2NIMChatroomTagMessageOption {
tags?: string[];
messageTypes?: V2NIMMessageType[];
beginTime?: number;
endTime?: number;
limit?: number;
direction?: V2NIMQueryDirection;
}
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
注册聊天室实例监听后,当相关事件发生时,会返回对应回调。
Javapublic interface V2NIMChatroomClientListener {
void onChatroomStatus(V2NIMChatroomStatus status,V2NIMError error);
void onChatroomEntered();
void onChatroomExited(V2NIMError error);
void onChatroomKicked(V2NIMChatroomKickedInfo kickedInfo);
}
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
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;
};
TypeScriptexport type V2NIMChatroomClientListener = {
onChatroomStatus: [status: V2NIMChatroomStatus, error?: V2NIMError]
onChatroomEntered: []
onChatroomExited: [error?: V2NIMError]
onChatroomKicked: [kickedInfo: V2NIMChatroomKickedInfo]
}
TypeScriptinterface V2NIMChatroomClientEvents {
chatroomStatus: ((status: number, error: V2NIMError) => void);
chatroomEntered: (() => void);
chatroomExited: ((error: V2NIMError) => void);
chatroomKicked: ((kickedInfo: V2NIMChatroomKickedInfo) => void);
}
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
注册聊天室监听后,当相关事件发生时,会返回对应回调。
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);
}
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
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;
};
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>]
}
TypeScriptinterface V2NIMChatroomClientEvents {
chatroomStatus: ((status: number, error: V2NIMError) => void);
chatroomEntered: (() => void);
chatroomExited: ((error: V2NIMError) => void);
chatroomKicked: ((kickedInfo: V2NIMChatroomKickedInfo) => void);
}
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
文件上传任务。
Javapublic interface V2NIMUploadFileTask {
String getTaskId();
V2NIMUploadFileParams getUploadFileParams();
}
Objective-C@interface V2NIMUploadFileTask : NSObject
@property (nonatomic,strong) NSString *taskId;
@property (nonatomic,strong) V2NIMUploadFileParams *uploadParams;
@end
C++struct V2NIMUploadFileTask {
nstd::string taskId;
V2NIMUploadFileParams uploadParams;
};
TypeScriptexport interface V2NIMUploadFileTask {
taskId: string
uploadParams: V2NIMUploadFileParams
}
TypeScriptinterface V2NIMUploadFileTask {
taskId?: string;
uploadParams?: V2NIMUploadFileParams;
}
TypeScriptexport interface V2NIMUploadFileTask {
taskId: string
uploadParams: V2NIMUploadFileParams
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
taskId |
String | 是 | - | 任务 ID |
uploadParams |
V2NIMUploadFileParams |
是 | - | 文件上传参数。 |
V2NIMUploadFileParams
文件上传任务。
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();
}
}
Objective-C@interface V2NIMUploadFileParams : NSObject
@property (nonatomic,strong) NSString *filePath;
@property (nonatomic,strong) NSString *sceneName;
@end
C++struct V2NIMUploadFileParams {
nstd::string filePath;
nstd::string sceneName;
};
TypeScriptexport interface V2NIMUploadFileParams {
fileObj: File | string
sceneName: string
}
TypeScriptinterface V2NIMUploadFileParams {
filePath?: string;
sceneName?: string;
}
TypeScriptexport interface V2NIMUploadFileParams {
filePath: string
sceneName: string
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
filePath |
String | 非 Web 端必填 | - | 文件地址。 |
fileObj |
String/File | 仅 Web 端必填 | - | |
sceneName |
String | 否 | DEFAULT_PROFILE 对应场景名,默认为 nim_default_profile_icon |
场景名。 使用自定义场景前,需要先调用 V2NIMStorageService.addCustomStorageScene 新增自定义场景名。 |
V2NIMFileMetaInfo(仅 Web)
文件相关媒体信息。
TypeScriptinterface V2NIMFileMetaInfo {
audioCodec?: string;
container?: string;
duration?: number;
ext: string;
height?: number;
md5?: string;
name: string;
orientation?: string;
size: number;
url: string;
videoCodec?: string;
width?: number;
}
成员参数
名称 | 类型 | 是否必填 | 是否只读 | 说明 |
---|---|---|---|---|
url |
string | 是 | 是 | 文件资源的 url 地址。 |
name |
string | 是 | 否 | 文件名称。 |
size |
int | 否 | 是 | 文件大小,单位字节。 |
ext |
string | 否 | 是 | 文件后缀名。 |
md5 |
string | 否 | 是 | 文件摘要 md5 值。 |
height |
int | 否 | 是 | 高度。如果为图片/视频,则为对应文件高度。 |
width |
int | 否 | 是 | 宽度。如果为图片/视频,则为对应文件宽度。 |
duration |
int | 否 | 是 | 时长。如果为音频/视频,则为对应文件时长。 |
orientation |
string | 否 | 是 | 文件方向,如果文件为图片/视频,则为对应文件方向。 |
audioCodec |
string | 否 | 是 | 音频的解码格式。 |
videoCodec |
string | 否 | 是 | 视频的解码格式。 |
container |
string | 否 | 是 | 音视频的容器。 |
V2NIMClientAntispamUtil
客户端本地反垃圾工具。
成员函数
-
checkTextAntispam
对输入的文本进行本地反垃圾检查,根据反垃圾配置规则返回不同的内容。
- 请在登录 IM 后调用该函数。
- 本地有缓存数据(除 Web),支持以当前状态进行检测。
- 参数说明
AndroidJava
public static V2NIMClientAntispamResult checkTextAntispam(String text, String replace)
参数名称 类型 是否必填 默认值 说明 text
String 是 - 待本地反垃圾检测的文本。 replace
String 否 null 检测到的敏感内容替换词。 iOSObjective-C
+ (V2NIMClientAntispamUtil *)checkTextAntispam:(NSString *)text replace:(nullable NSString *)replace;
参数名称 类型 是否必填 默认值 说明 text
NSString * 是 - 待本地反垃圾检测的文本。 replace
NSString * 否 null 检测到的敏感内容替换词。 macOS/WindowsC++
static V2NIMClientAntispamResult checkTextAntispam(nstd::string text, nstd::string replace);
参数名称 类型 是否必填 默认值 说明 text
nstd::string 是 - 待本地反垃圾检测的文本。 replace
nstd::string 否 null 检测到的敏感内容替换词。 Web/uni-app/小程序TypeScript
checkTextAntispam(text: string, replace?: string): V2NIMClientAntispamResult
参数名称 类型 是否必填 默认值 说明 text
string 是 - 待本地反垃圾检测的文本。 replace
string 否 null 检测到的敏感内容替换词。 Node.js/ElectronTypeScript
checkTextAntispam(text, replace): V2NIMClientAntispamResult
参数名称 类型 是否必填 默认值 说明 text
string 是 - 待本地反垃圾检测的文本。 replace
string 否 null 检测到的敏感内容替换词。 HarmonyOSTypeScript
checkTextAntispam(text: string, shield: string): V2NIMClientAntispamResult
参数名称 类型 是否必填 默认值 说明 text
string 是 - 待本地反垃圾检测的文本。 shield
string 否 null 检测到的敏感内容替换词。 - 示例代码
AndroidJava
V2NIMClientAntispamResult res = V2NIMClientAntispamUtil.checkTextAntispam('bad sentense', '***')
iOSObjective-C
V2NIMClientAntispamResult *res = [V2NIMClientAntispamUtil checkTextAntispam:@"bad sentense" replace:@"***"];
macOS/WindowsC++
auto result = V2NIMClientAntispamUtil::checkTextAntispam("spam text", "*");
Web/uni-app/小程序TypeScript
const res = nim.V2NIMClientAntispamUtil.checkTextAntispam('bad sentense', '***')
Node.js/ElectronTypeScript
const result = v2.clientAntispamUtil.checkTextAntispam(text, replace)
HarmonyOSTypeScript
const res = nim.localAntispamUtil.checkTextAntispam('bad sentense', '***')
V2NIMAntispamConfig
若需要使用反垃圾检测,但不使用网易云信安全通默认配置,则需要通过该类定制审核规则。
Javapublic class V2NIMAntispamConfig {
private String antispamBusinessId;
public V2NIMAntispamConfig() {
}
public V2NIMAntispamConfig(String antispamBusinessId) {
this.antispamBusinessId = antispamBusinessId;
}
public String getAntispamBusinessId() {
return antispamBusinessId;
}
public void setAntispamBusinessId(String antispamBusinessId) {
this.antispamBusinessId = antispamBusinessId;
}
}
Objective-C@interface V2NIMAntispamConfig : NSObject
@property(nonatomic,strong,readwrite) NSString *antispamBusinessId;
@end
C++struct V2NIMAntispamConfig {
nstd::string antispamBusinessId;
};
TypeScriptinterface V2NIMAntispamConfig: { antispamBusinessId: string }
TypeScriptinterface V2NIMAntispamConfig {
antispamBusinessId?: string;
}
TypeScriptinterface V2NIMAntispamConfig {
antispamBusinessId: string;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
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。 |
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 | 否 | 应用的数据目录,为空则使用默认目录。 默认数据: |
basicOption |
V2NIMBasicOption |
否 | 基础配置。 |
linkOption |
V2NIMLinkOption |
否 | 连接相关配置。 |
databaseOption |
V2NIMDatabaseOption |
否 | 数据库配置。 |
fcsOption |
V2NIMFCSOption |
否 | 融合存储配置。 |
privateServerOption |
nstd::optional<V2NIMPrivateServerOption > |
否 | 私有化配置。 |
V2NIMUpdatedTeamInfo
群信息更新。
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();
String getCustomerExtension();
}
Objective-C@interface V2NIMUpdatedTeamInfo : NSObject
@property(nullable,nonatomic,copy,readonly) NSString *name;
@property(nonatomic,assign,readonly) NSInteger memberLimit;
@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(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(nullable,nonatomic,copy,readonly) NSString *customerExtension;
@end
C++struct V2NIMUpdatedTeamInfo : V2NIMUpdateTeamInfoParams {
nstd::optional<V2NIMTeamChatBannedMode> chatBannedMode;
nstd::optional<nstd::string> customerExtension;
};
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
customerExtension?: string
}
TypeScriptinterface 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;
}
TypeScriptinterface V2NIMUpdatedTeamInfo {
agreeMode?: V2NIMTeamAgreeMode;
announcement?: string;
avatar?: string;
chatBannedMode?: V2NIMTeamChatBannedMode;
customerExtension?: string;
intro?: string;
inviteMode?: V2NIMTeamInviteMode;
joinMode?: V2NIMTeamJoinMode;
memberLimit?: number;
name?: string;
serverExtension?: string;
updateExtensionMode?: V2NIMTeamUpdateExtensionMode;
updateInfoMode?: V2NIMTeamUpdateInfoMode;
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
name |
String | 否 | - | 群组名称 |
memberLimit |
int | 否 | - | 群组人数上限。若为空,则表示不修改。 |
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 不禁言 |
群组禁言状态。 |
customerExtension |
String | 否 | - | 客户自定义扩展,仅服务器 API 可以设置,内容透传,云信不解析内容。 |
V2NIMSubscribeUserStatusOption
订阅用户状态的配置参数。
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;
}
}
Objective-C@interface V2NIMSubscribeUserStatusOption : NSObject
@property(nonatomic,copy) NSArray<NSString *> * _Nonnull accountIds;
@property(nonatomic,assign) NSInteger duration;
@property(nonatomic,assign) BOOL immediateSync;
@end
C++struct V2NIMSubscribeUserStatusOption {
nstd::vector<nstd::string> accountIds;
uint32_t duration{V2NIM_DEFAULT_SUBSCRIBE_DURATION};
bool immediateSync{false};
};
TypeScriptexport interface V2NIMSubscribeUserStatusOption {
accountIds: Array<string>
duration?: number
immediateSync?: boolean
}
TypeScriptinterface V2NIMSubscribeUserStatusOption {
accountIds: string[];
duration?: number;
immediateSync?: boolean;
}
TypeScriptinterface V2NIMSubscribeUserStatusOption {
accountIds: string[];
duration?: number;
immediateSync?: boolean;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
accountIds |
List<String> | 是 | - | 订阅的成员列表,为空返回参数错误,单次订阅的数量不超过 100 个,超限则返回参数错误。 |
duration |
Long | 否 | 60s | 订阅的有效期。 |
immediateSync |
Boolean | 否 | false | 订阅后是否立即同步事件状态值。默认为 false,即不立即同步。若设置为 true,表示立即同步当前状态值。但为了性能考虑,30s 内重复订阅,会忽略该参数。 |
V2NIMUserStatus
用户状态对象。
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();
}
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);
}
}
}
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
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;
};
TypeScriptexport interface V2NIMUserStatus {
accountId: string
statusType: number
clientType: V2NIMLoginClientType
publishTime: number
uniqueId?: number
duration?: number
extension?: string
serverExtension?: string
}
TypeScriptinterface V2NIMUserStatus {
accountId: string;
statusType: number;
clientType: V2NIMLoginClientType;
publishTime: number;
uniqueId?: string;
duration?: number;
extension?: string;
serverExtension?: string;
}
TypeScriptinterface V2NIMUserStatus {
accountId: string;
clientType: V2NIMLoginClientType;
duration?: number;
extension?: string;
publishTime: number;
serverExtension?: string;
statusType: number;
uniqueId?: number;
}
成员参数
名称 | 类型 | 是否必填 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|---|
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
取消订阅用户状态的配置参数。
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;
}
}
Objective-C@interface V2NIMUnsubscribeUserStatusOption : NSObject
@property(nonatomic,copy) NSArray<NSString *> * _Nullable accountIds;
@end
C++struct V2NIMUnsubscribeUserStatusOption {
nstd::optional<nstd::vector<nstd::string>> accountIds;
};
TypeScriptexport interface V2NIMUnsubscribeUserStatusOption {
accountIds: Array<string>
}
TypeScriptinterface V2NIMUnsubscribeUserStatusOption {
accountIds?: string[];
}
TypeScriptinterface V2NIMUnsubscribeUserStatusOption {
accountIds: string[];
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
accountIds |
List<String> | 否 | - | 取消订阅的成员列表,为空则表示取消所有订阅的成员,否则取消指定的成员。单次取消订阅的数量不超过 100,超过返回 191004 错误。 |
V2NIMCustomUserStatusParams
自定义用户状态数据结构。
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;
}
}
}
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
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};
};
TypeScriptexport interface V2NIMCustomUserStatusParams {
statusType: number
duration?: number
extension?: string
onlineOnly?: boolean
multiSync?: boolean
}
TypeScriptinterface V2NIMCustomUserStatusParams {
statusType: number;
duration?: number;
extension?: string;
onlineOnly?: boolean;
multiSync?: boolean;
}
TypeScriptinterface V2NIMCustomUserStatusParams {
duration?: number;
extension?: string;
multiSync?: boolean;
onlineOnly?: boolean;
statusType: number;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
statusType |
Int | 是 | - | 自定义状态设置值,10000 及以上(9999 以内为预定义值,不可使用)。若设置的值小于 10000 或超过 Int 上限,则返回参数错误。 |
duration |
Long | 是 | 60s | 自定义状态的有效期,范围为 60s ~ 604800s(72460*60s)。 |
extension |
String | 否 | - | 用户发布状态时设置的扩展字段。 |
onlineOnly |
Boolean | 否 | true | 用户发布状态时是否只广播给在线的订阅者。 |
multiSync |
Boolean | 否 | false | 用户发布状态时是否需要多端同步。 |
V2NIMUserStatusSubscribeResult
用户状态订阅的结果。
Javapublic interface V2NIMUserStatusSubscribeResult {
String getAccountId();
long getDuration();
long getSubscribeTime();
}
Objective-C@interface V2NIMUserStatusSubscribeResult : NSObject
@property(nonatomic,copy,readonly) NSString *accountId;
@property(nonatomic,assign,readonly) NSInteger duration;
@property(nonatomic,assign,readonly) NSTimeInterval subscribeTime;
@end
C++struct V2NIMUserStatusSubscribeResult {
nstd::string accountId;
uint32_t duration;
time_t subscribeTime;
};
TypeScriptexport interface V2NIMUserStatusSubscribeResult {
accountId: string
duration: number
subscribeTime: number
}
TypeScriptinterface V2NIMUserStatusSubscribeResult {
accountId: string;
duration: number;
subscribeTime: number;
}
TypeScriptinterface V2NIMUserStatusSubscribeResult {
accountId: string;
duration: number;
subscribeTime: number;
}
成员参数
名称 | 类型 | 是否必填 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|---|
accountId |
String | 是 | 是 | - | 查询的用户账号 ID。 |
duration |
Long | 是 | 是 | 60s | 订阅的有效期,范围为 60s ~ 2592000s(302460*60s)。 |
subscribeTime |
Long | 是 | 是 | - | 订阅时间。 |
V2NIMCustomUserStatusPublishResult
自定义用户状态发布的结果。
Javapublic interface V2NIMCustomUserStatusPublishResult {
String getUniqueId();
String getServerId();
long getPublishTime();
}
Objective-C@interface V2NIMCustomUserStatusPublishResult : NSObject
@property(nonatomic,copy,readonly) NSString *uniqueId;
@property(nonatomic,copy,readonly) NSString *serverId;
@property(nonatomic,assign,readonly) NSTimeInterval publishTime;
@end
C++struct V2NIMCustomUserStatusPublishResult {
nstd::string uniqueId;
nstd::string serverId;
time_t publishTime;
};
TypeScriptexport interface V2NIMCustomUserStatusPublishResult {
uniqueId: string
serverId: string
publishTime: number
}
TypeScriptinterface V2NIMCustomUserStatusPublishResult {
uniqueId: string;
serverId: string;
publishTime: number;
}
TypeScriptinterface V2NIMCustomUserStatusPublishResult {
publishTime: number;
serverId: string;
uniqueId: string;
}
成员参数
名称 | 类型 | 是否必填 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|---|
uniqueId |
String | 是 | 是 | - | 发布自定义用户状态时内部生成的唯一 ID。 |
serverId |
String | 是 | 是 | - | 服务器针对该状态事件生成的 ID。 |
publishTime |
Long | 是 | 是 | - | 用户状态的发布时间。 |
V2NIMSubscribeListener
用户订阅相关监听器。
Javapublic interface V2NIMSubscribeListener {
void onUserStatusChanged(List<V2NIMUserStatus> userStatusList);
}
Objective-C@protocol V2NIMSubscribeListener <NSObject>
@optional
- (void)onUserStatusChanged:(NSArray<V2NIMUserStatus *> *)data;
@end
C++struct V2NIMSubscribeListener {
nstd::function<void(const nstd::vector<V2NIMUserStatus>&)> onUserStatusChanged;
};
TypeScriptexport type V2NIMSubscribeListener = {
onUserStatusChanged: [userStatusList: Array<V2NIMUserStatus>]
}
TypeScriptinterface V2NIMSubscriptionListener {
userStatusChanged: [V2NIMUserStatus];
}
TypeScriptinterface V2NIMSubscribeListener {
onUserStatusChanged: [userStatusList: V2NIMUserStatus[]];
}
成员函数
-
onUserStatusChanged
其他用户的用户状态变更回调,包括在线状态和自定义状态。同账号发布状态时,多端也会同步收到回调。
在线状态事件会受到推送的影响:
如果应用被清理,但厂商推送(APNS、小米、华为、OPPO、VIVO、魅族、FCM)可达,则默认不会触发该用户断开连接的事件。若您需要该种情况下视为离线,请 前往网易云信控制台>选择应用>IM 即时通讯>功能配置>全局功能>在线状态订阅 进行设置。参数名称 类型 说明 userStatusList
List<V2NIMUserStatus> 用户状态列表
V2NIMLocalConversationResult(仅 HarmonyOS)
本地会话查询结果。
TypeScriptexport interface V2NIMLocalConversationResult {
offset: number
finished: boolean
conversationList: V2NIMLocalConversation[]
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
offset |
Number | 是 | 分页偏移。首次调用传 0,后续调用时传入上一次调用返回的 offset 。 |
finished |
Boolean | 是 | 数据是否获取完毕: |
conversationList |
V2NIMLocalConversation [] |
是 | 本地会话对象列表。 |
V2NIMLocalConversationOption(仅 HarmonyOS)
本地会话查询选项。
TypeScriptexport interface V2NIMLocalConversationOption {
conversationTypes?: V2NIMConversationType[]
onlyUnread?: boolean
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
conversationTypes |
V2NIMConversationType [] |
否 | [] 或 null | 需要指定的会话类型,null 表示不限制会话类型。 |
onlyUnread |
Boolean | 否 | false | 是否仅查询包含未读数的会话: |
V2NIMLocalConversationFilter(仅 HarmonyOS)
本地会话过滤器对象。
TypeScriptexport interface V2NIMLocalConversationFilter {
conversationTypes?: V2NIMConversationType[]
ignoreMuted?: boolean
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
conversationTypes |
V2NIMConversationType [] |
否 | null | 需要过滤的会话类型,null 表示不限制会话类型。 |
ignoreMuted |
Boolean | 否 | false | 是否过滤具有免打扰属性(mute 为 true )的本地会话对象: |
V2NIMLocalConversation(仅 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 | 本地会话名称。 |
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)
单条本地会话操作结果。
TypeScriptexport interface V2NIMLocalConversationOperationResult {
conversationId: string
error: V2NIMError
}
成员参数
名称 | 类型 | 是否只读 | 说明 |
---|---|---|---|
conversationId |
String | 是 | 操作失败的本地会话 ID。如果操作成功则为空。组成方式:用户账号(accountId)| 会话类型(V2NIMConversationType )| 聊天对象账号(accountId)或群组 ID。 |
error |
V2NIMError | 是 | 操作失败的错误码和错误信息,如果操作成功,则为空。 |
V2NIMLocalConversationListener(仅 HarmonyOS)
本地会话相关监听器。
调用 on("EventName")
注册会话监听后,当会话相关事件发生时,会返回对应回调。
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 标记的时间戳
V2NIMChatroomQueueListener
聊天室队列监听器。
调用 addQueueListener
注册聊天室队列监听后,当相关事件发生时,会返回对应回调。
Javapublic interface V2NIMChatroomQueueListener {
void onChatroomQueueOffered(V2NIMChatroomQueueElement element);
void onChatroomQueuePolled(V2NIMChatroomQueueElement element);
void onChatroomQueueDropped();
void onChatroomQueuePartCleared(List<V2NIMChatroomQueueElement> elements);
void onChatroomQueueBatchUpdated(List<V2NIMChatroomQueueElement> elements);
void onChatroomQueueBatchOffered(List<V2NIMChatroomQueueElement> elements);
C++struct V2NIMChatroomQueueListener {
nstd::function<void(const V2NIMChatroomQueueElement& element)> onChatroomQueueOffered;
nstd::function<void(const V2NIMChatroomQueueElement& element)> onChatroomQueuePolled;
nstd::function<void()> onChatroomQueueDropped;
nstd::function<void(const nstd::vector<V2NIMChatroomQueueElement>& keyValues)> onChatroomQueuePartCleared;
nstd::function<void(const nstd::vector<V2NIMChatroomQueueElement>& keyValues)> onChatroomQueueBatchUpdated;
nstd::function<void(const nstd::vector<V2NIMChatroomQueueElement>& keyValues)> onChatroomQueueBatchOffered;
};
TypeScriptexport type V2NIMChatroomQueueListener = {
onChatroomQueueOffered: [keyValues: { [key: string]: string }[]]
onChatroomQueuePolled: [keyValues: { [key: string]: string }[]]
onChatroomQueueDroped: [keyValues: { [key: string]: string }[]]
onChatroomQueuePartCleared: [keyValues: { [key: string]: string }[]]
onChatroomQueueBatchUpdated: [keyValues: { [key: string]: string }[]]
onChatroomQueueBatchOffered: [keyValues: { [key: string]: string }[]]
}
TypeScriptinterface V2NIMChatroomQueueListener {
chatroomQueueOffered: [V2NIMChatroomQueueElement];
chatroomQueuePolled: [V2NIMChatroomQueueElement];
chatroomQueueDropped: [];
chatroomQueuePartCleared: [V2NIMChatroomQueueElement[]];
chatroomQueueBatchUpdated: [V2NIMChatroomQueueElement[]];
chatroomQueueBatchOffered: [V2NIMChatroomQueueElement[]];
}
TypeScriptV2NIMChatroomQueueListener: {
onChatroomQueueBatchOffered: [elements: V2NIMChatroomQueueElement[]];
onChatroomQueueBatchUpdated: [elements: V2NIMChatroomQueueElement[]];
onChatroomQueueDropped: [];
onChatroomQueueOffered: [element: V2NIMChatroomQueueElement];
onChatroomQueuePartCleared: [elements: V2NIMChatroomQueueElement[]];
onChatroomQueuePolled: [element: V2NIMChatroomQueueElement];
}
成员函数
-
onChatroomQueueOffered
聊天室新增队列元素回调。在聊天室队列中新增元素成功后,SDK 会返回该回调。
参数名称 类型 说明 element
V2NIMChatroomQueueElement 新增的队列元素 -
onChatroomQueuePolled
聊天室取出(移除)队列元素回调。在聊天室队列中取出(移除)元素会触发该回调。
参数名称 类型 说明 element
V2NIMChatroomQueueElement 取出的队列元素 -
onChatroomQueueDropped
聊天室清空队列元素回调。聊天室队列中的元素被清空会触发该回调。
-
onChatroomQueuePartCleared
聊天室清理部分队列元素回调。聊天室队列中的部分元素被清理时会触发该回调。
参数名称 类型 说明 elements
List< V2NIMChatroomQueueElement
>被清理的队列元素列表 -
onChatroomQueueBatchUpdated
聊天室批量更新队列元素回调。当聊天室队列中的元素被批量更新时会触发该回调。
参数名称 类型 说明 elements
List< V2NIMChatroomQueueElement
>被批量更新的队列元素列表 -
onChatroomQueueBatchOffered
聊天室批量添加队列元素回调。当聊天室队列中批量添加元素时会触发该回调。
参数名称 类型 说明 elements
List< V2NIMChatroomQueueElement
>被批量添加的队列元素列表
V2NIMChatroomQueueElement
聊天室队列元素信息。
Javapublic class V2NIMChatroomQueueElement implements Serializable {
private final String key;
private final String value;
private String accountId;
private String nick;
private String extension;
private V2NIMChatroomQueueElement() {
this.key = null;
this.value = null;
}
public V2NIMChatroomQueueElement(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getNick() {
return nick;
}
public void setNick(String nick) {
this.nick = nick;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
}
C++struct V2NIMChatroomQueueElement {
nstd::string key;
nstd::string value;
nstd::optional<nstd::string> accountId;
nstd::optional<nstd::string> nick;
nstd::optional<nstd::string> extension;
};
TypeScriptinterface V2NIMChatroomQueueElement {
accountId?: string;
key: string;
nick?: string;
value: string;
}
TypeScriptinterface V2NIMChatroomQueueElement {
key: string;
value: string;
accountId?: string;
nick?: string;
extension?: string;
}
TypeScriptinterface V2NIMChatroomQueueElement {
accountId?: string;
key: string;
nick?: string;
value: string;
}
成员参数
名称 | 类型 | 是否只读 | 默认值 | 说明 |
---|---|---|---|---|
key |
String | 是 | - | 队列元素的 Key。 |
value |
String | 是 | - | 队列元素的值。 |
accountId |
String | 否 | - | 该队列元素所属的账号。 |
nick |
String | 否 | - | 该队列元素所属账号的昵称。 |
extension |
String | 否 | - | 队列元素的扩展字段,JSON 格式。 |
V2NIMChatroomQueueOfferParams
新增或更新队列元素的配置参数。
Javapublic class V2NIMChatroomQueueOfferParams {
private final String elementKey;
private final String elementValue;
private boolean isTransient = false;
private String elementOwnerAccountId;
public V2NIMChatroomQueueOfferParams(String elementKey, String elementValue) {
this.elementKey = elementKey;
this.elementValue = elementValue;
}
private V2NIMChatroomQueueOfferParams() {
this.elementKey = null;
this.elementValue = null;
}
public String getElementKey() {
return elementKey;
}
public String getElementValue() {
return elementValue;
}
public boolean isTransient() {
return isTransient;
}
public void setTransient(boolean isTransient) {
this.isTransient = isTransient;
}
public String getElementOwnerAccountId() {
return elementOwnerAccountId;
}
public void setElementOwnerAccountId(String elementOwnerAccountId) {
this.elementOwnerAccountId = elementOwnerAccountId;
}
public boolean isValid(){
if(TextUtils.isEmpty(elementKey)){
return false;
}
if(TextUtils.isEmpty(elementValue)){
return false;
}
return true;
}
}
C++struct V2NIMChatroomQueueOfferParams {
nstd::string elementKey;
nstd::string elementValue;
bool transient{false};
nstd::optional<nstd::string> elementOwnerAccountId;
};
TypeScriptexport interface V2NIMChatroomQueueOfferParams {
elementKey: string
elementValue: string
transient?: boolean
ownerAccountId?: string
}
TypeScriptinterface V2NIMChatroomQueueOfferParams {
elementKey?: string;
elementValue?: string;
transient?: boolean;
elementOwnerAccountId?: string;
}
TypeScriptinterface V2NIMChatroomQueueOfferParams {
elementKey: string;
elementOwnerAccountId?: string;
elementValue: string;
transient?: boolean;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
elementKey |
String | 是 | - | 队列元素的唯一 Key,长度限制为 128 字节。如果队列元素 Key 不存在,则追加到队尾,否则更新相应元素。 |
elementValue |
String | 是 | - | 队列元素的值,长度限制为 4096 字节。 |
transient |
Boolean | 否 | false | 队列元素是否瞬态。true:当前元素所属成员退出或掉线时,同步删除元素;false:当前元素所属成员退出或掉线时,仍保留元素。 |
elementOwnerAccountId |
String | 否 | - | 队列元素所属账号,默认为当前操作者;管理员操作,可以指定元素属于的合法账号。 |
V2NIMChatroomQueueNotificationAttachment
聊天室队列元素变更通知附件对象,继承自 V2NIMChatroomNotificationAttachment
。
Javapublic interface V2NIMChatroomQueueNotificationAttachment extends V2NIMChatroomNotificationAttachment{
List<V2NIMChatroomQueueElement> getElements();
V2NIMChatroomQueueChangeType getQueueChangeType();
}
Objective-C@interface V2NIMChatroomQueueNotificationAttachment: V2NIMChatroomNotificationAttachment
@property(nonatomic, strong, readonly) NSArray<NSDictionary *> *keyValues;
@property(nonatomic, assign, readonly) V2NIMChatroomQueueChangeType queueChangeType;
@end
C++struct V2NIMChatroomQueueNotificationAttachment : public V2NIMChatroomNotificationAttachment {
V2NIMChatroomQueueNotificationAttachment() { attachmentType = V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_QUEUE_NOTIFICATION; }
nstd::vector<V2NIMChatroomQueueElement> elements;
V2NIMChatroomQueueChangeType queueChangeType;
};
TypeScriptexport interface V2NIMChatroomQueueNotificationAttachment extends V2NIMChatroomNotificationAttachment {
keyValues?: { [key: string]: string }[]
queueChangeType?: number
}
TypeScriptinterface V2NIMChatroomQueueNotificationAttachment {
raw?: string;
type?: V2NIMChatroomMessageNotificationType;
targetIds?: string[];
targetNicks?: string[];
targetTag?: string;
operatorId?: string;
operatorNick?: string;
notificationExtension?: string;
tags?: string[];
keyValues?: Map<string, string>[];
queueChangeType?: V2NIMChatroomQueueChangeType;
}
TypeScriptinterface V2NIMChatroomQueueNotificationAttachment {
keyValues?: {
[key: string]: string;
}[];
notificationExtension?: string;
operatorId?: string;
operatorNick?: string;
queueChangeType?: V2NIMChatroomQueueChangeType;
tags?: string[];
targetIds?: string[];
targetNicks?: string;
targetTag?: string;
type: V2NIMChatroomMessageNotificationType;
}
成员参数
名称 | 类型 | 是否必填 | 默认值 | 说明 |
---|---|---|---|---|
elements |
List<V2NIMChatroomQueueElement> | 否 | - | 聊天室队列变更的内容。 |
queueChangeType |
V2NIMChatroomQueueChangeType | 否 | - | 聊天室队列更新类型。 |
枚举
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 | 群消息单向撤回,发送方无感知,接收方收到撤回通知并清除消息。 |
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 | 全员禁言,包括群主和管理员。 |
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 | 断开连接。 |
V2NIMChatroomQueueLevelMode
聊天室队列操作权限类型。
枚举类型 | 枚举值 | 说明 |
---|---|---|
V2NIM_CHATROOM_QUEUE_LEVEL_MODE_ANY | 0 | 聊天室中所有人都有权限。 |
V2NIM_CHATROOM_QUEUE_LEVEL_MODE_MANAGER | 1 | 只有聊天室创建者和管理员才有权限。 |
V2NIMChatroomQueueChangeType
聊天室队列通知消息类型。
枚举类型 | 枚举值 | 说明 |
---|---|---|
V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_UNKNOWN | 0 | 未知。 |
V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_OFFER | 1 | 新增队列元素。 |
V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_POLL | 2 | 移除队列元素。 |
V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_DROP | 3 | 清空所有元素。 |
V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_PARTCLEAR | 4 | 清理部分元素。 |
V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_BATCH_UPDATE | 5 | 批量更新元素。 |
V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_BATCH_OFFER | 6 | 批量添加元素。 |
V2NIMSearchKeywordMathType
搜索关键字匹配条件。
枚举类型 | 枚举值 | 说明 |
---|---|---|
V2NIM_SEARCH_KEYWORD_MATH_TYPE_OR | 0 | 或关系。 |
V2NIM_SEARCH_KEYWORD_MATH_TYPE_AND | 1 | 与关系。 |