6.0 KiB
P2.1 iOS Batch B - Validation + Delegation Methods
Purpose: Second batch of iOS plugin refactoring - methods that validate input then delegate to services
Owner: Development Team
Created: 2025-12-23
Status: ready
Baseline: See docs/progress/00-STATUS.md (v1.0.11-p3-complete)
Goal
Refactor iOS plugin methods that validate input then delegate to services. These methods:
- Extract and validate parameters from
CAPPluginCall - Handle error responses for invalid input
- Delegate validated parameters to service methods
- Map service results/errors to plugin responses
Success Criteria:
- Plugin method validates input, delegates to service
- Service method handles business logic
- External API unchanged
- Tests pass
Target Methods (Batch B)
Permissions (4 methods)
-
checkPermissionStatus()- Validate: None (read-only)
- Delegate:
UNUserNotificationCenter.getNotificationSettings()→ parse and format - Type: validation (parse settings, format response)
-
requestNotificationPermissions()- Validate: None (request only)
- Delegate:
UNUserNotificationCenter.requestAuthorization(...) - Type: validation (handle async result)
-
getNotificationPermissionStatus()- Validate: None (read-only)
- Delegate:
UNUserNotificationCenter.getNotificationSettings()→ parse and format - Type: validation (parse settings, format response)
-
requestNotificationPermission()- Validate: None (request only)
- Delegate:
UNUserNotificationCenter.requestAuthorization(...) - Type: validation (handle async result)
Scheduling (5 methods)
-
scheduleContentFetch()- Validate: Config object required
- Delegate:
DailyNotificationScheduler.scheduleFetch(...)orDailyNotificationBackgroundTaskManager.scheduleFetch(...) - Type: validation (validate config, delegate)
-
scheduleUserNotification()- Validate: Config object required
- Delegate:
DailyNotificationScheduler.scheduleUserNotification(...) - Type: validation (validate config, delegate)
-
scheduleDailyNotification()- Validate: Time format (HH:mm), required parameters
- Delegate:
DailyNotificationScheduler.schedule(...) - Type: validation (validate time format, delegate)
-
scheduleDailyReminder()- Validate: id, title, body, time required; time format (HH:mm)
- Delegate:
DailyNotificationStorage.storeReminder(...)+ schedule notification - Type: validation (validate input, delegate)
-
updateDailyReminder()- Validate: reminderId required
- Delegate:
DailyNotificationStorage.updateReminder(...) - Type: validation (validate input, delegate)
-
cancelDailyReminder()- Validate: reminderId required
- Delegate:
DailyNotificationStorage.removeReminder(id) - Type: validation (validate input, delegate)
Content & History (1 method)
getPendingNotifications()- Validate: None (read-only)
- Delegate:
UNUserNotificationCenter.getPendingNotificationRequests()→ parse and format - Type: validation (parse requests, format response)
Settings & Channels (5 methods)
-
isChannelEnabled()- Validate: channelId (optional)
- Delegate:
UNUserNotificationCenter.getNotificationSettings()→ check channel - Type: validation (parse settings, check channel)
-
openChannelSettings()- Validate: channelId (optional)
- Delegate:
UIApplication.openSettingsURLString(with channel fallback) - Type: validation (needs app context)
-
openNotificationSettings()- Validate: None
- Delegate:
UIApplication.openSettingsURLString - Type: validation (needs app context)
-
openBackgroundAppRefreshSettings()- Validate: None
- Delegate:
UIApplication.openSettingsURLString - Type: validation (needs app context)
-
updateSettings()- Validate: Settings object
- Delegate:
DailyNotificationStorage.updateSettings(...)orDailyNotificationStateActor.saveSettings(...) - Type: validation (validate input, delegate)
Configuration (1 method)
configure()- Validate: Optional parameters (dbPath, storage, ttlSeconds, etc.)
- Delegate:
DailyNotificationStorage.configure(...)or reinitialize storage - Type: validation (validate input, delegate)
Implementation Strategy
- Read current implementation of each method
- Extract validation logic to plugin method (parameter extraction, format validation)
- Identify service method to delegate to (or create if needed)
- Refactor plugin method to: validate → delegate → map response
- Test that external API behavior is unchanged
- Commit in small batches (2-3 methods per commit)
Service Methods Needed
Some service methods may need to be created or enhanced:
DailyNotificationStorage.storeReminder(...)- May need to be createdDailyNotificationStorage.updateReminder(...)- May need to be createdDailyNotificationStorage.removeReminder(id)- May need to be createdDailyNotificationScheduler.scheduleFetch(...)- Check if existsDailyNotificationScheduler.scheduleUserNotification(...)- Check if exists
Notes
- iOS uses
CAPPluginCallfor parameter extraction (similar to Android'sPluginCall) - Error handling uses
call.reject(message, code)withDailyNotificationErrorCodes - Async operations use
Task { }blocks withawait - Settings methods need
UIApplicationaccess (may need activity/view controller) - Permission methods use
UNUserNotificationCenterdirectly (no service wrapper needed)
Estimated Impact
- Methods refactored: 17
- Lines removed: ~400-500 lines (validation logic moved to services where appropriate)
- Complexity reduction: Medium (validation stays in plugin, business logic moves to services)
- Risk: Low-Medium (validation logic changes, but external API unchanged)
Next Batch
After Batch B, proceed to Batch C (glue/orchestration methods) for complex methods that combine multiple services.