fetchPreferences static method
Future<NotificationPreferences?>
fetchPreferences({
- dynamic onSuccess(
- NotificationPreferences notificationPreferences
- dynamic onError()?,
Retrieves the current notification preferences for the logged-in user.
This method makes an asynchronous call to fetch the NotificationPreferences from CometChat servers.
Upon successful retrieval, onSuccess
is invoked with the NotificationPreferences object.
In the case of an error, onError
is called with a CometChatException.
Returns a Future<NotificationPreferences?> which completes with the fetched preferences, or null if an error occurs.
Implementation
static Future<NotificationPreferences?> fetchPreferences(
{Function(NotificationPreferences notificationPreferences)? onSuccess,
Function(CometChatException e)? onError}) async {
try {
final result = await channel.invokeMethod('fetchPreferences');
final notificationPreferencesObj = NotificationPreferences.fromMap(result);
if (onSuccess != null) onSuccess(notificationPreferencesObj);
return notificationPreferencesObj;
} on PlatformException catch (p) {
_errorCallbackHandler(null, p, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}