initNotifications() — initialises the plugin and requests POST_NOTIFICATIONS permission on Android 13+
showNewMailNotification(accountEmail) — posts a high-priority notification (top-level function, usable from background isolates)
lib/core/sync/background_sync.dart (new)
@pragma('vm:entry-point') callbackDispatcher() — WorkManager entry point in its own Dart isolate
registerBackgroundSync() — registers a 15-minute periodic task (requires network)
Background logic: opens a fresh AppDatabase + AccountRepositoryImpl, calls IMAP STATUS INBOX (UIDNEXT) per IMAP account, compares against the last stored value in syncStates table (resource type background_check), posts notification if UIDNEXT increased
android/app/build.gradle.kts — bumps minSdk to 23 (WorkManager requirement)
Implements background mail sync and local notifications so users are informed of new messages even when the app is backgrounded.
## Changes
**New packages**
- `flutter_local_notifications ^18.0.1` — Android notification channel and permission handling
- `workmanager ^0.5.2` — Android WorkManager periodic background task
**`lib/core/services/notification_service.dart`** (new)
- `initNotifications()` — initialises the plugin and requests `POST_NOTIFICATIONS` permission on Android 13+
- `showNewMailNotification(accountEmail)` — posts a high-priority notification (top-level function, usable from background isolates)
**`lib/core/sync/background_sync.dart`** (new)
- `@pragma('vm:entry-point') callbackDispatcher()` — WorkManager entry point in its own Dart isolate
- `registerBackgroundSync()` — registers a 15-minute periodic task (requires network)
- Background logic: opens a fresh `AppDatabase` + `AccountRepositoryImpl`, calls IMAP `STATUS INBOX (UIDNEXT)` per IMAP account, compares against the last stored value in `syncStates` table (resource type `background_check`), posts notification if UIDNEXT increased
**`lib/core/sync/account_sync_manager.dart`**
- `typedef OnNewMailCallback = Future<void> Function(String accountEmail)`
- Optional `onNewMail` parameter on `AccountSyncManager` and `_AccountSync`
- In `_AccountSync._idle()`: tracks `ImapMessagesExistEvent` and fires the callback when `newMessagesExists > oldMessagesExists`
**`lib/di.dart`** — wires `showNewMailNotification` as the `onNewMail` callback
**`lib/main.dart`** — calls `initNotifications()` and (Android only) `registerBackgroundSync()` at startup
**`android/app/src/main/AndroidManifest.xml`** — adds `POST_NOTIFICATIONS`, `RECEIVE_BOOT_COMPLETED`, `WAKE_LOCK` permissions
**`android/app/build.gradle.kts`** — bumps `minSdk` to 23 (WorkManager requirement)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Implements background mail sync and local notifications so users are informed of new messages even when the app is backgrounded.
Changes
New packages
flutter_local_notifications ^18.0.1— Android notification channel and permission handlingworkmanager ^0.5.2— Android WorkManager periodic background tasklib/core/services/notification_service.dart(new)initNotifications()— initialises the plugin and requestsPOST_NOTIFICATIONSpermission on Android 13+showNewMailNotification(accountEmail)— posts a high-priority notification (top-level function, usable from background isolates)lib/core/sync/background_sync.dart(new)@pragma('vm:entry-point') callbackDispatcher()— WorkManager entry point in its own Dart isolateregisterBackgroundSync()— registers a 15-minute periodic task (requires network)AppDatabase+AccountRepositoryImpl, calls IMAPSTATUS INBOX (UIDNEXT)per IMAP account, compares against the last stored value insyncStatestable (resource typebackground_check), posts notification if UIDNEXT increasedlib/core/sync/account_sync_manager.darttypedef OnNewMailCallback = Future<void> Function(String accountEmail)onNewMailparameter onAccountSyncManagerand_AccountSync_AccountSync._idle(): tracksImapMessagesExistEventand fires the callback whennewMessagesExists > oldMessagesExistslib/di.dart— wiresshowNewMailNotificationas theonNewMailcallbacklib/main.dart— callsinitNotifications()and (Android only)registerBackgroundSync()at startupandroid/app/src/main/AndroidManifest.xml— addsPOST_NOTIFICATIONS,RECEIVE_BOOT_COMPLETED,WAKE_LOCKpermissionsandroid/app/build.gradle.kts— bumpsminSdkto 23 (WorkManager requirement)