Created missing Capacitor JavaScript files required for plugin access:
capacitor.js:
- Copied native-bridge.js from Capacitor framework
- Provides Capacitor runtime and native bridge functionality
- Required for plugin communication with native code
capacitor_plugins.js:
- Created minimal plugin registration file
- Sets up window.Capacitor.Plugins structure
- Allows DailyNotification plugin to be accessed
Fixes:
- Black screen: Capacitor scripts now exist and can be loaded
- Plugin errors: window.Capacitor will be available after scripts load
- JavaScript errors: Missing script files were causing page load failures
Result: App should now load and display the test interface
Updated Capacitor configuration and HTML initialization:
Capacitor Config:
- Changed webDir from 'www' to 'public' to match actual directory structure
- Config now correctly points to App/App/public/ directory
HTML Initialization:
- Removed immediate plugin assignment (was failing because Capacitor not loaded)
- Added Capacitor script tags (capacitor.js, capacitor_plugins.js)
- Added initialization script that waits for Capacitor to be ready
- Plugin is now set after Capacitor loads successfully
Fixes:
- Black screen: Capacitor scripts now load before plugin access
- Plugin errors: window.Capacitor was undefined, now waits for it
- Initialization: Proper async loading of Capacitor runtime
Note: capacitor.js and capacitor_plugins.js will be generated by Capacitor
during build or can be copied from node_modules if needed
Fixed build script to always open Simulator app window:
Simulator Visibility:
- Always opens Simulator app window after booting
- Ensures window is visible even if simulator was already booted
- Provides visual feedback that simulator is running
Boot Flow:
- If already booted: opens Simulator window immediately
- If booting: boots device, then opens Simulator window
- If boot fails: opens Simulator app for manual selection
Fixes:
- Simulator window now always appears after build
- User can see simulator even if it was already running
- Better visual feedback during build process
Result: Simulator window is now always visible after build completes
Enhanced simulator boot logic for better reliability:
Boot Detection:
- More robust check for already-booted simulators
- Uses grep with case-insensitive matching
- Verifies boot status after manual Simulator app opening
Error Handling:
- Shows actual boot command output (removed 2>/dev/null)
- Adds 3-second wait after successful boot for initialization
- Verifies boot status after opening Simulator app manually
- Continues with build even if boot verification fails
Fixes:
- Simulator boot detection now works correctly
- Better error messages when boot fails
- Handles edge cases where simulator is already booted
Result: Build script now reliably detects and boots simulators
Added CFBundleExecutable key required for iOS app installation:
CFBundleExecutable:
- Set to 'App' (matches PRODUCT_NAME from build settings)
- Required by iOS to identify the executable binary
- Without this, app installation fails with 'missing or invalid CFBundleExecutable'
Fixes:
- Installation error: 'Bundle has missing or invalid CFBundleExecutable in its Info.plist'
- App can now be installed on simulator successfully
Result: App installation should now complete successfully
Created missing asset catalog required by Xcode build:
Assets.xcassets:
- Created asset catalog directory structure
- Added Contents.json with standard Xcode format
- Added AppIcon.appiconset with minimal icon configuration
AppIcon.appiconset:
- Minimal icon set configuration for iOS
- Universal platform support
- 1024x1024 size placeholder (actual icons can be added later)
Fixes:
- Build error: 'None of the input catalogs contained a matching app icon set named AppIcon'
- Build error: 'Failed to read file attributes for Assets.xcassets'
- Xcode project expects this asset catalog for app icons
Result: Build should now complete successfully
Fixed simulator auto-detection to extract device name correctly:
Simulator Detection:
- Fixed sed command to extract device name (not UUID)
- Pattern: extracts text before first parenthesis
- Handles whitespace correctly with xargs
Example:
- Input: ' iPhone 17 Pro (UUID) (Status)'
- Output: 'iPhone 17 Pro'
Result: Build script now correctly detects and uses available iPhone simulators
Fixed build script to automatically detect and use available simulators:
Simulator Detection:
- Auto-detects first available iPhone simulator if none specified
- Falls back to generic destination if no iPhones found
- Lists available devices in error messages
Build Destination:
- Uses specific device name when available
- Falls back to generic destination for compatibility
- Handles both named devices and generic destinations
Fixes:
- No longer hardcodes 'iPhone 15 Pro' (which may not exist)
- Works with any available iPhone simulator
- Better error messages showing available devices
Usage:
- ./scripts/build-and-deploy.sh # Auto-detect
- ./scripts/build-and-deploy.sh 'iPhone 17' # Specify device
Result: Build script now works with any available simulator
Created complete iOS test app project structure:
Project Setup:
- Created package.json with Capacitor dependencies
- Installed Capacitor CLI and iOS platform
- Generated Xcode project (App.xcodeproj, App.xcworkspace)
- Configured Podfile with correct paths
Podfile Configuration:
- Fixed paths to use local node_modules for Capacitor
- Added DailyNotificationPlugin from project root
- Configured for iOS 13.0+ deployment target
Fixed Issues:
- Resolved zsh syntax error (CODE_SIGN_IDENTITY='' instead of "")
- Corrected Podfile paths for Capacitor and plugin
- Created public directory for web assets
Result:
- Pod install successful (3 pods installed)
- Workspace ready for command-line builds
- All files in place for simulator builds
Next: Can now run build scripts or xcodebuild commands
Fixed build error: 'cannot find PersistenceController in scope'
Changes:
- Made PersistenceController class public
- Made shared static property public
- Made container property public
- Made init method public
This allows DailyNotificationPlugin to access PersistenceController
across module boundaries. CocoaPods pod install was required to
regenerate project files with updated access modifiers.
Result: iOS plugin now builds successfully
Fixed compilation errors preventing iOS plugin build:
Duplicate Method Declarations:
- Removed duplicate getContentCache() and clearContentCache() from DailyNotificationCallbacks.swift
- These methods are already implemented in DailyNotificationPlugin.swift
- Added comment explaining removal
Override Keyword Issues:
- Added 'public' access modifier to checkPermissions() override
- Added 'public' access modifier to requestPermissions() override
- Methods now properly override parent class methods from CAPPlugin
Build Configuration:
- Set GENERATE_INFOPLIST_FILE=YES for framework target
- Fixed encoding issues with LANG=en_US.UTF-8
Result:
- iOS plugin now builds successfully
- All 52 API methods compile without errors
- Ready for testing and integration
Implemented schedule calculation utility method:
calculateNextRunTime():
- Calculates next run time from cron expression or HH:mm time string
- Supports cron format: "minute hour * * *" (e.g., "30 9 * * *" = 9:30 AM daily)
- Supports time format: "HH:mm" (e.g., "09:30" = 9:30 AM daily)
- Handles same-day vs next-day scheduling
- Returns nextRunAt timestamp in milliseconds
- Fallback to 24 hours from now if parsing fails
calculateNextRunTimeFromSchedule():
- Private helper method for schedule parsing
- Parses both cron and time formats
- Uses Calendar for date calculations
- Handles timezone-aware calculations
iOS Adaptations:
- Uses Calendar.current for date calculations
- TimeInterval conversion (Date to milliseconds)
- Handles edge cases (invalid formats, past times)
Progress: 48/52 methods implemented (92% complete)
Implemented content cache access methods using Core Data:
getContentCacheById():
- Returns content cache by ID or latest if ID not provided
- Uses Core Data fetch with predicate for ID lookup
- Returns null if cache not found
- Matches Android getContentCacheById method
getLatestContentCache():
- Returns latest content cache entry
- Delegates to getContentCacheById with no ID
- Matches Android getLatestContentCache method
saveContentCache():
- Saves content to cache in Core Data
- Auto-generates ID if not provided (cache_timestamp)
- Converts payload string to Data for storage
- Stores fetchedAt, ttlSeconds, payload, and meta
- Returns saved cache object
iOS Adaptations:
- Uses Core Data ContentCache entity
- Payload stored as Data (from JSON string)
- Timestamp conversion (Date to milliseconds)
- Error handling for invalid payload data
Progress: 47/52 methods implemented (90% complete)
Implemented schedule CRUD methods using UserDefaults:
createSchedule():
- Creates new schedule with required kind field
- Auto-generates ID if not provided (kind_timestamp)
- Stores optional fields (cron, clockTime, jitterMs, backoffPolicy, stateJson)
- Adds to schedules array in UserDefaults
- Returns created schedule
updateSchedule():
- Updates existing schedule by ID
- Updates provided fields (enabled, cron, clockTime, jitterMs, backoffPolicy, stateJson, lastRunAt, nextRunAt)
- Returns updated schedule
- Rejects if schedule not found
deleteSchedule():
- Deletes schedule by ID from UserDefaults
- Removes from schedules array
- Rejects if schedule not found
enableSchedule():
- Enables or disables schedule by ID
- Updates enabled field in schedule
- Rejects if schedule not found
iOS Adaptations:
- Uses UserDefaults array instead of SQLite database
- In-memory array manipulation then persistence
- Maintains schedule structure matching Android
Progress: 44/52 methods implemented (85% complete)
Implemented database access methods using UserDefaults:
getSchedules():
- Returns schedules matching optional filters (kind, enabled)
- Filters by schedule type ('fetch' | 'notify')
- Filters by enabled status (true/false/undefined)
- Returns schedules array matching Android API
getSchedule():
- Returns single schedule by ID
- Returns null if not found
- Matches Android getSchedule method
getConfig():
- Returns configuration value by key
- Supports optional timesafariDid for scoped configs
- Returns null if config not found
- Uses UserDefaults with key prefix
setConfig():
- Stores configuration value by key
- Supports optional timesafariDid for scoped configs
- Stores as JSON string in UserDefaults
- Matches Android setConfig method
iOS Adaptations:
- Uses UserDefaults instead of SQLite database
- Config keys prefixed with 'DailyNotificationConfig_'
- DID-scoped configs use composite keys
- JSON serialization for complex values
Progress: 40/52 methods implemented (77% complete)
Implemented alarm status and testing methods matching Android functionality:
isAlarmScheduled():
- Checks if notification is scheduled for given trigger time
- Searches pending notifications for matching trigger date
- Uses 1-minute tolerance for time comparison
- Returns scheduled status and triggerAtMillis
getNextAlarmTime():
- Gets the next scheduled notification time
- Finds earliest scheduled daily notification
- Returns scheduled status and triggerAtMillis (or just scheduled: false)
testAlarm():
- Schedules test notification for testing purposes
- Defaults to 5 seconds from now (configurable)
- Creates test notification with title and body
- Returns scheduled status, secondsFromNow, and triggerAtMillis
- Useful for verifying notification delivery works
iOS Adaptations:
- Uses UNCalendarNotificationTrigger for scheduling
- Searches pending notifications to check status
- Date component matching for precise scheduling
Progress: 30/52 methods implemented (58% complete)
Implemented status and settings methods matching Android functionality:
isChannelEnabled():
- Checks if notifications are enabled (iOS doesn't have channels)
- Returns enabled status and channelId
- Uses UNUserNotificationCenter authorization status
openChannelSettings():
- Opens iOS app notification settings
- iOS doesn't have per-channel settings like Android
- Opens general app settings instead
- Returns opened status and channelId
checkStatus():
- Comprehensive status check combining permissions and scheduling
- Returns notificationsEnabled, isScheduled, scheduledCount, pendingCount
- Includes nextNotificationTime and channel information
- Combines multiple status checks into one call
iOS Adaptations:
- No notification channels (checks app-level authorization)
- Opens app settings instead of channel settings
- Uses UNUserNotificationCenter for status checks
Progress: 27/52 methods implemented (52% complete - HALFWAY!)
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)
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)
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).
Created comprehensive next steps guide with priority recommendations:
Next Steps Documentation:
- Created NEXT_STEPS.md with implementation roadmap
- Prioritized critical API methods (scheduling, permissions, status)
- Provided effort estimates and decision matrix
- Recommended starting with scheduleDailyNotification() method
Current Status:
- Test apps ready (awaiting CocoaPods installation)
- 9/52 API methods implemented
- Plugin compiles successfully
- Foundation solid for further development
Recommended Path:
1. Implement critical scheduling methods (Priority 1)
2. Add permission & status methods (Priority 2)
3. Implement configuration methods (Priority 3)
4. Add content management (Priority 4)
First Target: scheduleDailyNotification() - most commonly used method
Documented CocoaPods installation process and current system status:
Installation Documentation:
- Created COCOAPODS_INSTALLATION.md with installation methods
- Documented Ruby version requirements (>= 2.7.0)
- Provided Homebrew, rbenv, and system Ruby options
- Included troubleshooting guide for common issues
Current Status Documentation:
- Created IOS_SETUP_REQUIREMENTS.md with setup status
- Documented completed command-line setup
- Identified manual step required (CocoaPods installation)
- Provided verification checklist
System Status:
- Ruby 2.6.10 (too old, needs >= 2.7.0)
- Homebrew not installed
- CocoaPods not installed
- All test app structures ready for pod install
Next Steps:
- Install Ruby >= 2.7.0 (via Homebrew recommended)
- Install CocoaPods gem
- Run pod install in both test app directories
Added iOS platform to Vue 3 test app and created standalone iOS test app:
Vue 3 Test App (daily-notification-test):
- Added iOS platform via 'npx cap add ios'
- Created ios/ directory with Xcode project structure
- Added DailyNotificationPlugin to Podfile
- Generated App.xcodeproj and App.xcworkspace
Standalone iOS Test App (ios-test-app):
- Created App structure with Capacitor configuration
- Added DailyNotificationPlugin to Podfile
- Created capacitor.config.json with plugin settings
- Copied test HTML interface (575 lines) from Android test app
- Set up public/ directory for web assets
Plugin Integration:
- Both Podfiles configured with plugin path: '../../../ios'
- Plugin dependencies ready for 'pod install'
- Configuration files created and verified
Documentation:
- Created IOS_TEST_APPS_SETUP_COMPLETE.md with setup details
- Documented next steps for CocoaPods and Xcode building
All command-line setup complete. Ready for:
- pod install (requires CocoaPods)
- Xcode building and testing
Created standalone iOS test app structure matching android-test-app:
- Added ios-test-app directory with README, setup guide, and build scripts
- Created comprehensive iOS synchronization status documentation
- Documented API method gaps between Android (52) and iOS (9 methods)
- Added iOS setup guide for Vue 3 test app
New files:
- test-apps/ios-test-app/ - Standalone iOS test app structure
- docs/IOS_SYNC_STATUS.md - Detailed API comparison and status tracking
- docs/IOS_SYNC_SUMMARY.md - Summary of iOS synchronization work
- test-apps/daily-notification-test/docs/IOS_SETUP.md - Vue app iOS setup
iOS test environments are now ready for setup. Test apps need Xcode project
generation via Capacitor CLI or copying from ios/App.
Next steps: Generate Xcode projects and implement missing API methods.
Fix three critical issues in the Android notification system:
1. configureNativeFetcher() now actually calls nativeFetcher.configure() method
- Previously only stored config in database without configuring fetcher instance
- Added synchronous configure() call with proper error handling
- Stores valid but empty config entry if configure() fails to prevent downstream errors
- Adds FETCHER|CONFIGURE_START and FETCHER|CONFIGURE_COMPLETE instrumentation logs
2. Prefetch operations now use DailyNotificationFetchWorker instead of legacy FetchWorker
- Replaced FetchWorker.scheduleDelayedFetch() with WorkManager scheduling
- Uses correct input data format (scheduled_time, fetch_time, retry_count, immediate)
- Enables native fetcher SPI to be used for prefetch operations
- Handles both delayed and immediate prefetch scenarios
3. Notification dismiss now cancels notification from NotificationManager
- Added notification cancellation before removing from storage
- Uses notificationId.hashCode() to match display notification ID
- Ensures notification disappears immediately when dismiss button is clicked
- Adds DN|DISMISS_CANCEL_NOTIF instrumentation log
Version bump: 1.0.8 → 1.0.11
Fix issue where prefetch worker saved content to ContentCache but didn't
create NotificationContentEntity, causing notification worker to skip
notifications with "content_not_found" error.
Changes:
- Extract notificationTime from input data in doWork()
- Create NotificationContentEntity with matching notification_id when
notificationTime > 0 (prefetch operations)
- Add parsePayload() helper to extract title/body from JSON or plain text
- Save entity to Room database so notification worker can find it
The notification_id format matches NotifyReceiver.kt: "notify_${notificationTime}",
ensuring the notification worker can retrieve content when the alarm fires.
Fixes issue where alarms triggered correctly but notifications were skipped
because DailyNotificationWorker couldn't find content in storage.
Fix reflection-based permission check that was failing with NoSuchMethodException.
Add multiple fallback strategies to ensure permission check works reliably.
Changes:
- Add getDeclaredMethod() fallback when getMethod() fails
- Add heuristic fallback: if exact alarms not allowed, assume they can be requested
- Improve error handling: catch NoSuchMethodException separately from other exceptions
- Add debug logging to track which reflection path is taken
- Change reflection failure log level from ERROR to WARNING (we have fallback)
The heuristic fallback is safe because:
- If exact alarms are not currently allowed, we should try to request them
- Only edge case is permanently denied (rare), worst case is unnecessary Settings redirect
- Better than failing silently or blocking permission requests
Fixes reflection failures seen in logcat where Settings.canRequestScheduleExactAlarms()
method lookup was failing, causing unnecessary Settings redirects.
Add comprehensive exact alarm permission handling for Android 12+ (API 31+)
and fix critical bugs preventing notifications from triggering.
Features:
- Add checkExactAlarmPermission() and requestExactAlarmPermission() plugin methods
- Add canScheduleExactAlarms() and canRequestExactAlarmPermission() helper methods
- Update all scheduling methods to check/request permission before scheduling
- Use reflection for canRequestScheduleExactAlarms() to avoid compilation issues
Bug Fixes:
- Fix receiver mismatch: change alarm intents from NotifyReceiver to DailyNotificationReceiver
- Fix coroutine compilation error: wrap getLatest() suspend call in runBlocking
- Store notification content in database before scheduling alarms
- Update intent action to match manifest registration
The permission request flow opens Settings intent when SCHEDULE_EXACT_ALARM
permission is not granted, providing clear user guidance. All scheduling
methods now check permission status and request it if needed before proceeding.
Version bumped to 1.0.8
- Add cancelAllNotifications() method to DailyNotificationPlugin
- Cancels all AlarmManager alarms (exact and inexact)
- Cancels all WorkManager prefetch/fetch jobs by tag
- Clears notification schedules from database (sets enabled=false)
- Idempotent - safe to call multiple times
- Implementation details:
- Reads scheduled notifications from database
- Uses NotifyReceiver.cancelNotification() for each scheduled alarm
- Includes fallback cleanup for orphaned alarms
- Cancels WorkManager jobs with tags: prefetch, daily_notification_fetch,
daily_notification_maintenance, soft_refetch, daily_notification_display,
daily_notification_dismiss
- Disables all notification and fetch schedules in database
- Add required imports:
- android.app.PendingIntent for alarm cancellation
- androidx.work.WorkManager for job cancellation
- Error handling:
- Gracefully handles missing alarms/jobs (logs warnings, doesn't fail)
- Continues cleanup even if individual operations fail
- Comprehensive logging for debugging
Fixes:
- 'not implemented' error when host app calls cancelAllNotifications()
- Enables users to update notification time without errors
- Allows users to disable notifications completely
- Prevents orphaned alarms and jobs after cancellation
The method matches TypeScript interface and is ready for use.
- Fix MainActivity ClassNotFoundException by using dynamic package launcher intent
- Replace hardcoded MainActivity class references with getLaunchIntent() helper
- Uses packageManager.getLaunchIntentForPackage() to work with any host app
- Removes dependency on specific MainActivity package/class name
- Fixes 3 occurrences in NotifyReceiver.kt (alarm clock, notification click, reminder click)
- Add exact alarm permission check before scheduling (Android 12+)
- Add canScheduleExactAlarms() helper to check SCHEDULE_EXACT_ALARM permission
- Check permission before scheduling exact alarms in scheduleExactNotification()
- Gracefully fall back to inexact alarms when permission not granted
- Prevents SecurityException and provides clear logging
- Bump version to 1.0.2
Fixes:
- ClassNotFoundException when plugin tries to resolve hardcoded MainActivity path
- SecurityException on Android 12+ when exact alarm permission not granted
- Plugin now works with any host app regardless of MainActivity package/class
All changes maintain backward compatibility and improve reliability.
The Vue test app was missing the NotifyReceiver registration in
AndroidManifest.xml, preventing alarm broadcasts from being delivered
to the BroadcastReceiver. This caused notifications scheduled via
setAlarmClock() to fire but not display.
Added NotifyReceiver registration matching the working android-test-app
configuration. Also includes supporting improvements:
- Enhanced alarm scheduling with setAlarmClock() for Doze exemption
- Unique request codes based on trigger time to prevent PendingIntent conflicts
- Diagnostic methods (isAlarmScheduled, getNextAlarmTime, testAlarm)
- TypeScript definitions for new methods
Verified: Notification successfully fired at 09:41:00 and was displayed.
- Add handleOnResume() fallback to resolve permission requests when
Capacitor Bridge doesn't route results (requestCode 1001)
- Implement checkPermissions() with override modifier for Capacitor
standard PermissionStatus format
- Implement getExactAlarmStatus() to return exact alarm capability info
- Implement updateStarredPlans() to store plan IDs in SharedPreferences
- Fix requestPermissions() override to properly delegate to
requestNotificationPermissions()
- Fix handleRequestPermissionsResult() return type to Unit
These changes ensure permission requests resolve correctly even when
Capacitor's Bridge doesn't recognize our custom request code, and
implement all missing methods called by the test application.
- Fix cron parsing to correctly calculate next run time based on hour/minute
- Always schedule prefetch 5 minutes before notification (even without URL)
- Make notifications dismissable with setAutoCancel(true)
- Add click action to launch app when notification is tapped
- Conditionally require network only when URL is provided for prefetch
- Generate mock content when no URL is specified
These changes ensure notifications fire at the correct time, are
user-friendly (dismissable and clickable), and prefetch works reliably
even without a content URL.