getTimezone static method
Retrieves the timezone preference for the logged-in user.
This method makes an asynchronous call to the CometChat server to fetch the timezone preference for the logged-in user.
Upon successful retrieval, onSuccess is invoked with the timezone preference.
If an error occurs, onError is called with a CometChatException.
Returns a Future<String?>, which completes with the timezone preference if the operation is successful, or null if an error occurs.
Implementation
static Future<String?> getTimezone(
{Function(String response)? onSuccess,
Function(CometChatException e)? onError}) async {
try {
final sdk = SdkRegistry.getInstance();
final response = await sdk.notificationsApi.getTimezone();
final data = response['data'] as Map<String, dynamic>;
final timezone = data['timezone'] as String;
if (onSuccess != null) onSuccess(timezone);
return timezone;
} catch (e) {
_handleError(e, onError);
}
return null;
}