Commit Graph

22 Commits

Author SHA1 Message Date
Matthew Raymer
ca40b971c5 feat(ios): implement getPowerState, requestBatteryOptimizationExemption, and setAdaptiveScheduling methods
Implemented power and scheduling utility methods:

getPowerState():
- Returns power state code (0=unknown, 1=unplugged, 2=charging, 3=full)
- Returns isOptimizationExempt (always false on iOS)
- Uses UIDevice battery monitoring

requestBatteryOptimizationExemption():
- No-op on iOS (battery optimization not applicable)
- Exists for API compatibility with Android
- Background App Refresh is user-controlled in Settings

setAdaptiveScheduling():
- Enables/disables adaptive scheduling
- Stores setting in UserDefaults
- Matches Android behavior

iOS Adaptations:
- Battery optimization not applicable (Background App Refresh is system setting)
- Power state derived from battery state
- Adaptive scheduling stored in UserDefaults

Progress: 24/52 methods implemented (46% complete)
2025-11-11 02:10:39 -08:00
Matthew Raymer
d2b1ab07cd feat(ios): implement getContentCache and clearContentCache methods
Implemented content cache management methods matching Android functionality:

getContentCache():
- Retrieves latest cached content from Core Data
- Returns id, fetchedAt, ttlSeconds, payload, and meta
- Returns empty object if no cache exists
- Uses async Task for Core Data access

clearContentCache():
- Deletes all content cache entries from Core Data
- Uses NSBatchDeleteRequest for efficient deletion
- Saves context after deletion

iOS Adaptations:
- Uses Core Data (ContentCache entity) instead of SQLite
- Async/await pattern for Core Data operations
- JSON deserialization for payload
- Timestamp conversion (Date to milliseconds)

Progress: 21/52 methods implemented (40% complete)
2025-11-11 02:08:41 -08:00
Matthew Raymer
ebab224916 feat(ios): implement configureNativeFetcher and setActiveDidFromHost methods
Implemented TimeSafari integration configuration methods:

configureNativeFetcher():
- Accepts apiBaseUrl, activeDid, and jwtToken/jwtSecret
- Stores configuration as JSON in UserDefaults
- Matches Android database storage pattern
- Supports backward compatibility (jwtToken/jwtSecret)
- Stores configuredAt timestamp

setActiveDidFromHost():
- Simpler method for updating just the activeDid
- Updates activeDid in UserDefaults
- Updates existing native fetcher config if present
- Stores updatedAt timestamp

iOS Adaptations:
- Uses UserDefaults instead of database (iOS equivalent of SharedPreferences)
- JSON serialization for config storage
- No native fetcher interface (unlike Android) - config stored for background tasks

Progress: 19/52 methods implemented (37% complete)
2025-11-11 02:07:59 -08:00
Matthew Raymer
17ede3ab20 feat(ios): implement updateStarredPlans method
Implemented starred plans update method matching Android functionality:

updateStarredPlans():
- Accepts planIds array from call options
- Handles multiple array formats (String array, Any array, single string)
- Stores planIds as JSON array string in UserDefaults
- Uses same key name as Android (starredPlanIds in daily_notification_timesafari)
- Returns success, count, and updatedAt timestamp
- Matches Android SharedPreferences storage pattern

iOS Adaptations:
- Uses UserDefaults with suite name for preference grouping
- JSON serialization for array storage (matching Android JSONArray format)
- Error handling for serialization failures

Progress: 17/52 methods implemented (33% complete)
2025-11-11 01:57:24 -08:00
Matthew Raymer
928733f87f feat(ios): implement getBatteryStatus method
Implemented battery status method matching Android functionality:

getBatteryStatus():
- Gets battery level (0-100%) using UIDevice
- Detects charging state (charging or full)
- Maps battery state to power state code (0=unknown, 1=unplugged, 2=charging, 3=full)
- Returns isOptimizationExempt (always false on iOS - no battery optimization)
- Enables battery monitoring automatically

iOS Adaptations:
- Uses UIDevice.current for battery information
- Battery optimization not applicable on iOS (Background App Refresh is system setting)
- Returns -1 for battery level if unknown

Progress: 16/52 methods implemented (31% complete)
2025-11-11 01:56:42 -08:00
Matthew Raymer
f651124466 feat(ios): implement permission checking and requesting methods
Implemented permission management methods matching Android functionality:

checkPermissionStatus():
- Checks notification authorization status
- Checks Background App Refresh (iOS equivalent of exact alarm)
- Returns boolean flags matching Android API
- Includes allPermissionsGranted flag

requestNotificationPermissions():
- Requests notification authorization from user
- Returns PermissionStatus matching Android format
- Includes detailed permission settings (alert, badge, sound, lockScreen, carPlay)
- Handles already-granted case

