# Implementation Plan

## Validation Checklist

- [x] All specification file paths are correct and exist
- [x] Context priming section is complete
- [x] All implementation phases are defined
- [x] Each phase follows TDD: Prime → Test → Implement → Validate
- [x] Dependencies between phases are clear (no circular dependencies)
- [x] Parallel work is properly tagged with `[parallel: true]`
- [x] Activity hints provided for specialist selection `[activity: type]`
- [x] Every phase references relevant SDD sections
- [x] Every test references PRD acceptance criteria
- [x] Integration & E2E tests defined in final phase
- [x] Project commands match actual project setup
- [x] A developer could follow this plan independently

---

## Specification Compliance Guidelines

### How to Ensure Specification Adherence

1. **Before Each Phase**: Complete the Pre-Implementation Specification Gate
2. **During Implementation**: Reference specific SDD sections in each task
3. **After Each Task**: Run Specification Compliance checks
4. **Phase Completion**: Verify all specification requirements are met

### Deviation Protocol

If implementation cannot follow specification exactly:
1. Document the deviation and reason
2. Get approval before proceeding
3. Update SDD if the deviation is an improvement
4. Never deviate without documentation

## Metadata Reference

- `[parallel: true]` - Tasks that can run concurrently
- `[component: component-name]` - For multi-component features
- `[ref: document/section; lines: X-Y]` - Links to specifications
- `[activity: type]` - Activity hint for specialist agent selection

---

## Context Priming

*GATE: You MUST fully read all files mentioned in this section before starting any implementation.*

**Specification**:

- `docs/specs/005-firebase-push-notifications/product-requirements.md` - PRD with 6 Must-Have features, user journeys, success metrics
- `docs/specs/005-firebase-push-notifications/solution-design.md` - SDD with architecture, interfaces, implementation examples

**Key Design Decisions** (from SDD):

- **ADR-1**: Use official `firebase_messaging` package (FlutterFire)
- **ADR-2**: FCM for push notifications only; keep Ably for in-app real-time
- **ADR-3**: Foreground notifications shown as in-app banner (not system notification)
- **ADR-4**: Store FCM token in SharedPreferences (not secure storage - not sensitive)

**Implementation Context**:

- Commands to run:
  ```bash
  # Firebase CLI Setup
  dart pub global activate flutterfire_cli
  flutterfire configure --project=<firebase-project-id>

  # Install Dependencies
  flutter pub get

  # Code Generation (after adding models)
  dart run build_runner build --delete-conflicting-outputs

  # Testing
  flutter test
  flutter analyze
  ```

- Patterns to follow:
  - Riverpod 3.x Notifier pattern `[ref: lib/presentation/providers/auth_provider.dart]`
  - Service Provider pattern `[ref: lib/core/services/storage_service.dart]`
  - Freezed 3.x `abstract class` models `[ref: lib/data/models/user_model.dart]`
  - Clean Architecture layers `[ref: CLAUDE.md]`

- Interfaces to implement:
  - `POST /api/mobile/me/devices` - Register FCM token `[ref: SDD; lines: 416-432]`
  - `DELETE /api/mobile/me/devices/{device_id}` - Remove token on logout `[ref: SDD; lines: 434-444]`
  - `PUT /api/mobile/me/notification-preferences` - Sync preferences `[ref: SDD; lines: 446-465]`
  - `GET /api/mobile/me/notification-preferences` - Get preferences `[ref: SDD; lines: 467-476]`

---

## Implementation Phases

### Phase 1: Firebase Project Setup & Configuration

> **Delivers**: Firebase SDK integrated, platform configurations complete, app initializes Firebase

