fetchPushPreferences static method
- {dynamic onSuccess(
- PushPreferences pushPreferences
- dynamic onError( )?}
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
static Future<PushPreferences?> fetchPushPreferences({Function(PushPreferences pushPreferences)? onSuccess, Function(CometChatException e)? onError}) async {
try {
final result = await channel.invokeMethod('fetchPushPreferences');
final pushPreferencesObj = PushPreferences.fromMap(result);
if(onSuccess != null) onSuccess(pushPreferencesObj);
return pushPreferencesObj;
} on PlatformException catch (platformException) {
if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
} catch (e) {
if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
}
return null;
}