initialize method

Future<bool> initialize({
  1. required String channelId,
  2. required String channelName,
  3. String? channelDescription,
  4. int notificationId = 1,
  5. String? smallIconName,
})

Initializes the notification service

Implementation

Future<bool> initialize({
  required String channelId,
  required String channelName,
  String? channelDescription,
  int notificationId = 1,
  String? smallIconName,
}) async {
  if (_initialized) return true;

  // If platform implementation is not available, return false
  if (!_platformImplementationAvailable) {
    debugPrint('Notification service not available on this platform');
    return false;
  }

  try {
    final result = await _channel.invokeMethod<bool>('initialize', {
      'channelId': channelId,
      'channelName': channelName,
      'channelDescription': channelDescription ?? 'Audio playback controls',
      'notificationId': notificationId,
      'smallIconName': smallIconName ?? 'ic_notification',
    });

    _initialized = result ?? false;
    return _initialized;
  } catch (e) {
    if (e is MissingPluginException) {
      _platformImplementationAvailable = false;
      debugPrint('Notification service not available on this platform');
    } else {
      debugPrint('Error initializing notification service: $e');
    }
    return false;
  }
}