resetPreferences static method

Future<NotificationPreferences?> resetPreferences({
  1. dynamic onSuccess(
    1. NotificationPreferences notificationPreferences
    )?,
  2. dynamic onError(
    1. CometChatException e
    )?,
})

Resets notification preferences to their default values for the logged-in user.

This method makes an asynchronous call to the CometChat server to reset the NotificationPreferences. Upon successful reset, onSuccess is invoked with the reset NotificationPreferences object. If an error occurs, onError is called with a CometChatException.

Returns a Future<NotificationPreferences?> which completes with the reset preferences, or null if an error occurs.

Implementation

static Future<NotificationPreferences?> resetPreferences(
    {Function(NotificationPreferences notificationPreferences)? onSuccess,
      Function(CometChatException e)? onError}) async {
  try {
    final result = await channel.invokeMethod('resetPreferences');
    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;
}