updatePreferences static method
Future<NotificationPreferences?>
updatePreferences(
- NotificationPreferences notificationPreferences, {
- dynamic onSuccess(
- NotificationPreferences notificationPreferences
- dynamic onError()?,
Updates the notification preferences for the logged-in user.
This method asynchronously sends the updated NotificationPreferences to the CometChat server.
If the update is successful, onSuccess
is called with the updated NotificationPreferences object.
If an error occurs during the update, onError
is called with a CometChatException.
Returns a Future<NotificationPreferences?> that resolves to the updated preferences, or null if an error occurs.
Implementation
static Future<NotificationPreferences?> updatePreferences(
final NotificationPreferences notificationPreferences,
{Function(NotificationPreferences notificationPreferences)? onSuccess,
Function(CometChatException e)? onError}) async {
try {
final result = await channel.invokeMethod(
'updatePreferences', notificationPreferences.toMap());
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;
}