import type { NIMEBaseServiceClass, NIMEStrAnyObj } from './types'; import { V2NIMTeamType } from './V2NIMTeamService'; /** * 设置模块. 包含会话免打扰设置, 推送设置. * * 注: 使用 dist/esm 产物时,需要动态引入 V2NIMSettingService 后使用 * * @example * ``` * import { NIM, V2NIMSettingService } from 'nim-web-sdk-ng/dist/esm/nim' * NIM.registerService(V2NIMSettingService, 'V2NIMSettingService') * ``` */ export declare class V2NIMSettingService extends NIMEBaseServiceClass { /** * 获取会话消息免打扰状态 * * 注: 若会话类型为群, 则群消息免打扰模式为 {@link V2NIMTeamMessageMuteMode.V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF | V2NIMTeamMessageMuteMode.V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF} 返回为false. 其他的返回 true. * * 注: 会话免打扰属性与 user 和 team 有关联. 建议使用 dist/esm 产物时,额外动态引入 {@link V2NIMUserService | V2NIMUserService} 以及 {@link V2NIMTeamService | V2NIMTeamService} * * @param conversationId 会话 id * @return mute 是否被免打扰 * @example * ```ts * const isMuted = nim.V2NIMSettingService.getConversationMuteStatus("conversationId") * ``` */ getConversationMuteStatus(conversationId: string): boolean; /** * 设置群消息免打扰模式 * * 注: 会话免打扰属性与 user 和 team 有关联. 建议使用 dist/esm 产物时,额外动态引入 {@link V2NIMUserService | V2NIMUserService} 以及 {@link V2NIMTeamService | V2NIMTeamService} * * @param teamId 群组ID * @param teamType 群组类型 * @param muteMode 群消息免打扰模式 * @example * ```ts * await nim.V2NIMSettingService.setTeamMessageMuteMode("teamId", 1, 1) * ``` */ setTeamMessageMuteMode(teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode): Promise; /** * 获取群消息免打扰模式 * * 注: 会话免打扰属性与 user 和 team 有关联. 建议使用 dist/esm 产物时,额外动态引入 {@link V2NIMUserService | V2NIMUserService} 以及 {@link V2NIMTeamService | V2NIMTeamService} * * @param teamId 群组ID * @param teamType 群组类型 * @return muteMode 群消息免打扰模式 * @example * ```ts * const muteMode = nim.V2NIMSettingService.getTeamMessageMuteMode("teamId", 1) * ``` */ getTeamMessageMuteMode(teamId: string, teamType: V2NIMTeamType): V2NIMTeamMessageMuteMode; /** * 获取我所在的群消息免打扰模式 * * @param teamType 群组类型 * @returns key 为群组 ID,value 为群消息免打扰模式 * @example * ```ts * const muteModes = await nim.V2NIMSettingService.getAllTeamMessageMuteMode(1) * ``` */ getAllTeamMessageMuteMode(teamType: V2NIMTeamType): Promise>; /** * 设置点对点消息免打扰模式 * * 注: 会话免打扰属性与 user 和 team 有关联. 建议使用 dist/esm 产物时,额外动态引入 {@link V2NIMUserService | V2NIMUserService} 以及 {@link V2NIMTeamService | V2NIMTeamService} * * @param accountId 目标账号 ID * @param muteMode 设置用户的免打扰模式 * @example * ```ts * await nim.V2NIMSettingService.setP2PMessageMuteMode("accountId1", 1) * ``` */ setP2PMessageMuteMode(accountId: string, muteMode: V2NIMP2PMessageMuteMode): Promise; /** * 获取用户消息免打扰模式 * * 注: 会话免打扰属性与 user 和 team 有关联. 建议使用 dist/esm 产物时,额外动态引入 {@link V2NIMUserService | V2NIMUserService} 以及 {@link V2NIMTeamService | V2NIMTeamService} * * @param accountId 目标账号 ID * @return muteMode p2p 类型消息免打扰模式 * @example * ```ts * const muteMode = nim.V2NIMSettingService.getP2PMessageMuteMode("accountId1") * ``` */ getP2PMessageMuteMode(accountId: string): V2NIMP2PMessageMuteMode; /** * 获取点对点消息免打扰列表。 * * 注: 会话免打扰属性与 user 有关联. 建议使用 dist/esm 产物时,额外动态引入 {@link V2NIMUserService | V2NIMUserService} * * 返回 V2NIMP2PMessageMuteMode 为 V2NIM_P2P_MESSAGE_MUTE_MODE_ON 的 accountId 列表。 * @example * ```ts * const muteList = await nim.V2NIMSettingService.getP2PMessageMuteList() * ``` */ getP2PMessageMuteList(): Promise>; /** * 设置应用前后台状态 * * web端运行在移动端时,需要用户调用此接口告知应用的前后台状态 * * 该函数仅在使用 uniapp 编译至 ios,或者 android 时有效,它告知服务器应用的前后台状态,服务器根据此状态调整推送策略 * * @param isBackground 是否在后台 * @param badge 应用图标上的未读数。当前仅 ios 使用 * @example * ```ts * await nim.V2NIMSettingService.setAppBackground(true, 0) * ``` */ setAppBackground(isBackground: boolean, badge?: number): Promise; /** * uniapp编译移动端应用时,调用该接口设置推送配置。该函数必须在 `login` 之前调用。 * * 离线推送相关配置请参考文档:https://doc.yunxin.163.com/messaging-enhanced/docs/TE1NjY4Nzk?platform=uniapp * * @param plugin 推送插件 * @param config 推送配置 * @example * ```ts * nim.V2NIMSettingService.setOfflinePushConfig(pushPlugin, { apns: { certificateName: "cert" } }) * ``` */ setOfflinePushConfig(plugin: NIMEStrAnyObj, config: V2NIMOfflinePushConfig): void; /** * 设置当桌面端在线时,移动端是否需要推送 * * @param need 桌面端在线时,移动端是否需要推送 * @example * ```ts * await nim.V2NIMSettingService.setPushMobileOnDesktopOnline(true) * ``` */ setPushMobileOnDesktopOnline(need: boolean): Promise; /** * 获取当桌面端在线时,移动端是否需要推送配置. v10.9.1 新增 * * @returns boolean 桌面端在线时,移动端是否需要推送. true 为需要 * @example * ```ts * const need = await nim.V2NIMSettingService.getPushMobileOnDesktopOnline() * ``` */ getPushMobileOnDesktopOnline(): Promise; } /** * 群消息免打扰模式 */ export declare const enum V2NIMTeamMessageMuteMode { /** * 群消息免打扰关闭 */ V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF = 0, /** * 群消息免打扰开启 */ V2NIM_TEAM_MESSAGE_MUTE_MODE_ON = 1, /** * 发送者为普通成员的群消息免打扰开启 */ V2NIM_TEAM_MESSAGE_MUTE_MODE_NORMAL_ON = 2 } /** * p2p 消息免打扰模式 */ export declare const enum V2NIMP2PMessageMuteMode { /** * 点对点消息免打扰关闭 */ V2NIM_P2P_MESSAGE_MUTE_MODE_OFF = 0, /** * 点对点消息免打扰开启 */ V2NIM_P2P_MESSAGE_MUTE_MODE_ON = 1 } /** * 设置模块的监听器 * * 注: 使用 dist/esm 产物时,需要动态引入 V2NIMSettingService 后使用 * * @example * ``` * import { NIM, V2NIMSettingService } from 'nim-web-sdk-ng/dist/esm/nim' * NIM.registerService(V2NIMSettingService, 'V2NIMSettingService') * ``` */ export interface V2NIMSettingListener { /** * 群消息免打扰模式变更 */ onTeamMessageMuteModeChanged: [teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode]; /** * 点对点消息免打扰模式变更 */ onP2PMessageMuteModeChanged: [accountId: string, muteMode: V2NIMP2PMessageMuteMode]; /** * ”当桌面端在线时,移动端是否需要推送“的状态回调 */ onPushMobileOnDesktopOnline: [need: boolean]; } /** * 离线推送配置参数 */ export interface V2NIMOfflinePushConfig { /** * 苹果推送配置,需要填写: certificateName */ apns?: V2NIMManufacturerPushConfig; /** * 苹果 pushkit 推送配置. 需要填写: certificateName */ pushkit?: V2NIMManufacturerPushConfig; /** * 华为推送配置,需要填写: appId, certificateName */ hwPush?: V2NIMManufacturerPushConfig; /** * 小米推送配置,需要填写: appId, appKey, certificateName */ miPush?: V2NIMManufacturerPushConfig; /** * vivo推送配置,需要填写: appId, appKey, certificateName */ vivoPush?: V2NIMManufacturerPushConfig; /** * oppo推送配置,需要填写: appId, appKey, certificateName, secret */ oppoPush?: V2NIMManufacturerPushConfig; /** * 荣耀推送配置,需要填写: appId, appKey, certificateName */ honorPush?: V2NIMManufacturerPushConfig; /** * fcm推送配置,需要填写: certificateName */ fcmPush?: V2NIMManufacturerPushConfig; /** * 魅族推送配置,需要填写: appId, appKey, certificateName */ mzPush?: V2NIMManufacturerPushConfig; /** * 鸿蒙推送配置. 只需要填写 certificateName. v10.9.75+ 支持 */ harmonyPush?: V2NIMManufacturerPushConfig; } /** * 推送 Token Provider 的返回结果。 */ export interface V2NIMPushTokenProviderResult { /** * 云信控制台中配置的推送证书名称。 */ certificateName: string; /** * 未加密的厂商推送 Token。 */ pushDeviceToken: string; } /** * 推送 Token Provider。 * * @param suggestPushType 服务端推荐的推送通道:5 为小米、6 为华为、7 为魅族、8 为 FCM、9 为 vivo、10 为 OPPO、11 为荣耀;空字符串表示 iOS、HarmonyOS 或服务端未返回 Android 推荐通道。 * @returns 当前端的推送证书名称和原始 Token。 */ export declare type V2NIMPushTokenProvider = (suggestPushType: string) => V2NIMPushTokenProviderResult | Promise; /** * 设置模块初始化配置。 */ export interface V2NIMSettingServiceConfig { /** * 登录或重连成功后获取推送 Token 的函数。 * * 配置后,SDK 跳过登录后的推送插件链路,并直接上报返回的证书名称和原始 Token。 * * Provider 可以不注册推送插件独立使用。但在 React Native Android 中,建议仍通过 `setOfflinePushConfig()` 注册插件:登录前的 `init()` 和 `getDeviceInfo()` 会将设备信息随登录请求上报,帮助服务端返回准确的 `suggestPushType`。Provider 仅替代登录后的 Token 获取与上报,不替代该设备信息流程。 * * 以下示例仅适用于 UniApp/RN 编译的 AOS(Android)应用, 开发者有自己的推送 token, 想共用给 IM 服务器的做法, 才需要代理推送插件的 token 获取函数。 * @example * ```ts * const nim = NIM.getInstance(options, { * V2NIMSettingServiceConfig: { * pushTokenProvider: async (suggestPushType) => { * if (suggestPushType === '5') { * return { certificateName: 'XIAOMI_CERT', pushDeviceToken: await xiaomiPush.getToken() } * } * if (suggestPushType === '6') { * return { certificateName: 'HUAWEI_CERT', pushDeviceToken: await huaweiPush.getToken() } * } * if (suggestPushType === '7') { * return { certificateName: 'MEIZU_CERT', pushDeviceToken: await meizuPush.getToken() } * } * if (suggestPushType === '8') { * return { certificateName: 'FCM_CERT', pushDeviceToken: await fcm.getToken() } * } * if (suggestPushType === '9') { * return { certificateName: 'VIVO_CERT', pushDeviceToken: await vivoPush.getToken() } * } * if (suggestPushType === '10') { * return { certificateName: 'OPPO_CERT', pushDeviceToken: await oppoPush.getToken() } * } * if (suggestPushType === '11') { * return { certificateName: 'HONOR_CERT', pushDeviceToken: await honorPush.getToken() } * } * return { certificateName: '', pushDeviceToken: '' } * } * } * }) * ``` */ pushTokenProvider?: V2NIMPushTokenProvider; } export interface V2NIMManufacturerPushConfig { /** * 推送应用 AppId */ appId?: string; /** * 推送应用 AppKey */ appKey?: string; /** * 推送应用证书名。证书在云信后台上传 */ certificateName: string; /** * 推送应用密钥 */ secret?: string; }