checkPermissions() / requestPermissions():
- Standard Capacitor permission format methods
- Maps iOS authorization status to PermissionState
- Compatible with Capacitor permission system

iOS Adaptations:
- Uses UNUserNotificationCenter for permission checks
- Background App Refresh inferred from notification status
- Wake lock always enabled on iOS (not applicable)

Progress: 15/52 methods implemented (29% complete)
2025-11-11 01:55:28 -08:00
Matthew Raymer
d7754752ba feat(ios): implement getNotificationStatus and cancelAllNotifications methods
Implemented status and cancellation methods matching Android functionality:

getNotificationStatus():
- Gets pending notifications from UNUserNotificationCenter
- Retrieves schedules from UserDefaults
- Calculates next notification time from schedules
- Returns status matching Android API structure
- Includes isEnabled, isScheduled, lastNotificationTime, nextNotificationTime, pending count

cancelAllNotifications():
- Removes all pending daily notifications from UNUserNotificationCenter
- Cancels background fetch tasks by identifier
- Clears notification schedules from UserDefaults
- Idempotent (safe to call multiple times)
- Matches Android behavior (cancels alarms, WorkManager jobs, database)

Helper Methods:
- getSchedulesFromUserDefaults() - Retrieves stored schedules
- Improved storeScheduleInUserDefaults() - Prevents duplicates

Progress: 12/52 methods implemented (23% complete)
2025-11-11 01:54:52 -08:00
Matthew Raymer
a7dd559c4a feat(ios): implement scheduleDailyNotification method
Implemented main scheduling method for iOS plugin, matching Android functionality:

Core Features:
- Permission checking and requesting (iOS notification authorization)
- Time parsing (HH:mm format) with validation
- Next run time calculation (handles same-day and next-day scheduling)
- UNUserNotificationCenter scheduling with daily repeat
- Priority/interruption level support (iOS 15.0+)
- Prefetch scheduling 5 minutes before notification (BGTaskScheduler)
- Schedule storage in UserDefaults

Implementation Details:
- Checks notification authorization status before scheduling
- Requests permission if not granted (equivalent to Android exact alarm permission)
- Parses time string and calculates next occurrence
- Creates UNCalendarNotificationTrigger for daily repeat
- Schedules BGAppRefreshTask for prefetch 5 minutes before
- Stores schedule metadata in UserDefaults for persistence

Matches Android API:
- Same parameter structure (time, title, body, sound, priority, url)
- Same behavior (daily repeat, prefetch scheduling)
- iOS-specific adaptations (UNUserNotificationCenter vs AlarmManager)

This is the first critical method implementation (10/52 methods now complete).
2025-11-11 01:50:26 -08:00
Matthew Raymer
8ded555a21 fix(ios): resolve compilation errors and enable successful build
Fixed critical compilation errors preventing iOS plugin build:
- Updated logger API calls from logger.debug(TAG, msg) to logger.log(.debug, msg)
  across all iOS plugin files to match DailyNotificationLogger interface
- Fixed async/await concurrency in makeConditionalRequest using semaphore pattern
- Fixed NotificationContent immutability by creating new instances instead of mutation
- Changed private access control to internal for extension-accessible methods
- Added iOS 15.0+ availability checks for interruptionLevel property
- Fixed static member references using Self.MEMBER_NAME syntax
- Added missing .scheduling case to exhaustive switch statement
- Fixed variable initialization in retry state closures

Added DailyNotificationStorage.swift implementation matching Android pattern.

Updated build scripts with improved error reporting and full log visibility.

iOS plugin now compiles successfully. All build errors resolved.
2025-11-04 22:22:02 -08:00
Matthew Raymer
4be87acc14 feat(ios): add iOS deployment support and web assets parity
Add comprehensive iOS build and deployment infrastructure with command-line
tooling, documentation, and web assets synchronization.

Changes:
- Update Capacitor dependencies to v6.0 in podspec
- Add iOS build support to build-native.sh with NVM integration
- Sync iOS web assets to match www/ source directory
- Create deployment scripts for both native iOS app and Vue 3 test app
- Add comprehensive iOS simulator deployment documentation
- Document web assets parity requirements between Android and iOS

This enables:
- Command-line iOS builds without Xcode UI
- Automated deployment to iOS simulators
- Consistent web assets across platforms
- Clear separation between native iOS app (ios/App) and Vue 3 test app

Files modified:
- ios/DailyNotificationPlugin.podspec (Capacitor 6.0)
- ios/App/App/public/index.html (synced from www/)
- scripts/build-native.sh (iOS build support)

