Notifications and Announcements
Relevant source files
The following files were used as context for generating this wiki page:
The VoiceInk application employs two distinct systems for communicating with the user: general-purpose notifications and remote announcements. General-purpose notifications, handled by an inferred NotificationManager, provide immediate, transient feedback for application events like model import success or failure. This system is used for status updates that are directly related to user actions.
The remote announcement system is a more complex feature designed to deliver news and updates to all users. It is driven by the AnnouncementsService, which periodically fetches data from a remote JSON file. This allows for asynchronous delivery of information, such as new features or version releases. Users have control over this feature and can disable it in the application's settings.
System Architecture
The notification and announcement systems are composed of several key singletons that work together. NotificationManager handles local, event-driven pop-ups, while AnnouncementsService and AnnouncementManager work in tandem to fetch, validate, and display remote messages.
The following diagram illustrates the high-level architecture and data flow between these components.
General-Purpose Notifications
This system is designed to provide immediate, context-specific feedback to the user. It is accessed via a NotificationManager singleton. While the implementation file for NotificationManager is not directly provided, its interface can be inferred from its usage throughout the codebase.
Interface
The manager is consistently called via NotificationManager.shared, indicating a singleton pattern. The primary method used is showNotification.
This diagram shows the inferred interface of the NotificationManager based on its usage in other files.
Sources: VoiceInk/Whisper/WhisperState+LocalModelManager.swift:390-407, VoiceInk/Whisper/WhisperState.swift:101-106
Usage
Notifications are triggered in response to specific events, such as the success or failure of a model import.
Example: Model Import Feedback
When a user imports a local model, NotificationManager is used to inform them of the outcome.
// VoiceInk/Whisper/WhisperState+LocalModelManager.swift:390-407
// On success
await NotificationManager.shared.showNotification(
title: "Imported \(destinationURL.lastPathComponent)",
type: .success,
duration: 3.0
)
// On failure
await NotificationManager.shared.showNotification(
title: "Failed to import model: \(error.localizedDescription)",
type: .error,
duration: 5.0
)
Sources: VoiceInk/Whisper/WhisperState+LocalModelManager.swift:390-407
Remote Announcements
This system delivers news and updates fetched from a remote server. It is designed to be robust, with features for scheduling, dismissal persistence, and user opt-out.
AnnouncementsService
The AnnouncementsService is the engine of this system. It's a singleton that runs in the background to fetch and process announcements.
- Activation: The service is started and stopped based on the
enableAnnouncementsuser setting, which is managed inVoiceInkAppand configured inSettingsView. - Fetching Schedule: It uses a
Timerto fetch announcements every 4 hours. An initial fetch is also scheduled 5 seconds after the app starts.
Sources: VoiceInk/VoiceInk.swift:17, 110-112, VoiceInk/Services/AnnouncementsService.swift:16-28, VoiceInk/Views/Settings/SettingsView.swift:273-281
The core logic resides in the fetchAndMaybeShow method, which performs the following steps:
This flowchart details the process AnnouncementsService follows to fetch and display a valid announcement.
Sources: VoiceInk/Services/AnnouncementsService.swift:34-52
Data Structure (announcements.json)
The service fetches a JSON file from https://beingpax.github.io/VoiceInk/announcements.json. This file contains an array of announcement objects.
The RemoteAnnouncement struct maps to the objects in this JSON file.
| Field | Type | Description |
|---|---|---|
id | String | A unique identifier for the announcement. Used for tracking dismissals. |
title | String | The main title of the announcement. |
description | String? | The body text of the announcement. |
url | String? | An optional URL for a "Learn More" button. |
startAt | String? | An optional ISO 8601 date string. The announcement will not show before this date. |
endAt | String? | An optional ISO 8601 date string. The announcement will not show after this date. |
Sources: announcements.json, VoiceInk/Services/AnnouncementsService.swift:76-88
An example of the JSON structure is below:
[
{
"id": "2025-08-welcome",
"title": "Thanks for using VoiceInk!",
"description": "We’re rolling out minor fixes and performance improvements this week. No action needed.",
"url": "https://tryvoiceink.com/docs/announcements",
"startAt": "2025-07-01T00:00:00Z",
"endAt": "2025-08-01T00:00:00Z"
},
{
"id": "2025-09-ios-launch",
"title": "VoiceInk iOS App is Now Live!",
"description": "Our iOS app is now available on the App Store! Download it today and experience seamless voice-to-text transcription on your iPhone and iPad.",
"url": "https://www.youtube.com/watch?v=T6NwmXadG3M",
"startAt": "2025-09-25T00:00:00Z",
"endAt": "2025-12-31T23:59:59Z"
}
]
Sources: announcements.json:1-19
UI and Dismissal
The AnnouncementManager is responsible for presenting the announcement UI. Its interface is inferred from its usage in AnnouncementsService. When an announcement is shown, it's provided with an onDismiss callback. When the user closes the banner, this callback triggers AnnouncementsService.markDismissed(id), persisting the dismissal.
The following sequence diagram shows the end-to-end flow from service startup to a user dismissing an announcement.
Configuration and Persistence
User preferences for the announcement system are persisted in UserDefaults.
| Key | Type | Description | File Reference |
|---|---|---|---|
enableAnnouncements | Bool | Controls whether the AnnouncementsService is active. Toggled in SettingsView. | VoiceInk.swift:17 |
dismissedAnnouncementIds | [String] | An array of IDs for announcements the user has dismissed. | AnnouncementsService.swift:20 |
To prevent the dismissedAnnouncementIds array from growing indefinitely, the service only keeps a record of the most recent maxDismissedToKeep (currently 2) IDs.
Sources: VoiceInk/Services/AnnouncementsService.swift:21, 71-73
Summary
VoiceInk utilizes a dual-pronged approach to user communication. The NotificationManager provides immediate, local feedback for user actions, enhancing the interactive experience. In parallel, the AnnouncementsService offers a robust, configurable system for delivering remote updates, complete with scheduling, dismissal persistence, and user opt-out to ensure it remains a helpful and non-intrusive feature.