updateTimezone static method
Future<String?>
updateTimezone(})
Updates the timezone preference for the logged-in user.
This method makes an asynchronous call to the CometChat server to update the timezone preference for the logged-in user.
Upon successful update, onSuccess is invoked with a success response.
If an error occurs, onError is called with a CometChatException.
Returns a Future<String>, which completes with a success response if the operation is successful, or null if an error occurs.
Implementation
static Future<String?> updateTimezone(String timezone,
{Function(String response)? onSuccess,
Function(CometChatException e)? onError}) async {
if (timezone.isEmpty) {
_handleError(
CometChatException(
ErrorCode.errorInvalidTimezone,
ErrorMessage.errorInvalidEmptyTimezone,
ErrorMessage.errorInvalidEmptyTimezone),
onError);
return null;
}
try {
final sdk = SdkRegistry.getInstance();
await sdk.notificationsApi.updateTimezone(timezone);
const result = 'Timezone updated successfully';
if (onSuccess != null) onSuccess(result);
return result;
} catch (e) {
_handleError(e, onError);
}
return null;
}