Files added:
- docs/WEB_ASSETS_PARITY.md
- docs/standalone-ios-simulator-guide.md
- scripts/build-and-deploy-native-ios.sh
- test-apps/daily-notification-test/docs/IOS_BUILD_QUICK_REFERENCE.md
- test-apps/daily-notification-test/scripts/build-and-deploy-ios.sh
2025-11-04 01:40:38 -08:00
Matthew Raymer
f746434b6b refactor(plugin): remove echo test method and references
- Remove echo() method from DailyNotificationPlugin.java
- Update Android test app to show 'Plugin is loaded and ready!' instead of echo test
- Update web test app to remove echo method call
- Update iOS test app to remove echo method call
- Update documentation to remove echo test references
- Replace echo test with simple plugin availability check

The echo test was only used for initial plugin verification and is no longer
needed since the plugin now has comprehensive notification functionality.
This simplifies the codebase and removes unnecessary test code.
2025-10-14 06:31:07 +00:00
Matthew Raymer
e789fa6a60 feat: complete android test app setup
- Create missing capacitor-cordova-android-plugins directory and build files
- Add cordova.variables.gradle with proper variable definitions
- Create www directory with functional test web app
- Add capacitor.config.ts with plugin configuration
- Fix test file package names from com.getcapacitor.myapp to com.timesafari.dailynotification
- Move test files to correct package directories
- Test app now builds successfully and creates APK
- Capacitor sync now works (Android portion)
- Build script handles both plugin and test app builds

The android/app test app is now fully functional and can be used
to test the DailyNotification plugin in a real Android environment.
2025-10-12 06:24:59 +00:00
Matthew Raymer
f9c21d4e5b docs: add comprehensive static daily reminders documentation
- Add static daily reminders to README.md core features and API reference
- Create detailed usage guide in USAGE.md with examples and best practices
- Add version 2.1.0 changelog entry documenting new reminder functionality
- Create examples/static-daily-reminders.ts with complete usage examples
- Update test-apps README to include reminder testing capabilities

The static daily reminder feature provides simple daily notifications
without network content dependency, supporting cross-platform scheduling
with rich customization options.
2025-10-05 05:12:06 +00:00
Matthew Raymer
a71fb2fd67 feat(ios)!: implement iOS parity with BGTaskScheduler + UNUserNotificationCenter
- Add complete iOS plugin implementation with BGTaskScheduler integration
- Implement Core Data model mirroring Android SQLite schema (ContentCache, Schedule, Callback, History)
- Add background task handlers for content fetch and notification delivery
- Implement TTL-at-fire logic with Core Data persistence
- Add callback management with HTTP and local callback support
- Include comprehensive error handling and structured logging
- Add Info.plist configuration for background tasks and permissions
- Support for dual scheduling with BGAppRefreshTask and BGProcessingTask

BREAKING CHANGE: iOS implementation requires iOS 13.0+ and background task permissions
2025-09-22 09:39:54 +00:00
Matthew Raymer
0ccf071f5c feat(performance): implement Phase 3.3 performance optimization for production
- Add DailyNotificationPerformanceOptimizer for Android with comprehensive optimization
- Add DailyNotificationPerformanceOptimizer for iOS with Swift performance management
- Implement database query optimization with indexes and PRAGMA settings
- Add memory usage monitoring with automatic cleanup and thresholds
- Implement object pooling for frequently used objects to reduce allocation
- Add battery usage tracking and background CPU optimization
- Add network request optimization and efficiency monitoring
- Add comprehensive performance metrics and reporting
- Add production-ready optimization with stress testing support
- Add phase3-3-performance-optimization.ts usage examples

This implements Phase 3.3 performance optimization for production reliability:
- Database indexes for query optimization (slot_id, fetched_at, status, etc.)
- Memory monitoring with warning/critical thresholds and automatic cleanup
- Object pooling for String, Data, and other frequently used objects
- Battery optimization with background CPU usage minimization
- Network request batching and efficiency improvements
- Comprehensive performance metrics tracking and reporting
- Production-ready optimization with configurable thresholds
- Cross-platform implementation (Android + iOS)

Files: 3 changed, 1200+ insertions(+)
2025-09-09 05:00:36 +00:00
Matthew Raymer
359051c13f feat(etag): implement Phase 3.1 ETag support for efficient content fetching
- Add DailyNotificationETagManager for Android with conditional request handling
- Add DailyNotificationETagManager for iOS with URLSession integration
- Update DailyNotificationFetcher with ETag manager integration
- Implement If-None-Match header support for conditional requests
- Add 304 Not Modified response handling for cached content
- Add ETag storage and validation with TTL management
- Add network efficiency metrics and cache statistics
- Add conditional request logic with fallback handling
- Add ETag cache management and cleanup methods
- Add phase3-1-etag-support.ts usage examples

