fetchPushPreferences static method

  1. @Deprecated('This method has been deprecated. Please use [fetchPreferences] instead.')
Future<PushPreferences?> fetchPushPreferences({
  1. dynamic onSuccess(
    1. PushPreferences pushPreferences
    )?,
  2. dynamic onError(
    1. CometChatException e
    )?,
})

Retrieves the current push notification preferences for the logged-in user.

This method makes an asynchronous call to fetch the PushPreferences from CometChat servers. Upon successful retrieval, onSuccess is invoked with the PushPreferences object. In the case of an error, onError is called with a CometChatException.

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

Implementation

@Deprecated('This method has been deprecated. Please use [fetchPreferences] instead.')
static Future<PushPreferences?> fetchPushPreferences(
    {Function(PushPreferences pushPreferences)? onSuccess,
    Function(CometChatException e)? onError}) async {
  try {
    final result = await channel.invokeMethod('fetchPreferences');
    final pushPreferencesObj = PushPreferences.fromMap(result);
    if (onSuccess != null) onSuccess(pushPreferencesObj);
    return pushPreferencesObj;
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return null;
}