fetchSilentModeForConversations method

Future<Map<String, ChatSilentModeResult>> fetchSilentModeForConversations(
  1. List<ChatConversation> conversations
)

~english Gets the offline push settings of specified conversations.

Param conversations The conversation list.

Return The key is the conversation ID and the value is offline push settings.

Throws A description of the exception. See ChatError. ~end

~chinese 批量获取指定会话的推送通知设置。

Param conversations 会话列表。

Return 键为会话 ID,值为离线推送设置。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 ChatError。 ~end

Implementation

Future<Map<String, ChatSilentModeResult>> fetchSilentModeForConversations(
  List<ChatConversation> conversations,
) async {
  Map<String, int> req = {};
  for (var item in conversations) {
    req[item.id] = conversationTypeToInt(item.type);
  }
  Map result = await PushChannel.invokeMethod(
    ChatMethodKeys.fetchSilentModeForConversations,
    req,
  );
  try {
    ChatError.hasErrorFromResult(result);
    Map<String, ChatSilentModeResult> ret = {};
    Map? tmpMap = result[ChatMethodKeys.fetchSilentModeForConversations];
    if (tmpMap != null) {
      for (var item in tmpMap.entries) {
        if (item.key is String && item.value is Map) {
          ret[item.key] = ChatSilentModeResult.fromJson(item.value);
        }
      }
    }
    return ret;
  } on ChatError catch (e) {
    throw e;
  }
}