系统设置
更新时间: 2024/04/18 18:11:00
NetEase IM SDK(以下简称 NIM SDK)提供系统设置相关功能,支持设置单聊/群聊消息免打扰、获取会话消息的免打扰状态等。
本文介绍系统设置相关 API。
支持平台
Android | iOS | macOS/Windows | Web/uni-app/小程序 |
---|---|---|---|
✓ | ✓ | ✓ | ✓ |
API 概览
系统设置监听
API | 描述 | 起始版本 |
---|---|---|
addSettingListener | 注册系统设置相关监听器 | v10.2.0 |
removeSettingListener | 移除系统设置相关监听器 | v10.2.0 |
API | 描述 | 起始版本 |
---|---|---|
on("EventName") | 注册系统设置相关监听 | v10.2.0 |
off("EventName") | 取消注册系统设置相关监听 | v10.2.0 |
系统设置操作
API | 描述 | 起始版本 |
---|---|---|
setP2PMessageMuteMode | 设置单聊消息免打扰模式 | v10.2.0 |
getP2PMessageMuteMode | 获取单聊消息免打扰模式 | v10.2.0 |
getP2PMessageMuteList | 获取开启单聊消息免打扰的用户列表 | v10.2.0 |
setTeamMessageMuteMode | 设置群消息免打扰模式 | v10.2.0 |
getTeamMessageMuteMode | 获取群消息免打扰模式 | v10.2.0 |
getConversationMuteStatus | 获取会话消息免打扰状态 | v10.2.0 |
setAppBackground | 设置应用前后台状态(仅 Web 端) | v10.2.0 |
setPushMobileOnDesktopOnline | 设置当桌面端在线时,移动端是否需要推送 | v10.2.0 |
setDndConfig | 设置推送全局免打扰(仅移动端端) | v10.2.0 |
setOfflinePushConfig | 设置离线推送配置信息(仅 Web 端) | v10.2.0 |
getDndConfig | 获取推送免打扰配置信息(仅移动端) | v10.2.4 |
接口类
V2NIMSettingService
类提供系统设置相关接口,包括设置单聊/群聊消息免打扰模式、获取单聊/群聊消息免打扰模式、获取单聊消息免打扰列表、获取会话消息的免打扰状态等接口。
addSettingListener
接口描述
注册系统设置相关监听器。
注册成功后,当事件发生时,SDK 会返回对应的回调。
-
建议在初始化后调用该方法。
-
全局只需注册一次。
-
该方法为同步。
参数说明
javavoid addSettingListener(V2NIMSettingListener listener);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
listener |
V2NIMSettingListener |
是 | - | 系统设置相关监听器 |
objective-c- (void)addSettingListener:(id<V2NIMSettingListener>)listener;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
listener |
id<V2NIMSettingListener > |
是 | - | 系统设置相关监听器 |
cppvirtual void addSettingListener(V2NIMSettingListener listener) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
listener |
V2NIMSettingListener |
是 | - | 系统设置相关监听器 |
示例代码
javaNIMClient.getService(V2NIMSettingService.class).addSettingListener(new V2NIMSettingListener() {
@Override
public void onTeamMessageMuteModeChanged(String teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode) {
}
@Override
public void onP2PMessageMuteModeChanged(String accountId, V2NIMP2PMessageMuteMode muteMode) {
}
});
objective-c[[[NIMSDK sharedSDK] v2SettingService] addSettingListener:self];
cppV2NIMTeamListener listener;
listener.onTeamMessageMuteModeChanged = [](std::string teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode) {
// handle team message mute mode changed
};
listener.onP2PMessageMuteModeChanged = [](std::string accountId, V2NIMP2PMessageMuteMode muteMode) {
// handle p2p message mute mode changed
};
settingService.addSettingListener(listener);
返回值
无
removeSettingListener
接口描述
移除系统设置相关监听器。
该方法为同步。
参数说明
javavoid removeSettingListener(V2NIMSettingListener listener);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
listener |
V2NIMSettingListener |
是 | - | 系统设置相关监听器 |
objective-c- (void)removeSettingListener:(id<V2NIMSettingListener>)listener;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
listener |
id<V2NIMSettingListener > |
是 | - | 系统设置相关监听器 |
cpp virtual void removeSettingListener(V2NIMSettingListener listener) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
listener |
V2NIMSettingListener |
是 | - | 系统设置相关监听器 |
示例代码
javaNIMClient.getService(V2NIMSettingService.class).removeSettingListener(listener);
objective-c[[[NIMSDK sharedSDK] v2SettingService] removeSettingListener:self];
cppV2NIMTeamListener listener;
// ...
settingService.removeSettingListener(listener);
返回值
无
on("EventName")
支持平台
Android | iOS | macOS/Windows | Web |
---|---|---|---|
× | × | × | ✓ |
接口描述
注册系统设置相关监听。
注册成功后,当事件发生时,SDK 会返回对应的回调。
-
建议在初始化后调用该方法。
-
全局只需注册一次。
-
该方法为同步。
参数说明
typescriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 EventEmitter3 的监听事件方法。
*/
on<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
/**
* 继承自 EventEmitter3 的监听事件方法。
*/
once<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
}
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
eventName |
T | 是 | - | 事件名称:onTeamMessageMuteModeChanged :群消息免打扰模式变更回调,包括群组 ID、群组类型、群消息免打扰模式。onP2PMessageMuteModeChanged :单聊(点对点)消息免打扰模式变更回调,包括聊天对象账号、单聊消息免打扰模式。 |
fn |
function | 是 | - | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
示例代码
typescriptnim.V2NIMSettingService.on("onTeamMessageMuteModeChanged", function (teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode)
nim.V2NIMSettingService.on("onP2PMessageMuteModeChanged", function (accountId: string, muteMode: V2NIMP2PMessageMuteMode)
返回值
无
off("EventName")
支持平台
Android | iOS | macOS/Windows | Web |
---|---|---|---|
× | × | × | ✓ |
接口描述
取消注册系统设置相关监听。
该方法为同步。
参数说明
typescriptexport interface NIMEBaseServiceInterface<I extends NIMEBaseListener> {
/**
* 继承自 EventEmitter3 的取消监听方法。
*/
off<T extends keyof I>(eventName: T, fn: (...args: I[T]) => void): void;
/**
* 继承自 EventEmitter3 的移除事件方法。
*/
removeAllListeners<T extends keyof I>(eventName?: T): void;
}
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
eventName |
T | 是 | - | 事件名称: 事件名称:onTeamMessageMuteModeChanged :群消息免打扰模式变更回调,包括群组 ID、群组类型、群消息免打扰模式。onP2PMessageMuteModeChanged :单聊(点对点)消息免打扰模式变更回调,包括聊天对象账号、单聊消息免打扰模式。 |
fn |
function | 是 | - | 监听事件的回调函数。当事件触发时,会调用该函数进行处理。 |
示例代码
typescriptnim.V2NIMSettingService.off("onTeamMessageMuteModeChanged", function (teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode)
nim.V2NIMSettingService.off("onP2PMessageMuteModeChanged", function (accountId: string, muteMode: V2NIMP2PMessageMuteMode)
返回值
无
setP2PMessageMuteMode
接口描述
设置单聊(点对点)消息免打扰模式。
本地端或多端同步设置成功后,SDK 会返回单聊消息免打扰模式变更回调 onP2PMessageMuteModeChanged
,并触发会话变更。
参数说明
javavoid setP2PMessageMuteMode(String accountId, V2NIMP2PMessageMuteMode muteMode, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
String | 是 | - | 聊天对象用户账号,不可为空,否则返回 191004 参数错误。 |
muteMode |
V2NIMP2PMessageMuteMode |
是 | - | 消息免打扰模式:免打扰开启或免打扰关闭 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
objective-c- (void)setP2PMessageMuteMode:(NSString *)accountId
muteMode:(V2NIMP2PMessageMuteMode)muteMode
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
NSString * | 是 | - | 聊天对象用户账号,不可为空,否则返回 191004 参数错误。 |
muteMode |
V2NIMP2PMessageMuteMode |
是 | - | 消息免打扰模式:免打扰开启或免打扰关闭 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
cppvirtual void setP2PMessageMuteMode(std::string accountId,
V2NIMP2PMessageMuteMode muteMode,
V2NIMSuccessCallback<void> success,
V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
std::string | 是 | - | 聊天对象用户账号,不可为空,否则返回 191004 参数错误。 |
muteMode |
V2NIMP2PMessageMuteMode |
是 | - | 消息免打扰模式:免打扰开启或免打扰关闭 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
typescriptsetP2PMessageMuteMode(accountId: string, muteMode: V2NIMP2PMessageMuteMode): Promise<void>
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
string | 是 | - | 聊天对象用户账号,不可为空,否则返回 191004 参数错误。 |
muteMode |
V2NIMP2PMessageMuteMode |
是 | - | 消息免打扰模式:免打扰开启或免打扰关闭 |
示例代码
javaNIMClient.getService(V2NIMSettingService.class).setP2PMessageMuteMode(accountId, muteMode,
new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
}
});
objective-c[[[NIMSDK sharedSDK] v2SettingService] setP2PMessageMuteMode:@"accountId" muteMode:V2NIM_P2P_MESSAGE_MUTE_MODE_OFF success:^{
// 成功回调
} failure:^(V2NIMError * _Nonnull error) {
// 失败回调
}];
cppsettingService.setP2PMessageMuteMode(
"accountId",
V2NIM_P2P_MESSAGE_MUTE_MODE_ON,
[]() {
// set p2p mute mode succeeded
},
[](V2NIMError error) {
// set p2p mute mode failed, handle error
});
typescriptnim.V2NIMSettingService.setP2PMessageMuteMode('accountId', 1)
返回值
无返回值
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调;设置成功,返回onP2PMessageMuteModeChanged
回调。 - 请求失败,返回
V2NIMFailuerCallback
回调,包含免打扰相关错误码。
设置成功,返回 onP2PMessageMuteModeChanged
回调。
getP2PMessageMuteMode
接口描述
获取单聊(点对点)消息免打扰模式。
该方法为同步。
参数说明
javaV2NIMP2PMessageMuteMode getP2PMessageMuteMode(String accountId);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
String | 是 | - | 聊天对象用户账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
objective-c- (V2NIMP2PMessageMuteMode)getP2PMessageMuteMode:(NSString *)accountId;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
NSString * | 是 | - | 聊天对象用户账号,不如果为空、不合法、不存在,则返回 191004 参数错误。 |
cppvirtual V2NIMP2PMessageMuteMode getP2PMessageMuteMode(nstd::string accountId) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
nstd::string | 是 | - | 聊天对象用户账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
typescriptgetP2PMessageMuteMode(accountId: string): V2NIMP2PMessageMuteMode
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
accountId |
string | 是 | - | 聊天对象用户账号,如果为空、不合法、不存在,则返回 191004 参数错误。 |
示例代码
javaV2NIMP2PMessageMuteMode muteMode = NIMClient.getService(V2NIMSettingService.class).getP2PMessageMuteMode(accountId);
objective-c[[[NIMSDK sharedSDK] v2SettingService] getP2PMessageMuteMode:@"accountId"];
cppauto muteMode = settingService.getP2PMessageMuteMode("accountId");
typescriptconst mode = nim.V2NIMSettingService.getP2PMessageMuteMode('accountId')
返回值
V2NIMP2PMessageMuteMode
单聊(点对点)消息免打扰模式
Promise<V2NIMP2PMessageMuteMode
>
相关回调
无
getP2PMessageMuteList
接口描述
获取开启单聊(点对点)消息免打扰的用户列表。
参数说明
javavoid getP2PMessageMuteList(V2NIMSuccessCallback<List<String>> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
success |
V2NIMSuccessCallback |
是 | - | 获取成功回调,返回 accountId 列表。 |
failure |
V2NIMFailureCallback |
是 | - | 获取失败回调,返回错误码。 |
objective-c- (void)getP2PMessageMuteList:(nullable V2NIMGetMuteListSuccess)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
success |
V2NIMGetMuteListSuccess |
是 | - | 获取成功回调,返回 accountId 列表,可自定义设置。 |
failure |
V2NIMFailureCallback |
是 | - | 获取失败回调,返回错误码。 |
cppvirtual void getP2PMessageMuteList(V2NIMSuccessCallback<nstd::vector<nstd::string>> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
success |
V2NIMSuccessCallback |
是 | - | 获取成功回调,返回 accountId 列表。 |
failure |
V2NIMFailureCallback |
是 | - | 获取失败回调,返回错误码。 |
typescriptgetP2PMessageMuteList(): Promise<Array<string>>
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
success |
V2NIMSuccessCallback |
是 | - | 获取成功回调,返回 accountId 列表。 |
failure |
V2NIMFailureCallback |
是 | - | 获取失败回调,返回错误码。 |
示例代码
javaNIMClient.getService(V2NIMSettingService.class).getP2PMessageMuteList(
new V2NIMSuccessCallback<List<String>>() {
@Override
public void onSuccess(List<String> strings) {
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
}
}
);
objective-c[[[NIMSDK sharedSDK] v2SettingService] getP2PMessageMuteList:^(NSArray<NSString *> * _Nonnull result) {
// 成功回调
} failure:^(V2NIMError * _Nonnull error) {
// 失败回调
}];
cppsettingService.getP2PMessageMuteList(
[](nstd::vector<nstd::string> muteList) {
// get p2p mute list succeeded, handle mute list
},
[](V2NIMError error) {
// get p2p mute list failed, handle error
});
typescriptconst mutedList = await nim.V2NIMSettingService.getP2PMessageMuteList()
返回值
无返回值
Promise<Array
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调,包含accountId
列表。 - 请求失败,返回
V2NIMFailuerCallback
回调,包含免打扰相关错误码。
无
setTeamMessageMuteMode
接口描述
设置群聊消息免打扰模式。
本地端或多端同步设置成功后,SDK 会返回群聊消息免打扰模式变更回调 onTeamMessageMuteModeChanged
,并触发会话变更。
参数说明
javavoid setTeamMessageMuteMode(String teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
String | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
muteMode |
V2NIMTeamMessageMuteMode |
是 | - | 群消息免打扰模式:免打扰开启或免打扰关闭 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
objective-c- (void)setTeamMessageMuteMode:(NSString *)teamId
teamType:(V2NIMTeamType)teamType
muteMode:(V2NIMTeamMessageMuteMode)muteMode
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
NSString * | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
muteMode |
V2NIMTeamMessageMuteMode |
是 | - | 群消息免打扰模式:免打扰开启或免打扰关闭 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
cppvirtual void setTeamMessageMuteMode(std::string teamId, V2NIMTeamType teamType, V2NIMTeamMessageMuteMode muteMode, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
std::string | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
muteMode |
V2NIMTeamMessageMuteMode |
是 | - | 群消息免打扰模式:免打扰开启或免打扰关闭 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
typescriptsetTeamMessageMuteMode(teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode): Promise<void>
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
string | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
muteMode |
V2NIMTeamMessageMuteMode |
是 | - | 群消息免打扰模式:免打扰开启或免打扰关闭 |
示例代码
javaNIMClient.getService(V2NIMSettingService.class).setTeamMessageMuteMode(teamId, teamType, muteMode,
new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
// success
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
// failed, handle error
}
});
objective-c[[[NIMSDK sharedSDK] v2SettingService] setTeamMessageMuteMode:@"teamId" teamType:V2NIM_TEAM_TYPE_INVALID muteMode:V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF success:^{
// 成功回调
} failure:^(V2NIMError * _Nonnull error) {
// 失败回调
}];
cppsettingService.setTeamMessageMuteMode(
"teamId",
V2NIM_TEAM_TYPE_NORMAL,
V2NIM_TEAM_MESSAGE_MUTE_MODE_ON,
[]() {
// set team mute mode succeeded
},
[](V2NIMError error) {
// set team mute mode failed, handle error
}
);
typescriptnim.V2NIMSettingService.setTeamMessageMuteMode('teamId', 1, 1)
返回值
无返回值
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调;设置成功,返回onTeamMessageMuteModeChanged
回调。 - 请求失败,返回
V2NIMFailuerCallback
回调,包含免打扰相关错误码。
设置成功,返回 onTeamMessageMuteModeChanged
回调。
getTeamMessageMuteMode
接口描述
获取群聊消息免打扰模式。
该方法为同步。
参数说明
javaV2NIMTeamMessageMuteMode getTeamMessageMuteMode(String teamId, V2NIMTeamType teamType);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
String | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
objective-c- (V2NIMTeamMessageMuteMode)getTeamMessageMuteMode:(NSString *)teamId
teamType:(V2NIMTeamType)teamType;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
NSString * | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
cppvirtual V2NIMTeamMessageMuteMode getTeamMessageMuteMode(nstd::string teamId, V2NIMTeamType teamType) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
nstd::string | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
typescriptgetTeamMessageMuteMode(teamId: string, teamType: V2NIMTeamType): V2NIMTeamMessageMuteMode
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
teamId |
string | 是 | - | 群组 ID。如果为空、不合法、不存在则返回 191004 参数错误。 |
teamType |
V2NIMTeamType |
是 | - | 群组类型,包括高级群和超大群。 |
示例代码
javaV2NIMTeamMessageMuteMode muteMode = NIMClient.getService(V2NIMSettingService.class).getTeamMessageMuteMode(teamId, teamType);
objective-c[[[NIMSDK sharedSDK] v2SettingService] getTeamMessageMuteMode:@"teamId" teamType:V2NIM_TEAM_TYPE_NORMAL];
cppauto muteMode = settingService.getTeamMessageMuteMode("teamId", V2NIM_TEAM_TYPE_NORMAL);
typescriptconst muteMode = nim.V2NIMSettingService.getTeamMessageMuteMode('teamId', 1)
返回值
V2NIMTeamMessageMuteMode
群聊消息免打扰模式
Promise<V2NIMTeamMessageMuteMode
>
相关回调
无
getConversationMuteStatus
接口描述
获取会话消息免打扰状态。
- 该方法为同步。
- 如果该方法返回值不满足界面显示需求,可以调用
getP2PMessageMuteMode
或getTeamMessageMuteMode
方法获取单聊或群聊消息的具体免打扰模式。
参数说明
javaboolean getConversationMuteStatus(String conversationId);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
conversationId |
String | 是 | - | 会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。V2NIMConversationType )|聊天对象账号(accountId)或群组 ID。 |
objective-c- (BOOL)getConversationMuteStatus:(NSString *)conversationId;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
conversationId |
NSString * | 是 | - | 会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。V2NIMConversationType )|聊天对象账号(accountId)或群组 ID。 |
cppvirtual bool getConversationMuteStatus(nstd::string conversationId) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
conversationId |
nstd::string | 是 | - | 会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。V2NIMConversationType )|聊天对象账号(accountId)或群组 ID。 |
typescriptgetConversationMuteStatus(conversationId: string): boolean
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
conversationId |
string | 是 | - | 会话 ID,通过调用 V2NIMConversationIdUtil 的对应函数创建。V2NIMConversationType )|聊天对象账号(accountId)或群组 ID。 |
示例代码
javaboolean isMute = NIMClient.getService(V2NIMSettingService.class).getConversationMuteStatus(conversationId);
objective-c[[NIMSDK sharedSDK] v2SettingService] getConversationMuteStatus:@"conversationId"];
cppauto mute = settingService.getConversationMuteStatus(conversationId);
typescriptnim.V2NIMSettingService.getConversationMuteStatus('sender|1|receiver')
返回值
true
:会话消息免打扰开启。false
:会话消息免打扰关闭。
相关回调
无
setPushMobileOnDesktopOnline
接口描述
设置当桌面端在线时,移动端是否需要推送。
参数说明
javavoid setPushMobileOnDesktopOnline(boolean need, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
need |
boolean | 否 | true | 桌面端在线时,移动端是否需要推送: |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
objective-c- (void)setPushMobileOnDesktopOnline:(BOOL)need
success:(nullable V2NIMSuccessCallback)success
failure:(nullable V2NIMFailureCallback)failure;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
need |
BOOL | 否 | true | 桌面端在线时,移动端是否需要推送: |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
cppvirtual void setPushMobileOnDesktopOnline(bool need, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
need |
bool | 否 | true | 桌面端在线时,移动端是否需要推送: |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
typescriptsetPushMobileOnDesktopOnline(need: boolean): Promise<void>
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
need |
boolean | 否 | true | 桌面端在线时,移动端是否需要推送: |
示例代码
javaNIMClient.getService(V2NIMSettingService.class).setPushMobileOnDesktopOnline(needPushMobileOnDesktopOnline,
new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
}
});
objective-c[[[NIMSDK sharedSDK] v2SettingService] setPushMobileOnDesktopOnline:YES success:^{
// 成功回调
} failure:^(V2NIMError * _Nonnull error) {
// 失败回调
}];
cppsettingService.setPushMobileOnDesktopOnline(
true,
[]() {
// set push mobile on desktop online succeeded
},
[](V2NIMError error) {
// set push mobile on desktop online failed, handle error
});
typescriptnim.V2NIMSettingService.setPushMobileOnDesktopOnline(true)
返回值
无返回值
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailuerCallback
回调,包含相关错误码。
无
setDndConfig
接口描述
设置推送全局免打扰。
参数说明
javavoid setDndConfig(V2NIMDndConfig config, V2NIMSuccessCallback<Void> success, V2NIMFailureCallback failure);
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
config |
V2NIMDndConfig |
是 | - | APNs 推送全局免打扰配置信息 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
objective-c- (void)setDndConfig:(V2NIMDndConfig *)config;
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
config |
V2NIMDndConfig |
是 | - | APNs 推送全局免打扰配置信息 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
示例代码
javaV2NIMDndConfig dndConfig = V2NIMDndConfig.V2NIMDndConfigBuilder.builder(fromH, fromM, toH, toM).build();
NIMClient.getService(V2NIMSettingService.class).setDndConfig(dndConfig,
new V2NIMSuccessCallback<Void>() {
@Override
public void onSuccess(Void unused) {
}
},
new V2NIMFailureCallback() {
@Override
public void onFailure(V2NIMError error) {
}
});
objective-c[[[NIMSDK sharedSDK] v2SettingService] setDndConfig:config];
返回值
无返回值
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailuerCallback
回调,包含相关错误码。
getDndConfig
接口描述
获取推送全局免打扰配置详情。
参数说明
javaV2NIMDndConfig getDndConfig();
无参数
objective-c- (nullable V2NIMDndConfig *)getDndConfig;
无参数
示例代码
javaV2NIMDndConfig dndConfig = NIMClient.getService(V2NIMSettingService.class).getDndConfig();
objective-c[NIMSDK.sharedSDK.v2SettingService getDndConfig];
返回值
V2NIMDndConfig
: 推送全局免打扰配置信息
setOfflinePushConfig(仅 Web)
接口描述
设置离线推送配置信息。
适用于 Web uni-app 编译为移动端的场景。实现步骤请参见 uni-app 离线推送。
参数说明
typescriptsetOfflinePushConfig(plugin: NIMEStrAnyObj, config: V2NIMOfflinePushConfig): void
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
plugin |
NIMEStrAnyObj | 是 | - | 云信提供的离线推送插件,请点击下载。 |
config |
V2NIMOfflinePushConfig |
是 | - | 离线推送配置信息 |
示例代码
typescriptconst nimPushPlugin = uni.requireNativePlugin('NIMUniPlugin-PluginModule')
try {
this.$store.v2NIM.V2NIMSettingService.setOfflinePushConfig(
nimPushPlugin,
{
miPush: {
appId: '111',
appKey: '111',
certificateName: 'MI_PUSH_CERT'
},
vivoPush: {
certificateName: 'VIVO_PUSH_CERT'
},
oppoPush: {
appId: '111',
appKey: '111',
secret: '111',
certificateName: 'OPPO_PUSH_CERT'
},
hwPush: {
appId: '111',
certificateName: 'HUAWEI_PUSH_CERT2'
},
fcmPush: {
certificateName: 'FCM_PUSH_CERT'
},
mzPush: {
appId: '111',
appKey: '111',
certificateName: 'MEIZU_PUSH_CERT'
},
honorPush: {
certificateName: 'HONOR_PUSH_CERT'
},
apns: {
certificateName: 'APPLE_PUSH_CERT'
}
}
)
} catch (err) {
console.error('setOfflinePushConfig error', err.code, err.detail)
}
返回值
void
相关回调
无
setAppBackground(仅 Web)
接口描述
设置应用后台状态。
适用于 Web uni-app 编译为移动端的场景。
参数说明
typescriptsetAppBackground(isBackground: boolean, badge?: number): Promise<void>
参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
---|---|---|---|---|
isBackground |
boolean | 否 | - | 是否运行在后台 |
badge |
number | 否 | 0 | 未读数。仅用于 iOS 端。 |
success |
V2NIMSuccessCallback |
是 | - | 设置成功回调 |
failure |
V2NIMFailureCallback |
是 | - | 设置失败回调,返回错误码。 |
示例代码
typescriptnim.V2NIMSettingService.setAppBackground(true)
返回值
Promise<void>
相关回调
- 请求成功,返回
V2NIMSuccessCallback
回调。 - 请求失败,返回
V2NIMFailuerCallback
回调,包含相关错误码。