managePushNotifications method

Future<VIUserEvent> managePushNotifications(
  1. List<VIMessengerNotification>? notifications
)

Manage messenger push notification subscriptions for the current user.

notifications - List of VIMessengerNotification

Throws VIException, if operation failed, otherwise returns VIUserEvent instance. For all possible errors see VIMessagingError

Implementation

Future<VIUserEvent> managePushNotifications(
  List<VIMessengerNotification>? notifications,
) async {
  try {
    Map<String, dynamic>? data = await _methodChannel.invokeMapMethod(
        'Messaging.managePushNotifications',
        {'notifications': notifications?.map((e) => e.index).toList()});
    if (data == null) {
      _VILog._e(
          'VIMessenger: managePushNotifications: data was null, skipping');
      throw VIException(
        VIMessagingError.ERROR_INTERNAL,
        'VIMessenger:managePushNotifications: data was null',
      );
    }
    return VIUserEvent._fromMap(data);
  } on PlatformException catch (e) {
    throw VIException(e.code, e.message);
  }
}