This implements Phase 3.1 ETag support for network optimization:
- Conditional requests with If-None-Match headers
- 304 Not Modified response handling for bandwidth savings
- ETag caching with 24-hour TTL for efficient storage
- Network metrics tracking cache hit ratios and efficiency
- Graceful fallback when ETag requests fail
- Comprehensive cache management and cleanup
- Cross-platform implementation (Android + iOS)

Files: 4 changed, 800+ insertions(+)
2025-09-09 03:31:43 +00:00
Matthew Raymer
13905db3e4 feat(etag): implement Phase 3.1 ETag support for efficient content fetching
- Add DailyNotificationETagManager for Android with conditional request handling
- Add DailyNotificationETagManager for iOS with URLSession integration
- Update DailyNotificationFetcher with ETag manager integration
- Implement If-None-Match header support for conditional requests
- Add 304 Not Modified response handling for cached content
- Add ETag storage and validation with TTL management
- Add network efficiency metrics and cache statistics
- Add conditional request logic with fallback handling
- Add ETag cache management and cleanup methods
- Add phase3-1-etag-support.ts usage examples

This implements Phase 3.1 ETag support for network optimization:
- Conditional requests with If-None-Match headers
- 304 Not Modified response handling for bandwidth savings
- ETag caching with 24-hour TTL for efficient storage
- Network metrics tracking cache hit ratios and efficiency
- Graceful fallback when ETag requests fail
- Comprehensive cache management and cleanup
- Cross-platform implementation (Android + iOS)

Files: 4 changed, 800+ insertions(+)
2025-09-09 03:19:54 +00:00
Matthew Raymer
5eebae9556 feat(ios): implement Phase 2.1 iOS background tasks with T–lead prefetch
- Add DailyNotificationBackgroundTaskManager with BGTaskScheduler integration
- Add DailyNotificationTTLEnforcer for iOS freshness validation
- Add DailyNotificationRollingWindow for iOS capacity management
- Add DailyNotificationDatabase with SQLite schema and WAL mode
- Add NotificationContent data structure for iOS
- Update DailyNotificationPlugin with background task integration
- Add phase2-1-ios-background-tasks.ts usage examples

This implements the critical Phase 2.1 iOS background execution:
- BGTaskScheduler integration for T–lead prefetch
- Single-attempt prefetch with 12s timeout
- ETag/304 caching support for efficient content updates
- Background execution constraints handling
- Integration with existing TTL enforcement and rolling window
- iOS-specific capacity limits and notification management

Files: 7 changed, 2088 insertions(+), 299 deletions(-)
2025-09-08 10:30:13 +00:00
Matthew Raymer
3a181632d1 docs: add comprehensive notification system documentation
- Add GLOSSARY.md with core terminology and cross-references
- Add implementation-roadmap.md with 3-phase development plan
- Add notification-system.md with Native-First architecture spec
- Update ios/Plugin/README.md to reflect actual vs planned implementation status

This establishes the foundation for implementing shared SQLite storage,
TTL-at-fire enforcement, rolling window safety, and platform completion
as outlined in the phased roadmap.

Files: 4 changed, 807 insertions(+), 13 deletions(-)
2025-09-08 08:57:36 +00:00
Matthew Raymer
a54ba34cb9 feat(ios): Enhance battery optimization and notification management
Description:
- Add battery status and power state monitoring
- Implement adaptive scheduling based on battery levels
- Add maintenance worker for background tasks
- Enhance logging with structured DailyNotificationLogger
- Add configuration management with DailyNotificationConfig
- Define constants in DailyNotificationConstants
- Improve error handling and recovery mechanisms

Testing:
- Add comprehensive test coverage for battery optimization
- Add test coverage for power state management
- Add test coverage for maintenance tasks
- Add test coverage for configuration management
- Add test coverage for constants validation

Documentation:
- Add comprehensive file-level documentation
- Add method-level documentation
- Add test documentation
- Add configuration documentation

This commit improves the iOS implementation's reliability and battery
efficiency by adding robust error handling, logging, and configuration
management to make the plugin more maintainable and debuggable.
2025-03-28 03:50:54 -07:00
Server
9994db28bd feat: implement core notification functionality for iOS and Android - Add settings management, proper error handling, and platform-specific implementations 2025-03-27 01:50:19 -07:00
Matthew Raymer
71e0f297ff refactor: improve build configuration and code organization
- Add build scripts for Android and iOS platforms
- Remove duplicate web implementation (src/web.ts)
- Add proper TypeScript configuration
- Add module documentation to index.ts
- Clean up package.json scripts

This commit improves the project structure and build process by:
1. Adding dedicated build scripts for native platforms
2. Removing redundant web implementation
3. Adding proper TypeScript configuration with strict mode
4. Improving code documentation
5. Organizing package.json scripts

The changes maintain backward compatibility while improving
the development experience and code quality.
2025-03-25 13:13:55 +00:00