+
+
🔍 Debug Tools
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
+#### Console.app Integration
+
+**System Logs:**
+- Use `os_log` for system-level logging
+- View logs in Console.app on macOS
+- Filter by subsystem: `com.timesafari.dailynotification`
+- Export logs for analysis
+
+**Log Export:**
+- Export logs from test app UI
+- Export via Xcode Organizer
+- Export via Console.app
+- Include timestamps and log levels
+
+#### Background Task Debugging
+
+**BGTaskScheduler Debugging:**
+1. **Task Registration Verification**
+ - Log task registration in AppDelegate
+ - Verify task identifiers match Info.plist
+ - Check task handler registration
+
+2. **Task Execution Monitoring**
+ - Log task start/completion
+ - Log task expiration
+ - Monitor task execution time
+ - Track task success/failure
+
+3. **Task Scheduling Debugging**
+ - Log scheduled task times
+ - Verify earliestBeginDate
+ - Check task submission success
+ - Monitor task cancellation
+
+**Debug Commands:**
+```swift
+// In test app or debug build
+func debugBackgroundTasks() {
+ // List registered tasks
+ // Show scheduled tasks
+ // Trigger test tasks
+ // View task history
+}
+```
+
+#### Notification Debugging
+
+**Notification Delivery Debugging:**
+1. **Scheduled Notifications**
+ - List all pending notifications
+ - Show notification content
+ - Display trigger times
+ - Verify notification limits
+
+2. **Notification Delivery**
+ - Log notification delivery
+ - Track delivery success/failure
+ - Monitor notification actions
+ - Debug notification display
+
+3. **Permission Debugging**
+ - Check permission status
+ - Log permission requests
+ - Track permission changes
+ - Debug permission denials
+
+**Debug Methods:**
+```swift
+// Debug notification state
+func debugNotifications() {
+ // Get pending notifications
+ // Get delivered notifications
+ // Check notification settings
+ // Verify notification categories
+}
+```
+
+### Test App Implementation Checklist
+
+- [ ] Create `ios-test-app` directory structure (equivalent to `android-test-app`)
+- [ ] Copy HTML/JS UI from `android-test-app/app/src/main/assets/public/index.html`
+- [ ] Adapt JavaScript to use iOS plugin methods
+- [ ] Configure Info.plist with required permissions
+- [ ] Implement AppDelegate with plugin setup
+- [ ] Set up Xcode project/workspace
+- [ ] Configure CocoaPods (if needed) or direct dependencies
+- [ ] Create build script `scripts/build-ios-test-app.sh`
+- [ ] Test Xcode GUI builds
+- [ ] Test command-line builds via script
+- [ ] Implement comprehensive logging
+- [ ] Add Console.app integration
+- [ ] Create debugging documentation
+
+---
+
+## File Organization
+
+### New Files to Create
+
+```
+ios/Plugin/
+├── DailyNotificationStorage.swift # Storage abstraction (new)
+├── DailyNotificationScheduler.swift # Scheduler implementation (new)
+├── DailyNotificationJWTManager.swift # JWT management (new)
+├── EnhancedDailyNotificationFetcher.swift # Enhanced fetcher (new)
+└── DailyNotificationRebootRecoveryManager.swift # Reboot recovery (new)
+```
+
+### Files to Enhance
+
+```
+ios/Plugin/
+├── DailyNotificationPlugin.swift # Add missing methods
+├── DailyNotificationBackgroundTaskManager.swift # Enhance background tasks
+├── DailyNotificationRollingWindow.swift # Enhance rolling window
+├── DailyNotificationTTLEnforcer.swift # Enhance TTL enforcement
+└── DailyNotificationETagManager.swift # Enhance ETag management
+```
+
+### Test App Files to Create
+
+```
+test-apps/ios-test-app/ # New iOS test app (equivalent to android-test-app)
+├── App/
+│ ├── AppDelegate.swift # App delegate with plugin setup
+│ ├── Info.plist # iOS permissions and config
+│ ├── SceneDelegate.swift # Scene management (if needed)
+│ └── Main.storyboard # Main storyboard (if needed)
+├── App.xcodeproj/ # Xcode project
+├── App.xcworkspace/ # Xcode workspace (if using CocoaPods)
+├── Podfile # CocoaPods dependencies
+└── www/ # Web assets (same as android-test-app)
+ ├── index.html # Same UI as android-test-app
+ ├── capacitor.config.json # Capacitor config
+ └── capacitor.plugins.json # Plugin registration
+```
+
+### Build Scripts to Create
+
+```
+scripts/
+└── build-ios-test-app.sh # iOS test app build script (new)
+ # Pattern: Similar to scripts/build-native.sh
+ # Features:
+ # - Check environment (xcodebuild, pod)
+ # - Install dependencies (pod install)
+ # - Build for simulator or device
+ # - Clear error messages and logging
+```
+
+---
+
+## Success Criteria
+
+### Functional Parity
+
+- [ ] All Android `@PluginMethod` methods have iOS equivalents
+- [ ] All methods return same data structures as Android
+- [ ] All methods handle errors consistently with Android
+- [ ] All methods log consistently with Android
+
+### Platform Adaptations
+
+- [ ] iOS uses appropriate iOS APIs (UNUserNotificationCenter, BGTaskScheduler)
+- [ ] iOS respects iOS limits (64 notification limit, background execution limits)
+- [ ] iOS provides iOS-specific features where appropriate (Background App Refresh)
+
+### Code Quality
+
+- [ ] All code follows Swift best practices
+- [ ] All code is documented with file-level and method-level comments
+- [ ] All code includes error handling and logging
+- [ ] All code is type-safe
+
+### Testing
+
+- [ ] Unit tests cover all new methods
+- [ ] Integration tests verify full pipeline
+- [ ] Manual testing confirms real-world behavior
+
+### Test App
+
+- [ ] `ios-test-app` created with same UI as `android-test-app`
+- [ ] Test app uses iOS plugin implementation
+- [ ] All permissions properly configured in Info.plist
+- [ ] Build script `build-ios-test-app.sh` created and working
+- [ ] Build works via both Xcode GUI and command line
+- [ ] Comprehensive logging accessible via Console.app
+- [ ] Background task debugging tools available
+
+---
+
+## Risks & Mitigations
+
+### Risk 1: iOS Background Execution Limitations
+
+**Risk:** iOS background execution is more limited than Android
+**Mitigation:**
+- Use efficient processing algorithms
+- Schedule next task immediately after completion
+- Provide clear user guidance on Background App Refresh
+
+### Risk 2: iOS Notification Limits
+
+**Risk:** iOS 64 notification limit may conflict with rolling window strategy
+**Mitigation:**
+- Implement smart rolling window that respects limits
+- Prioritize today's notifications over tomorrow's
+- Provide clear error messages when limits are reached
+
+### Risk 3: TypeScript Interface Compatibility
+
+**Risk:** iOS implementation may not match TypeScript interface exactly
+**Mitigation:**
+- Test all methods against TypeScript interface
+- Ensure return types match exactly
+- Ensure error handling matches Android behavior
+
+### Risk 4: Platform-Specific Behavior Differences
+
+**Risk:** iOS and Android may behave differently for same operations
+**Mitigation:**
+- Document all platform differences
+- Provide platform-specific error messages where appropriate
+- Test cross-platform compatibility
+
+---
+
+## Timeline Estimate
+
+### Phase 1: Core Infrastructure
+- Storage layer implementation
+- Scheduler implementation (single daily schedule: one prefetch + one notification)
+ - Prefetch scheduled 5 minutes before notification time
+- Background fetching enhancement (single daily prefetch, 5 minutes before notification)
+- Core methods implementation
+- iOS test app creation (ios-test-app)
+- Build script creation (build-ios-test-app.sh)
+- Testing on iOS Simulator
+
+**Test App Readiness:** ✅ Ready for testing after Phase 1 completion
+- Basic scheduling (one prefetch 5 minutes before + one notification per day)
+- Core plugin methods functional
+- Testable on iOS Simulator
+
+### Phase 2: Advanced Features
+- Rolling window enhancement (expands beyond single daily schedule)
+- TTL enforcement enhancement
+- Exact alarm equivalent implementation
+- Reboot recovery implementation
+- Power management enhancement
+- Testing on iOS Simulator
+
+**Test App Readiness:** ✅ Ready for testing after Phase 2 completion
+- Rolling window and advanced features functional
+- Testable on iOS Simulator
+
+### Phase 3: TimeSafari Integration
+- JWT management implementation
+- ETag management enhancement
+- Enhanced fetcher implementation
+- Phase 1 methods implementation
+- Testing on iOS Simulator
+
+**TimeSafari Integration Readiness:** ✅ Library ready for TimeSafari integration after Phase 3 completion
+**Test App Readiness:** ✅ Ready for testing after Phase 3 completion
+- TimeSafari integration features functional
+- Testable on iOS Simulator
+
+### Phase 4: Background Coordination
+- Background coordination implementation
+- Lifecycle management implementation
+- Coordination status implementation
+- Testing on iOS Simulator
+
+**TimeSafari Integration Readiness:** ✅ Full library ready for production TimeSafari integration after Phase 4 completion
+**Test App Readiness:** ✅ Ready for testing after Phase 4 completion
+- Full background coordination functional
+- Testable on iOS Simulator
+
+---
+
+## Dependencies
+
+### External Dependencies
+
+- **Capacitor:** iOS plugin framework
+- **UserNotifications:** iOS notification framework
+- **BackgroundTasks:** iOS background execution framework
+- **CoreData:** iOS data persistence framework
+
+### Internal Dependencies
+
+- **TypeScript Interface:** Must remain unchanged (`src/definitions.ts`)
+- **Android Implementation:** Reference implementation (read-only)
+- **Existing iOS Components:** Build upon existing Swift files
+
+---
+
+## References
+
+### Android Implementation Files
+
+- `src/android/DailyNotificationPlugin.java` - Main plugin class
+- `src/android/DailyNotificationStorage.java` - Storage layer
+- `src/android/DailyNotificationScheduler.java` - Scheduler
+- `src/android/DailyNotificationFetcher.java` - Background fetching
+- `src/android/DailyNotificationDatabase.java` - Database management
+- `src/android/DailyNotificationRollingWindow.java` - Rolling window
+- `src/android/DailyNotificationExactAlarmManager.java` - Exact alarms
+- `src/android/DailyNotificationRebootRecoveryManager.java` - Reboot recovery
+- `src/android/DailyNotificationTTLEnforcer.java` - TTL enforcement
+- `src/android/DailyNotificationETagManager.java` - ETag management
+- `src/android/DailyNotificationJWTManager.java` - JWT management
+- `src/android/EnhancedDailyNotificationFetcher.java` - Enhanced fetcher
+
+### iOS Implementation Files
+
+- `ios/Plugin/DailyNotificationPlugin.swift` - Main plugin class
+- `ios/Plugin/DailyNotificationDatabase.swift` - Database (CoreData)
+- `ios/Plugin/DailyNotificationRollingWindow.swift` - Rolling window
+- `ios/Plugin/DailyNotificationTTLEnforcer.swift` - TTL enforcement
+- `ios/Plugin/DailyNotificationETagManager.swift` - ETag management
+- `ios/Plugin/DailyNotificationBackgroundTaskManager.swift` - Background tasks
+
+### TypeScript Interface
+
+- `src/definitions.ts` - Complete TypeScript interface definition
+
+### Documentation
+
+- `doc/implementation-roadmap.md` - Implementation roadmap
+- `doc/INTEGRATION_CHECKLIST.md` - Integration checklist
+- `README.md` - Project documentation
+
+---
+
+## Competence Hooks
+
+### Why This Works
+
+- **Platform Parity:** Matching Android functionality ensures consistent user experience across platforms
+- **Incremental Approach:** Phased implementation reduces risk and allows for iterative testing
+- **Platform Adaptations:** Using iOS-native APIs ensures optimal performance and reliability
+
+### Common Pitfalls
+
+- **Background Execution Limits:** iOS background execution is more limited than Android - must design for efficiency
+- **Notification Limits:** iOS 64 notification limit requires careful rolling window management
+- **Permission Model:** iOS requires explicit permission requests - must handle gracefully
+
+### Next Skill Unlock
+
+- **iOS Background Execution:** Understanding BGTaskScheduler and background execution patterns
+- **iOS Notification System:** Deep dive into UNUserNotificationCenter and notification delivery guarantees
+
+### Teach-Back
+
+**Question:** "How does iOS background execution differ from Android, and how does this affect the notification scheduling strategy?"
+
+**Expected Answer:** iOS background execution is more limited (30 seconds for refresh tasks) and less reliable than Android WorkManager. This requires efficient processing, immediate next-schedule after completion, and fallback strategies for when background execution fails.
+
+---
+
+## Collaboration Hooks
+
+### Discussion Points
+
+1. **Platform Differences:** How should we handle platform-specific behavior differences in error messages and user guidance?
+2. **Testing Strategy:** What level of cross-platform testing is needed to ensure parity?
+3. **Performance:** How do we ensure iOS implementation performs as well as Android?
+
+### Review Points
+
+- **Code Review:** All new iOS code should be reviewed against Android implementation for functional parity
+- **Architecture Review:** iOS component architecture should be reviewed for maintainability
+- **Testing Review:** Test coverage should be reviewed for completeness
+
+### Stakeholders
+
+- **iOS Developer:** Primary implementer
+- **Android Developer:** Reference implementation owner (consultation)
+- **TypeScript Developer:** Interface maintainer (consultation)
+- **QA:** Testing and validation
+
+---
+
+## Decision Log
+
+### 2025-11-13: Directive Created
+
+**Decision:** Create comprehensive directive for iOS Android parity implementation
+**Rationale:** Need clear plan for upgrading iOS while preserving Android and TypeScript interface
+**Status:** ✅ Approved for implementation
+
+---
+
+**Status:** 🎯 **READY FOR IMPLEMENTATION**
+**Next Steps:** Begin Phase 1 implementation after directive approval
+