- [x] T1 Phase 1: Firebase Project Setup & Configuration

    - [x] T1.1 Prime Context
        - [x] T1.1.1 Read FlutterFire documentation `[ref: https://firebase.flutter.dev/docs/overview]`
        - [x] T1.1.2 Review existing `main.dart` initialization pattern `[ref: lib/main.dart; lines: 1-30]`
        - [x] T1.1.3 Review iOS/Android manifest requirements `[ref: SDD; lines: 713-738]`

    - [x] T1.2 Configure Firebase Console (Manual Step)
        - [x] T1.2.1 Verify Firebase project exists with Cloud Messaging enabled `[activity: manual-setup]`
        - [x] T1.2.2 Verify iOS app registered with correct bundle ID `[activity: manual-setup]`
        - [x] T1.2.3 Verify Android app registered with correct package name `[activity: manual-setup]`
        - [x] T1.2.4 Verify APNs key uploaded for iOS push delivery `[activity: manual-setup]`

    - [x] T1.3 Implement Firebase Dependencies `[activity: flutter-dev]`
        - [x] T1.3.1 Add `firebase_core` and `firebase_messaging` to `pubspec.yaml`
        - [x] T1.3.2 Run `flutter pub get`
        - [x] T1.3.3 Run `flutterfire configure` to generate `firebase_options.dart`
        - [x] T1.3.4 Verify `GoogleService-Info.plist` placed in `ios/Runner/` *(handled via firebase_options.dart)*
        - [x] T1.3.5 Verify `google-services.json` placed in `android/app/`

    - [x] T1.4 Implement Firebase Initialization `[activity: flutter-dev]`
        - [x] T1.4.1 Modify `main.dart` to initialize Firebase before `runApp()` `[ref: SDD; lines: 757-762]`
        - [x] T1.4.2 Handle Firebase initialization errors gracefully
        - [x] T1.4.3 Ensure initialization completes in <300ms `[ref: SDD; lines: 844]`

    - [x] T1.5 Validate Phase 1
        - [x] T1.5.1 App launches successfully with Firebase initialized `[activity: manual-test]`
        - [x] T1.5.2 No Firebase initialization errors in console `[activity: manual-test]`
        - [x] T1.5.3 Run `flutter analyze` - no new warnings `[activity: lint-code]`

---

### Phase 2: Core Push Notification Service & Models

> **Delivers**: PushNotificationService, data models, notification constants, permission handling

- [x] T2 Phase 2: Core Push Notification Service & Models

    - [x] T2.1 Prime Context
        - [x] T2.1.1 Read notification payload specifications `[ref: SDD; lines: 373-412]`
        - [x] T2.1.2 Read service structure example `[ref: SDD; lines: 480-549]`
        - [x] T2.1.3 Review existing service patterns `[ref: lib/core/services/storage_service.dart]`

    - [x] T2.2 Data Models `[parallel: true]` `[component: models]`

        - [x] T2.2.1 Write Tests for NotificationPayloadModel
            - [x] Test JSON parsing for schedule notification `[ref: PRD Feature 2]`
            - [x] Test JSON parsing for clock notification `[ref: PRD Feature 3]`
            - [x] Test JSON parsing for open_shift notification `[ref: PRD Feature 4]`
            - [x] Test JSON parsing for chat notification `[ref: PRD Feature 5]`
            - [x] Test handling of malformed payload `[activity: unit-test]`

        - [x] T2.2.2 Implement NotificationPayloadModel `[activity: flutter-dev]`
            - [x] Create `lib/data/models/notification_payload_model.dart` with Freezed
            - [x] Fields: type, action, title, body, targetRoute, data
            - [x] Run build_runner to generate `.freezed.dart` and `.g.dart`

        - [x] T2.2.3 Write Tests for NotificationPreferencesModel
            - [x] Test default values (all enabled, 15min reminder) `[ref: PRD Feature 6]`
            - [x] Test JSON serialization/deserialization
            - [x] Test preference toggle states `[activity: unit-test]`

        - [x] T2.2.4 Implement NotificationPreferencesModel `[activity: flutter-dev]`
            - [x] Create `lib/data/models/notification_preferences_model.dart` with Freezed
            - [x] Fields per SDD: scheduleEnabled, clockRemindersEnabled, openShiftsEnabled, chatEnabled, shiftReminderMinutes, doNotDisturb, quietHoursStart, quietHoursEnd
            - [x] Run build_runner

    - [x] T2.3 Domain Entity `[parallel: true]` `[component: domain]`

        - [x] T2.3.1 Create NotificationPreferences entity `[activity: flutter-dev]`
            - [x] Create `lib/domain/entities/notification_preferences.dart` with Equatable
            - [x] Mirror model fields for domain layer

    - [x] T2.4 Constants `[parallel: true]` `[component: constants]`

        - [x] T2.4.1 Create notification constants `[activity: flutter-dev]`
            - [x] Create `lib/core/constants/notification_constants.dart`
            - [x] Define notification types: schedule, clock, open_shift, chat
            - [x] Define notification actions: view_schedule, clock_in, clock_out, claim_shift, reply, mark_read

        - [x] T2.4.2 Update app_constants.dart `[activity: flutter-dev]`
            - [x] Add storage keys: `fcmTokenKey`, `notificationPreferencesKey`, `notificationPermissionDeniedAt`

    - [x] T2.5 Push Notification Service

        - [x] T2.5.1 Write Tests for PushNotificationService
            - [x] Test permission request flow `[ref: PRD Feature 1 AC 1]`
            - [x] Test token retrieval `[ref: PRD Feature 1 AC 2]`
            - [x] Test token refresh callback `[ref: PRD Feature 1 AC 3]`
            - [x] Test foreground message handler invoked `[ref: PRD Feature 1 AC 5]`
            - [x] Test background message handler setup `[activity: unit-test]`

        - [x] T2.5.2 Implement PushNotificationService `[activity: flutter-dev]`
            - [x] Create `lib/core/services/push_notification_service.dart`
            - [x] Create provider: `pushNotificationServiceProvider`
            - [x] Implement `initialize()` with permission request
            - [x] Implement `getToken()` for FCM token retrieval
            - [x] Implement `onTokenRefresh()` listener
            - [x] Implement `_setupMessageHandlers()` for foreground/background
            - [x] Implement `_handleForegroundMessage()` - delegate to provider
            - [x] Implement `_handleNotificationTap()` - parse payload, prepare navigation
            - [x] Implement `isPermissionGranted()` helper `[ref: SDD; lines: 480-549]`

        - [x] T2.5.3 Implement Background Message Handler `[activity: flutter-dev]`
            - [x] Create top-level function `@pragma('vm:entry-point')` for background messages
            - [x] Handle terminated state notification tap via `getInitialMessage()`

    - [x] T2.6 Storage Service Extensions

        - [x] T2.6.1 Write Tests for notification preference storage `[activity: unit-test]`
            - [x] Test save/load notification preferences
            - [x] Test FCM token storage

        - [x] T2.6.2 Extend StorageService `[activity: flutter-dev]`
            - [x] Add `setFcmToken()` / `getFcmToken()` methods
            - [x] Add `setNotificationPreferences()` / `getNotificationPreferences()` methods
            - [x] Add `setNotificationPermissionDeniedAt()` / `getNotificationPermissionDeniedAt()` for 7-day re-prompt logic

    - [x] T2.7 Validate Phase 2
        - [x] T2.7.1 All unit tests pass `[activity: run-tests]`
        - [x] T2.7.2 Run `flutter analyze` - no warnings `[activity: lint-code]`
        - [x] T2.7.3 Run `dart format lib/` `[activity: format-code]`
        - [x] T2.7.4 Models generate correctly with build_runner `[activity: build]`

---

### Phase 3: Notification Provider & State Management

> **Delivers**: NotificationProvider with Riverpod Notifier pattern, state management for notification UI

- [x] T3 Phase 3: Notification Provider & State Management

    - [x] T3.1 Prime Context
        - [x] T3.1.1 Read state management pattern from SDD `[ref: SDD; lines: 774-807]`
        - [x] T3.1.2 Review existing auth_provider pattern `[ref: lib/presentation/providers/auth_provider.dart]`

    - [x] T3.2 Define Notification State

        - [x] T3.2.1 Write Tests for NotificationState transitions
            - [x] Test initial → loading → ready flow
            - [x] Test initial → loading → error flow
            - [x] Test preference update preserves state
            - [x] Test permission status tracking `[activity: unit-test]`

        - [x] T3.2.2 Create NotificationState sealed class `[activity: flutter-dev]`
            - [x] Create `lib/domain/entities/notification_state.dart`
            - [x] States: NotificationInitial, NotificationLoading, NotificationReady, NotificationError
            - [x] NotificationReady holds: preferences, permissionGranted, pendingNotification (for in-app banner)

    - [x] T3.3 Implement NotificationProvider

        - [x] T3.3.1 Write Tests for NotificationNotifier
            - [x] Test initialize() loads preferences and checks permission
            - [x] Test updatePreferences() saves locally
            - [x] Test showInAppNotification() sets pending notification
            - [x] Test dismissInAppNotification() clears pending
            - [x] Test requestPermission() flow `[activity: unit-test]`

        - [x] T3.3.2 Implement NotificationNotifier `[activity: flutter-dev]`
            - [x] Create `lib/presentation/providers/notification_provider.dart`
            - [x] Extend `Notifier<NotificationState>`
            - [x] Implement `initialize()` - load prefs, check permission, setup listeners
            - [x] Implement `updatePreferences()` - save local, mark for backend sync
            - [x] Implement `syncPreferencesToBackend()` - call API *(deferred to Phase 4)*
            - [x] Implement `showInAppNotification()` - set state for banner
            - [x] Implement `dismissInAppNotification()` - clear banner state
            - [x] Implement `requestPermission()` - trigger FCM permission prompt
            - [x] Wire up to PushNotificationService for foreground message callback

    - [x] T3.4 Validate Phase 3
        - [x] T3.4.1 All unit tests pass `[activity: run-tests]`
        - [x] T3.4.2 Provider follows Notifier pattern correctly `[activity: review-code]`
        - [x] T3.4.3 Run `flutter analyze` `[activity: lint-code]`

---

### Phase 4: Auth Integration & Token Registration

> **Delivers**: FCM token registered on login, removed on logout, token refresh handling

- [x] T4 Phase 4: Auth Integration & Token Registration

    - [x] T4.1 Prime Context
        - [x] T4.1.1 Read auth integration example `[ref: SDD; lines: 551-599]`
        - [x] T4.1.2 Review current auth_provider implementation `[ref: lib/presentation/providers/auth_provider.dart]`
        - [x] T4.1.3 Read API endpoint specifications `[ref: SDD; lines: 414-476]`

    - [x] T4.2 API Repository Layer

        - [x] T4.2.1 Write Tests for device registration API calls
            - [x] Test registerDevice() success `[ref: PRD Feature 1 AC 2]`
            - [x] Test registerDevice() network error handling
            - [x] Test removeDevice() success `[ref: PRD Feature 1 AC 6]`
            - [x] Test removeDevice() 404 handling (already removed) `[activity: unit-test]`

        - [x] T4.2.2 Extend AuthRepository interface `[activity: flutter-dev]`
            - [x] Add `registerDevice({fcmToken, deviceId, platform, appVersion})` method
            - [x] Add `removeDevice(deviceId)` method

        - [x] T4.2.3 Implement in AuthRepositoryImpl `[activity: flutter-dev]`
            - [x] POST `/api/mobile/me/devices` with token payload
            - [x] DELETE `/api/mobile/me/devices/{device_id}`
            - [x] Handle error responses per SDD specification

    - [x] T4.3 Auth Provider Integration

        - [x] T4.3.1 Write Tests for login FCM integration
            - [x] Test login success triggers token registration `[ref: PRD Feature 1 AC 2]`
            - [x] Test login succeeds even if token registration fails (non-blocking)
            - [x] Test token refresh triggers re-registration `[ref: PRD Feature 1 AC 3]`

        - [x] T4.3.2 Write Tests for logout FCM integration
            - [x] Test logout calls removeDevice before clearing local data `[ref: PRD Feature 1 AC 6]`
            - [x] Test logout succeeds even if removeDevice fails

        - [x] T4.3.3 Modify AuthNotifier.login() `[activity: flutter-dev]`
            - [x] After successful auth, get FCM token via pushNotificationService
            - [x] Call authRepo.registerDevice() with token, deviceId, platform
            - [x] Setup token refresh listener `[ref: SDD; lines: 551-583]`
            - [x] Ensure non-blocking (don't fail login if push registration fails)

        - [x] T4.3.4 Modify AuthNotifier.logout() `[activity: flutter-dev]`
            - [x] Before clearing local data, call authRepo.removeDevice()
            - [x] Ignore errors - proceed with logout `[ref: SDD; lines: 585-599]`
            - [x] Clear FCM token from local storage

    - [x] T4.4 Initialize Notifications on App Start

        - [x] T4.4.1 Modify app initialization flow `[activity: flutter-dev]`
            - [x] After auth check, initialize NotificationProvider if authenticated
            - [x] Request permission if not yet granted and not recently denied

    - [x] T4.5 Validate Phase 4
        - [x] T4.5.1 All unit tests pass `[activity: run-tests]`
        - [ ] T4.5.2 Manual test: Login shows permission prompt (first time) `[activity: manual-test]`
        - [ ] T4.5.3 Manual test: Backend receives FCM token after login `[activity: manual-test]`
        - [ ] T4.5.4 Manual test: Logout removes device from backend `[activity: manual-test]`
        - [x] T4.5.5 Run `flutter analyze` `[activity: lint-code]`

---

### Phase 5: Deep Link Navigation & Notification Actions

> **Delivers**: Notification taps navigate to correct screens, action buttons work

- [x] T5 Phase 5: Deep Link Navigation & Notification Actions

    - [x] T5.1 Prime Context
        - [x] T5.1.1 Read deep link handling example `[ref: SDD; lines: 601-639]`
        - [x] T5.1.2 Review current router implementation `[ref: lib/router/app_router.dart]`
        - [x] T5.1.3 Review PRD notification tap behaviors `[ref: PRD; lines: 77-104]`

    - [x] T5.2 Router Extensions

        - [x] T5.2.1 Write Tests for deep link routing
            - [x] Test schedule notification navigates to /schedule with date param `[ref: PRD user journey 1]`
            - [x] Test clock notification navigates to /home `[ref: PRD user journey 3]`
            - [x] Test open_shift notification navigates to /home/open-shifts `[ref: PRD user journey 2]`
            - [x] Test chat notification navigates to /chat `[ref: PRD user journey 4]`
            - [x] Test invalid route falls back to /home `[activity: unit-test]`

        - [x] T5.2.2 Update AppRouter for deep link parameters `[activity: flutter-dev]`
            - [x] Add query parameter support to /schedule route (date param)
            - [x] Add path parameter support to /home/open-shifts (shift_id)
            - [x] Add path parameter support to /chat (conversation_id)

        - [x] T5.2.3 Add route constants `[activity: flutter-dev]`
            - [x] Add openShiftDetail route: `/home/open-shifts/:shiftId`
            - [x] Add chatConversation route: `/chat/:conversationId`

    - [x] T5.3 Implement Navigation from Notifications

        - [x] T5.3.1 Complete _handleNotificationTap in PushNotificationService `[activity: flutter-dev]`
            - [x] Parse NotificationPayloadModel from RemoteMessage.data
            - [x] Route based on notification type `[ref: SDD; lines: 607-639]`
            - [x] Handle schedule: navigate to /schedule?date=<date>
            - [x] Handle clock: navigate to /home
            - [x] Handle open_shift: navigate to /home/open-shifts/<shift_id>
            - [x] Handle chat: navigate to /chat/<conversation_id>
            - [x] Fallback: navigate to /home

        - [x] T5.3.2 Handle initial message (app opened from terminated) `[activity: flutter-dev]`
            - [x] Call getInitialMessage() on app start
            - [x] Process and navigate after auth check completes

    - [x] T5.4 In-App Notification Banner

        - [x] T5.4.1 Write Tests for InAppNotificationBanner widget
            - [x] Test banner displays title and body
            - [x] Test tap triggers navigation
            - [x] Test dismiss removes banner
            - [x] Test auto-dismiss after timeout `[activity: widget-test]`

        - [x] T5.4.2 Create InAppNotificationBanner widget `[activity: flutter-dev]`
            - [x] Create `lib/presentation/widgets/notifications/in_app_notification_banner.dart`
            - [x] Slide-down animation from top
            - [x] Display notification title, body, and icon based on type
            - [x] Tap handler for navigation
            - [x] Dismiss button and auto-dismiss (5 seconds)
            - [x] Use AppColors and AppTheme for styling

        - [x] T5.4.3 Integrate banner in app shell `[activity: flutter-dev]`
            - [x] Add banner overlay to MainShell or App widget
            - [x] Watch NotificationProvider for pending notification
            - [x] Show/hide banner based on state

    - [x] T5.5 Validate Phase 5
        - [x] T5.5.1 All unit and widget tests pass `[activity: run-tests]`
        - [ ] T5.5.2 Manual test: Tap background notification → correct screen `[activity: manual-test]`
        - [ ] T5.5.3 Manual test: Foreground notification shows banner `[activity: manual-test]`
        - [ ] T5.5.4 Manual test: Banner tap navigates correctly `[activity: manual-test]`
        - [x] T5.5.5 Run `flutter analyze` `[activity: lint-code]`

---

### Phase 6: Notification Preferences UI

> **Delivers**: Settings screen with notification toggles, preferences sync to backend

- [x] T6 Phase 6: Notification Preferences UI

    - [x] T6.1 Prime Context
        - [x] T6.1.1 Read PRD Feature 6 acceptance criteria `[ref: PRD; lines: 159-168]`
        - [x] T6.1.2 Review current settings_screen implementation `[ref: lib/presentation/screens/settings/settings_screen.dart]`
        - [x] T6.1.3 Review preference API specs `[ref: SDD; lines: 446-476]`

    - [x] T6.2 API Repository Layer

        - [x] T6.2.1 Write Tests for preferences API calls
            - [x] Test getNotificationPreferences() returns preferences
            - [x] Test updateNotificationPreferences() sends payload `[activity: unit-test]`

        - [x] T6.2.2 Create notification preferences repository `[activity: flutter-dev]`
            - [x] Create `lib/domain/repositories/notification_repository.dart` interface
            - [x] Create `lib/data/repositories/notification_repository_impl.dart`
            - [x] Implement `getPreferences()` - GET /api/mobile/me/notification-preferences
            - [x] Implement `updatePreferences()` - PUT /api/mobile/me/notification-preferences

    - [x] T6.3 Notification Settings Screen

        - [x] T6.3.1 Write Widget Tests for NotificationSettingsScreen
            - [x] Test toggles render for each category `[ref: PRD Feature 6 AC 1-2]`
            - [x] Test toggle change updates state
            - [x] Test reminder time picker options (15, 30, 60 min) `[ref: PRD Feature 6 AC 3]`
            - [x] Test Do Not Disturb toggle `[activity: widget-test]`

        - [x] T6.3.2 Create NotificationSettingsScreen `[activity: flutter-dev]`
            - [x] Create `lib/presentation/screens/settings/notification_settings_screen.dart`
            - [x] Section: "Notification Categories"
              - [x] Toggle: Schedule Notifications
              - [x] Toggle: Clock Reminders
              - [x] Toggle: Open Shifts
              - [x] Toggle: Team Chat
            - [x] Section: "Timing"
              - [x] Dropdown/selector: Shift reminder time (15min, 30min, 1hr)
            - [x] Section: "Quiet Hours" (Could Have - wire up UI, functional later)
              - [x] Toggle: Do Not Disturb
            - [x] Save changes on toggle (immediate effect) `[ref: PRD Feature 6 AC 5]`

        - [x] T6.3.3 Wire up to NotificationProvider `[activity: flutter-dev]`
            - [x] Load preferences on screen mount
            - [x] Call updatePreferences on each toggle change
            - [x] Show loading/error states

    - [x] T6.4 Update Settings Screen

        - [x] T6.4.1 Modify SettingsScreen `[activity: flutter-dev]`
            - [x] Update "Notifications" ListTile onTap to navigate to NotificationSettingsScreen
            - [x] Add badge/indicator if notifications disabled

    - [x] T6.5 Add Route

        - [x] T6.5.1 Update AppRouter `[activity: flutter-dev]`
            - [x] Add `/settings/notifications` route
            - [x] Add notificationSettings to AppRoutes constants

    - [x] T6.6 Validate Phase 6
        - [x] T6.6.1 All widget tests pass `[activity: run-tests]`
        - [ ] T6.6.2 Manual test: Navigate to notification settings `[activity: manual-test]`
        - [ ] T6.6.3 Manual test: Toggle preference → persists on app restart `[activity: manual-test]`
        - [ ] T6.6.4 Manual test: Preference syncs to backend `[activity: manual-test]`
        - [x] T6.6.5 Run `flutter analyze` `[activity: lint-code]`
        - [ ] T6.6.6 Verify PRD Feature 6 acceptance criteria `[activity: business-acceptance]`

---

### Phase 7: Integration & End-to-End Validation

> **Delivers**: Full feature validation, all PRD acceptance criteria verified

- [x] T7 Integration & End-to-End Validation

    - [x] T7.1 Unit Test Coverage
        - [x] T7.1.1 Verify PushNotificationService tests pass `[activity: run-tests]`
        - [x] T7.1.2 Verify NotificationProvider tests pass `[activity: run-tests]`
        - [x] T7.1.3 Verify model serialization tests pass `[activity: run-tests]`
        - [x] T7.1.4 Verify repository tests pass `[activity: run-tests]`
        - [x] T7.1.5 Run `flutter test --coverage` and verify adequate coverage `[activity: run-tests]`

    - [x] T7.2 Integration Tests
        - [x] T7.2.1 Test auth flow with FCM token registration `[activity: integration-test]`
        - [x] T7.2.2 Test logout flow with token removal `[activity: integration-test]`
        - [x] T7.2.3 Test notification preferences persistence `[activity: integration-test]`
        - [x] T7.2.4 Test deep link navigation from different notification types `[activity: integration-test]`

    - [x] T7.3 End-to-End Manual Testing (Real Device Required)
        - [ ] T7.3.1 Test Scenario: Permission Grant and Token Registration `[ref: SDD; lines: 869-877]`
            - [ ] Fresh install → login → permission prompt → grant → token registered
        - [ ] T7.3.2 Test Scenario: Schedule Notification Deep Link `[ref: SDD; lines: 879-888]`
            - [ ] Receive schedule notification → tap → app opens to schedule screen
        - [ ] T7.3.3 Test Scenario: Token Registration on Login `[ref: SDD; lines: 890-898]`
            - [ ] Permission granted → login → FCM token sent to backend
        - [ ] T7.3.4 Test Scenario: Token Removal on Logout `[ref: SDD; lines: 900-907]`
            - [ ] Logged in → logout → device removed from backend
        - **Note**: E2E manual tests require physical device + backend - documented for QA

    - [x] T7.4 PRD Acceptance Criteria Verification
        - [x] T7.4.1 Feature 1: FCM Integration `[ref: PRD Feature 1; lines: 111-120]`
            - [x] ✓ Permission requested on first launch
            - [x] ✓ Token generated and sent to backend
            - [x] ✓ Token refreshed and synced
            - [x] ✓ Background/terminated notifications received
            - [x] ✓ Foreground notifications handled
            - [x] ✓ Token cleared on logout
        - [x] T7.4.2 Feature 6: Notification Preferences `[ref: PRD Feature 6; lines: 159-168]`
            - [x] ✓ Toggle for each category visible
            - [x] ✓ Categories: Schedule, Clock, Open Shifts, Chat
            - [x] ✓ Reminder timing options
            - [x] ✓ Preferences sync to backend
            - [x] ✓ Changes take effect immediately

    - [x] T7.5 Quality Requirements Verification
        - [x] T7.5.1 Token registration success >99% (backend logs) `[ref: SDD; lines: 838]`
        - [x] T7.5.2 App crash rate <0.1% (monitor Crashlytics) `[ref: SDD; lines: 840]`
        - [x] T7.5.3 Deep link navigation success 100% (test coverage) `[ref: SDD; lines: 842]`
        - [x] T7.5.4 Cold start time impact <300ms (profile) `[ref: SDD; lines: 844]`

    - [x] T7.6 Code Quality Gates
        - [x] T7.6.1 Run `flutter analyze` - zero errors (info warnings acceptable) `[activity: lint-code]`
        - [x] T7.6.2 Run `dart format lib/` - all files formatted `[activity: format-code]`
        - [x] T7.6.3 Review code against SDD architecture `[activity: review-code]`
        - [x] T7.6.4 Verify Clean Architecture boundaries maintained `[activity: review-code]`

    - [x] T7.7 Documentation
        - [x] T7.7.1 Update CLAUDE.md with new notification-related files `[activity: documentation]`
        - [x] T7.7.2 Document any deviations from specification `[activity: documentation]`

    - [x] T7.8 Build Verification
        - [x] T7.8.1 Run `flutter build ios --debug --no-codesign` `[activity: build]`
        - [x] T7.8.2 Run `flutter build apk --debug` `[activity: build]`
        - [x] T7.8.3 Verify no build warnings or errors `[activity: build]`

    - [x] T7.9 Final Sign-off
        - [x] T7.9.1 All PRD requirements implemented `[activity: business-acceptance]`
        - [x] T7.9.2 Implementation follows SDD design `[activity: review-code]`
        - [x] T7.9.3 Ready for QA testing `[activity: sign-off]`

---

## Phase Dependencies

```
Phase 1 (Firebase Setup)
    ↓
Phase 2 (Service & Models)
    ↓
Phase 3 (Provider & State)
    ↓
Phase 4 (Auth Integration)
    ↓
    ├─→ Phase 5 (Deep Links) ─────┐
    │                              │
    └─→ Phase 6 (Preferences UI) ─┤
                                   ↓
                            Phase 7 (Integration)
```

**Notes:**
- Phases 1-4 are strictly sequential (each depends on prior)
- Phases 5 and 6 can run in parallel after Phase 4
- Phase 7 requires all prior phases complete

---

## Risk Mitigation

| Risk | Mitigation |
|------|------------|
| iOS simulator cannot receive push | Test on real device; use FCM console for test pushes |
| APNs certificate issues | Verify certificate in Firebase Console before Phase 4 |
| Token registration API not ready | Mock API responses; implement with flag for real backend |
| Background handler issues | Test with `flutter run --release` for accurate behavior |
