fetchSilentModeForConversations method

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

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.

Implementation

Future<Map<String, ChatSilentModeResult>> fetchSilentModeForConversations(
  List<ChatConversation> conversations,
) async {
  try {
    Map<String, int> req = {};
    for (var item in conversations) {
      req[item.id] = item.type.index;
    }
    Map result = await platform_interface.Client.instance.pushManager.callNativeMethod(
      ChatMethodKeys.fetchSilentModeForConversations,
      req,
    );
    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;
  } catch (e) {
    rethrow;
  }
}