Skip to content

Implement Notification Center integration and service with configuration option #8

@abeckDev

Description

@abeckDev

Problem

Currently, when toggling a switch in BarKeeper (which triggers On/Off scripts), the process runs asynchronously and updates itself only once the action completes. However, there is no direct feedback to the user regarding the completion or failure of these actions unless they actively check the UI. This can reduce usability, especially if an action takes a while and the user switches to other tasks.

Proposed Solution: Notification Center Integration

Integrate BarKeeper with macOS's native Notification Center so that a push notification is sent to the user whenever a toggle action completes—regardless of success or error. This ensures the user is promptly notified of:

  • Successful actions (e.g., action started or stopped)
  • Failed actions (with error details)

Implementation Instructions

  1. Notification Service Abstraction

    • Implement a NotificationService as an injectable/service class responsible for all notifications.
    • Ensure the service is generic and can be reused by other (upcoming) components.
  2. Using macOS Notification Center

    • Use the UNUserNotificationCenter or execute an AppleScript via a shell command (for CLI/bundled apps) to trigger system-level notifications.
    • Define notification payloads: title, message, and error details (if any).
    • Optionally, bundle or link notification icons for success/error messages.
  3. Notification Triggers

    • When a toggle operation starts: optionally notify the user ("Action started...").
    • When a toggle operation completes:
      • Notify success: include which action completed (e.g., "Script started" or "Script stopped").
      • Notify error: include error details in the notification.
  4. Configuration Option

    • Add a configuration flag (e.g., enableNotifications: boolean) in the app's settings or user preferences.
    • Respect user's opt-in/out choice when sending notifications.
    • Persist the configuration across app restarts.
  5. Usage

    • Provide a straightforward API, e.g., notificationService.notify({ title, message, type }).
    • Replace current "action completed" UI update hooks to call the notification service after a toggle action finishes.
  6. Extensibility

    • Document how other modules can inject or use the notification service.
    • Allow future extensions (like supporting more notification channels, notification grouping, or user actions on notification).

Acceptance Criteria

  • macOS notifications are triggered on action completion or error.
  • There is a config option for enabling/disabling notifications.
  • Service can be easily reused by future components.
  • Appropriate info is shown for both success and error outcomes.
  • Usage of Notification Service is documented.

Feel free to refine the implementation approach based on the actual tech stack.

Metadata

Metadata

Assignees

Labels

FeatureNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions