Commit Graph

325 Commits

Author SHA1 Message Date
Matthew Raymer
308e249620 fix(ios): add missing CFBundleExecutable to Info.plist
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
2025-11-11 19:54:09 -08:00
Matthew Raymer
a330f25e21 fix(ios): add missing Assets.xcassets with AppIcon for test app
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
2025-11-11 19:51:54 -08:00
Matthew Raymer
fa0fea7f75 fix(ios): add missing storyboard files for test app
Created missing storyboard files required by Xcode build:

Main.storyboard:
- Minimal storyboard referencing CAPBridgeViewController
- Required for Capacitor app initialization
- Matches standard Capacitor iOS app structure

LaunchScreen.storyboard:
- Launch screen storyboard for app startup
- Simple view controller with safe area layout
- Referenced in Info.plist as UILaunchStoryboardName

Fixes:
- Build error: 'Build input file cannot be found: Main.storyboard'
- Build error: 'Build input file cannot be found: LaunchScreen.storyboard'
- Xcode project expects these files for storyboard-based UI

Result: Build should now complete successfully
2025-11-11 19:50:01 -08:00
Matthew Raymer
b45ac46b98 fix(ios): correct simulator name extraction in build script
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
2025-11-11 19:47:12 -08:00
Matthew Raymer
a6b48013ab fix(ios): auto-detect available iPhone simulator for builds
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
2025-11-11 19:46:56 -08:00
Matthew Raymer
d7fe746b6b feat(ios): add comprehensive requirements checking and improved CocoaPods detection
Enhanced iOS test app setup with better prerequisite handling:

Requirements Checker:
- Created check-requirements.sh script
- Verifies all prerequisites (macOS, Xcode, Ruby, CocoaPods, Node.js)
- Checks Ruby version (requires 3.1+)
- Detects CocoaPods in multiple locations (PATH, rbenv, gem bin)
- Validates UTF-8 encoding
- Provides installation instructions for missing items

Build Script Improvements:
- Enhanced CocoaPods detection (checks PATH, rbenv, gem bin)
- Better error messages with installation options
- Automatic LANG=en_US.UTF-8 export
- Uses detected pod command location

Documentation Updates:
- Expanded prerequisites section with versions
- Added rbenv recommendation
- Added quick requirements check step
- Clearer installation instructions

Fixes:
- Handles rbenv-based CocoaPods installation
- Works with system Ruby, rbenv, or Homebrew
- Provides helpful error messages

Result: Developers can easily verify and install all requirements
2025-11-11 19:36:47 -08:00
Matthew Raymer
d23a1e8719 feat(ios): set up iOS test app project structure from command line
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
2025-11-11 19:30:43 -08:00
Matthew Raymer
09a3d5159c docs(ios): add comprehensive iOS code signing guide
Created iOS code signing documentation:

Signing Scenarios:
- Simulator builds (signing disabled - faster)
- Device builds with automatic signing (recommended)
- Device builds with manual signing (advanced)

Configuration:
- Command-line build flags for each scenario
- Xcode project settings
- Environment variables

Troubleshooting:
- Common signing errors and solutions
- Certificate and provisioning profile issues
- Bundle identifier conflicts
- Verification commands

Quick Reference:
- Simulator: CODE_SIGNING_REQUIRED=NO
- Device (auto): CODE_SIGN_STYLE=Automatic + DEVELOPMENT_TEAM
- Device (manual): CODE_SIGN_STYLE=Manual + PROVISIONING_PROFILE

Updated SETUP.md:
- Added code signing section
- Quick reference for simulator vs device builds
- Link to comprehensive guide

Result: Complete signing guide for all iOS build scenarios
2025-11-11 19:09:45 -08:00
Matthew Raymer
5f55882b02 docs(ios): enhance iOS test app SETUP.md with Android app information
Expanded iOS test app setup guide with comprehensive information:

Added Sections:
- Prerequisites (macOS, Xcode, CocoaPods, Node.js, Ruby)
- Quick Start options (copy existing vs generate new)
- Detailed configuration steps (Podfile, Capacitor, Info.plist)
- iOS-specific permissions and background modes
- Build and run instructions (Xcode, command line, scripts)
- Test interface features (matching Android test app)
- iOS-specific considerations (background execution, notifications, storage)
- Comprehensive troubleshooting guide
- Project structure documentation
- Dependencies list
- Android vs iOS comparison table
- Additional resources and support

Configuration Details:
- Podfile with plugin path
- Capacitor config with plugin options
- Info.plist permissions (UIBackgroundModes, BGTaskScheduler, notifications)
- iOS permission equivalents to Android

Troubleshooting:
- Plugin not found solutions
- CocoaPods encoding and installation issues
- Build errors and cleanup procedures
- Runtime issues (notifications, background tasks, plugin methods)

Comparison Table:
- Side-by-side Android vs iOS equivalents
- Build systems, permissions, storage, etc.

Result: Comprehensive setup guide matching Android test app documentation
2025-11-11 18:08:36 -08:00
Matthew Raymer
530691b863 fix(ios): make PersistenceController public for build access
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
2025-11-11 17:45:01 -08:00
Matthew Raymer
04602de973 fix(ios): resolve compilation errors for iOS plugin build
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
2025-11-11 17:36:11 -08:00
Matthew Raymer
93a6000b59 docs(ios): add iOS implementation completion summary
Created comprehensive completion summary documenting:

Implementation Status:
- 52/52 methods implemented (100% API parity)
- All method categories completed
- iOS-specific adaptations documented

Method Categories:
- Core scheduling (3)
- Permissions (4)
- Status & battery (4)
- Configuration (3)
- Content management (5)
- Power & scheduling (3)
- Status & settings (3)
- Alarm status (3)
- Exact alarm (2)
- Dual schedule (4)
- Database access (8)
- Schedule CRUD (4)
- History (2)
- Config management (3)
- Utility methods (1)

iOS Adaptations:
- UserDefaults for schedules/configs
- Core Data for cache/history
- UNUserNotificationCenter for notifications
- BGTaskScheduler for background tasks
- Platform differences documented

Known Limitations:
- getAllConfigs() limited by UserDefaults enumeration
- Background App Refresh cannot be checked programmatically
- Battery optimization not applicable on iOS

Ready for testing and integration!
2025-11-11 02:28:06 -08:00
Matthew Raymer
ca081e971d feat(ios): implement getHistory, getHistoryStats, getAllConfigs, updateConfig, and deleteConfig methods
Implemented history and config management methods:

getHistory():
- Returns history entries with optional filters (since, kind, limit)
- Uses Core Data History entity
- Filters by timestamp and kind
- Sorts by occurredAt descending (most recent first)
- Returns history array matching Android API

getHistoryStats():
- Returns statistics about history entries
- Counts outcomes and kinds
- Finds mostRecent and oldest timestamps
- Returns totalCount, outcomes, kinds, mostRecent, oldest
- Uses Core Data for aggregation

getAllConfigs():
- Returns all configurations (limited by UserDefaults enumeration)
- Supports optional filters (timesafariDid, configType)
- Note: UserDefaults doesn't support key enumeration directly
- Returns empty array (limitation documented)

updateConfig():
- Updates existing configuration value
- Validates config exists before updating
- Supports optional timesafariDid for scoped configs
- Handles JSON and plain string values
- Returns updated config

deleteConfig():
- Deletes configuration by key
- Validates config exists before deletion
- Supports optional timesafariDid for scoped configs
- Removes from UserDefaults

iOS Adaptations:
- Uses Core Data History entity for history storage
- UserDefaults for config storage (enumeration limitation)
- Timestamp conversion (Date to milliseconds)
- Predicate-based filtering for Core Data queries

Progress: 52/52 methods implemented (100% COMPLETE!)
2025-11-11 02:23:41 -08:00
Matthew Raymer
a8d92291e9 feat(ios): implement calculateNextRunTime method
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)
2025-11-11 02:20:50 -08:00
Matthew Raymer
9d5ffcfdb5 feat(ios): implement getContentCacheById, getLatestContentCache, and saveContentCache methods
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)
2025-11-11 02:18:55 -08:00
Matthew Raymer
be6cdc98d6 feat(ios): implement createSchedule, updateSchedule, deleteSchedule, and enableSchedule methods
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)
2025-11-11 02:17:59 -08:00
Matthew Raymer
082a70f54f feat(ios): implement getSchedules, getSchedule, getConfig, and setConfig methods
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)
2025-11-11 02:17:02 -08:00
Matthew Raymer
22fdaa789d feat(ios): implement updateDualScheduleConfig, cancelDualSchedule, pauseDualSchedule, and resumeDualSchedule methods
Implemented dual schedule management methods:

updateDualScheduleConfig():
- Updates dual schedule configuration
- Cancels existing schedules and reschedules with new config
- Stores config in UserDefaults for persistence
- Combines content fetch and user notification scheduling

cancelDualSchedule():
- Cancels all dual schedule notifications
- Clears stored dual schedule config
- Uses existing cancelAllNotifications method

pauseDualSchedule():
- Pauses dual schedule by cancelling notifications
- Stores pause state in UserDefaults
- Allows resuming later with stored config

resumeDualSchedule():
- Resumes paused dual schedule
- Restores from stored config in UserDefaults
- Re-schedules both content fetch and user notification
- Validates pause state before resuming

iOS Adaptations:
- Uses UserDefaults for config persistence
- Pause/resume pattern for schedule management
- Config restoration on resume

Progress: 36/52 methods implemented (69% complete)
2025-11-11 02:14:54 -08:00
Matthew Raymer
9a8589bb08 feat(ios): implement getExactAlarmStatus and openExactAlarmSettings methods
Implemented exact alarm status methods matching Android functionality:

getExactAlarmStatus():
- Returns exact alarm scheduling capability information
- iOS always supports exact alarms (UNUserNotificationCenter)
- Returns supported=true, enabled based on notification authorization
- No fallback window needed (exact scheduling always available)
- Matches Android API structure

openExactAlarmSettings():
- Opens iOS app notification settings
- iOS doesn't have separate exact alarm settings like Android
- Opens general app settings instead
- Provides API compatibility with Android

iOS Adaptations:
- Exact alarms always supported (no permission needed)
- Enabled status based on notification authorization
- No fallback window (precise scheduling always available)
- Opens app settings instead of exact alarm settings

Progress: 32/52 methods implemented (62% complete)
2025-11-11 02:13:15 -08:00
Matthew Raymer
bdee842ea9 feat(ios): implement isAlarmScheduled, getNextAlarmTime, and testAlarm methods
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)
2025-11-11 02:12:35 -08:00
Matthew Raymer
b3817a0cb1 feat(ios): implement isChannelEnabled, openChannelSettings, and checkStatus methods
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!)
2025-11-11 02:11:08 -08:00
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
24fd7c1679 docs(ios): add next steps roadmap for iOS implementation
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
2025-11-11 01:45:48 -08:00
Matthew Raymer
9790f2d01c docs(ios): document CocoaPods installation requirements and current status
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
2025-11-11 01:42:44 -08:00
Matthew Raymer
a2e4517518 feat(ios): complete iOS test apps setup with plugin integration
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
2025-11-11 01:37:05 -08:00
Matthew Raymer
a166f3be9a feat(ios): create iOS test app structure and synchronization documentation
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.
2025-11-11 01:30:31 -08:00
Matthew Raymer
fbd9ad338d Merge branch 'master' into ios-implementation 2025-11-11 01:15:55 -08:00
Matthew Raymer
1b34f1f34a fix(android): configure native fetcher, use DailyNotificationFetchWorker, and cancel notifications on dismiss
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
2025-11-11 08:06:59 +00:00
Matthew Raymer
a5fdf8c5b9 fix(android): create NotificationContentEntity in FetchWorker for prefetch
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.
2025-11-11 01:06:51 +00:00
Matthew Raymer
3fa167cba0 fix(android): improve exact alarm permission check with fallback strategies
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.
2025-11-10 06:12:22 +00:00
Matthew Raymer
5b61f18bd7 feat(android): add exact alarm permission request flow and fix receiver mismatch
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
2025-11-10 05:51:05 +00:00
Matthew Raymer
f31bae1563 feat(android): implement cancelAllNotifications() method
- 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.
2025-11-10 04:17:45 +00:00
Matthew Raymer
50b08401d0 fix(android): resolve MainActivity ClassNotFoundException and add exact alarm permission check
- 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.
2025-11-10 03:52:35 +00:00
Matthew Raymer
37753bb051 docs: add comprehensive integration guides and diagnostic method documentation
Add integration guides and update API documentation with new Android
diagnostic methods. Emphasize critical NotifyReceiver registration
requirement that was causing notification delivery failures.

Documentation Updates:
- API.md: Document isAlarmScheduled(), getNextAlarmTime(), testAlarm()
- README.md: Add Quick Integration section and Android diagnostic methods
- notification-testing-procedures.md: Add BroadcastReceiver troubleshooting

New Integration Guides:
- QUICK_INTEGRATION.md: Step-by-step guide for human developers
- AI_INTEGRATION_GUIDE.md: Machine-readable guide with verification steps
- TODO.md: Task tracking for pending improvements

Key Improvements:
- Explicit NotifyReceiver registration requirement highlighted
- Complete troubleshooting flow for BroadcastReceiver issues
- Diagnostic method examples for debugging alarm scheduling
- AI-friendly integration instructions with verification commands

Fixes notification delivery issues caused by missing NotifyReceiver
registration in host app AndroidManifest.xml files.
2025-11-06 10:08:18 +00:00
Matthew Raymer
a19cb2ba61 fix(test-app): register NotifyReceiver in AndroidManifest
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.
2025-11-06 09:56:32 +00:00
Matthew Raymer
1a7ac200f1 fix(android): implement missing plugin methods and permission handling
- 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.
2025-11-06 08:29:36 +00:00
Matthew Raymer
9f8e295234 fix(android): improve notification scheduling and UX
- 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.
2025-11-06 07:52:40 +00:00
Matthew Raymer
18106e5ba8 feat(android): consolidate databases and add prefetch scheduling
Consolidate Java and Kotlin database implementations into unified
schema, add delayed prefetch scheduling, and fix notification
delivery issues.

Database Consolidation:
- Merge Java DailyNotificationDatabase into Kotlin DatabaseSchema
- Add migration path from v1 to v2 unified schema
- Include all entities: ContentCache, Schedule, Callback, History,
  NotificationContentEntity, NotificationDeliveryEntity,
  NotificationConfigEntity
- Add @JvmStatic getInstance() for Java interoperability
- Update DailyNotificationWorker and DailyNotificationStorageRoom
  to use unified database

Prefetch Functionality:
- Add scheduleDelayedFetch() to FetchWorker for 5-minute prefetch
  before notifications
- Support delayed WorkManager scheduling with initialDelay
- Update scheduleDailyNotification() to optionally schedule prefetch
  when URL is provided

Notification Delivery Fixes:
- Register NotifyReceiver in AndroidManifest.xml (was missing,
  causing notifications not to fire)
- Add safe database initialization with lazy getDatabase() helper
- Prevent PluginLoadException on database init failure

Build Configuration:
- Add kotlin-android and kotlin-kapt plugins
- Configure Room annotation processor (kapt) for Kotlin
- Add Room KTX dependency for coroutines support
- Fix Gradle settings with pluginManagement blocks

Plugin Methods Added:
- checkPermissionStatus() - detailed permission status
- requestNotificationPermissions() - request POST_NOTIFICATIONS
- scheduleDailyNotification() - schedule with AlarmManager
- configureNativeFetcher() - configure native content fetcher
- Various status and configuration methods

Code Cleanup:
- Remove duplicate BootReceiver.java (keep Kotlin version)
- Remove duplicate DailyNotificationPlugin.java (keep Kotlin version)
- Remove old Java database implementation
- Add native fetcher SPI registry (@JvmStatic methods)

The unified database ensures schedule persistence across reboots
and provides a single source of truth for all plugin data.
Prefetch scheduling enables content caching before notifications
fire, improving offline-first reliability.
2025-11-06 06:28:00 +00:00
Matthew Raymer
d9bdeb6d02 refactor(android)!: restructure to standard Capacitor plugin layout
Restructure Android project from nested module layout to standard
Capacitor plugin structure following community conventions.

Structure Changes:
- Move plugin code from android/plugin/ to android/src/main/java/
- Move test app from android/app/ to test-apps/android-test-app/app/
- Remove nested android/plugin module structure
- Remove nested android/app test app structure

Build Infrastructure:
- Add Gradle wrapper files (gradlew, gradlew.bat, gradle/wrapper/)
- Transform android/build.gradle from root project to library module
- Update android/settings.gradle for standalone plugin builds
- Add android/gradle.properties with AndroidX configuration
- Add android/consumer-rules.pro for ProGuard rules

Configuration Updates:
- Add prepare script to package.json for automatic builds on npm install
- Update package.json version to 1.0.1
- Update android/build.gradle to properly resolve Capacitor dependencies
- Update test-apps/android-test-app/settings.gradle with correct paths
- Remove android/variables.gradle (hardcode values in build.gradle)

Documentation:
- Update BUILDING.md with new structure and build process
- Update INTEGRATION_GUIDE.md to reflect standard structure
- Update README.md to remove path fix warnings
- Add test-apps/BUILD_PROCESS.md documenting test app build flows

Test App Configuration:
- Fix android-test-app to correctly reference plugin and Capacitor
- Remove capacitor-cordova-android-plugins dependency (not needed)
- Update capacitor.settings.gradle path verification in fix script

BREAKING CHANGE: Plugin now uses standard Capacitor Android structure.
Consuming apps must update their capacitor.settings.gradle to reference
android/ instead of android/plugin/. This is automatically handled by
Capacitor CLI for apps using standard plugin installation.
2025-11-05 08:08:37 +00: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
c4b7f6382f fix(test-app): ensure afterId parameter is always included in API requests
The /api/v2/report/plansLastUpdatedBetween endpoint requires the afterId
parameter. When no previous jwtId is stored, default to "0" for the first
request. This ensures afterId is always present and never null/omitted.

Fix resolves "afterId parameter is required" API errors. Verified working:
prefetch execution shows request body includes afterId: "0" and API returns
HTTP 200 successfully.
2025-11-02 09:58:41 +00:00
Matthew Raymer
a421bb5d41 fix(test-app): remove aud claim from JWT to resolve server validation error
Remove the aud (audience) claim from JWT payloads. The server's did-jwt
verification requires an audience option when aud is present, but the server
isn't configured to validate it, causing "JWT audience is required but your
app address has not been configured" errors.

Changes:
- Removed aud claim from JWT payload in generateEndorserJWT()
- Updated key derivation to User Zero's specific path (m/84737769'/0'/0'/0')
- Added public key verification against expected User Zero key
- Enhanced JWT diagnostics logging throughout
- Added alarm deduplication optimization (prevent duplicate alarms for same time)

Verified: JWT validation now passes (token length 360→333 chars, no audience
error). New error is API parameter validation (afterId required - separate issue).
2025-11-02 09:46:54 +00:00