unblockUser static method
Future<Map<String, dynamic> ?>
unblockUser(
- List<
String> ? uids, { - required dynamic onSuccess()?,
- required dynamic onError(
- CometChatException excep
Un-block a user from sending logged-in user any messages.
uids list of UID of users to be un-blocked
receive a map which contains UIDs as the keys and "success" or "fail" as the value based on if the un-block operation for the UID was successful or not
method could throw PlatformException with error codes specifying the cause
Migration Note: Migrated from platform channels to native Dart implementation. Behavior and signature remain identical for backward compatibility.
Android Reference: UsersRequest.unblockUsers(List<String> uids)
Implementation
static Future<Map<String, dynamic>?> unblockUser(List<String>? uids,
{required Function(Map<String, dynamic> map)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
// Validate UIDs
if (uids == null || uids.isEmpty) {
throw CometChatException(
ErrorCode.errorInvalidParameter,
'UIDs list cannot be empty',
'UIDs list cannot be empty',
);
}
// Get SDK instance
final sdk = SdkRegistry.getInstance();
// Call native Dart user repository
await sdk.users.unblockUsers(uids);
// Create success map (matching Android SDK behavior)
final res = <String, dynamic>{};
for (final uid in uids) {
res[uid] = 'success';
}
// Call success callback
if (onSuccess != null) onSuccess(res);
return res;
} on SdkException catch (sdkEx) {
// Convert SdkException to CometChatException
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
_errorCallbackHandler(cometChatEx, null, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}