initialize method

Future<void> initialize({
  1. required String appName,
  2. NotificationData notificationData = const NotificationData(),
})

Initializes the notification service

appName - The name of the application notificationData - Configuration data for notifications

Implementation

Future<void> initialize({
  required String appName,
  NotificationData notificationData = const NotificationData(),
}) async {
  _appName = appName;
  _notificationData = notificationData;
  if (_isInitialized) {
    debugPrint('PlatformNotificationService is already initialized');
    return;
  }

  if (isWeb) {
    _isInitialized = true;
    return;
  }

  try {
    if (isMobile) {
      await _initializeMobilePlatform();
    } else {
      await _initializeDesktopPlatform();
    }

    _isInitialized = true;
    debugPrint('PlatformNotificationService initialized successfully');
  } catch (error) {
    debugPrint('Failed to initialize PlatformNotificationService: $error');
    rethrow;
  }
}