# API Reference ## DailyNotificationPlugin Interface ### Configuration #### `configure(options: ConfigureOptions): Promise` Configure the plugin with storage, TTL, and optimization settings. **Parameters:** - `options.storage`: `'shared'` | `'tiered'` - Storage mode - `options.ttlSeconds`: `number` - TTL in seconds (default: 1800) - `options.prefetchLeadMinutes`: `number` - Prefetch lead time (default: 15) - `options.enableETagSupport`: `boolean` - Enable ETag conditional requests - `options.enableErrorHandling`: `boolean` - Enable advanced error handling - `options.enablePerformanceOptimization`: `boolean` - Enable performance optimization ### Core Methods #### `scheduleDailyNotification(options: NotificationOptions): Promise` Schedule a daily notification with content fetching. **Parameters:** - `options.url`: `string` - Content endpoint URL - `options.time`: `string` - Time in HH:MM format - `options.title`: `string` - Notification title - `options.body`: `string` - Notification body - `options.sound`: `boolean` - Enable sound (optional) - `options.retryConfig`: `RetryConfiguration` - Custom retry settings (optional) #### `getLastNotification(): Promise` Get the last scheduled notification. #### `cancelAllNotifications(): Promise` Cancel all scheduled notifications. ### Platform-Specific Methods #### Android Only ##### `getExactAlarmStatus(): Promise` Get exact alarm permission and capability status. ##### `requestExactAlarmPermission(): Promise` Request exact alarm permission from user. ##### `openExactAlarmSettings(): Promise` Open exact alarm settings in system preferences. ##### `getRebootRecoveryStatus(): Promise` Get reboot recovery status and statistics. ### Management Methods #### `maintainRollingWindow(): Promise` Manually trigger rolling window maintenance. #### `getRollingWindowStats(): Promise` Get rolling window statistics and status. ### Optimization Methods #### `optimizeDatabase(): Promise` Optimize database performance with indexes and settings. #### `optimizeMemory(): Promise` Optimize memory usage and perform cleanup. #### `optimizeBattery(): Promise` Optimize battery usage and background CPU. ### Metrics and Monitoring #### `getPerformanceMetrics(): Promise` Get comprehensive performance metrics. #### `getErrorMetrics(): Promise` Get error handling metrics and statistics. #### `getNetworkMetrics(): Promise` Get network efficiency metrics (ETag support). #### `getMemoryMetrics(): Promise` Get memory usage metrics and statistics. #### `getObjectPoolMetrics(): Promise` Get object pooling efficiency metrics. ### Utility Methods #### `resetPerformanceMetrics(): Promise` Reset all performance metrics to zero. #### `resetErrorMetrics(): Promise` Reset error handling metrics. #### `clearRetryStates(): Promise` Clear all retry states and operations. #### `cleanExpiredETags(): Promise` Clean expired ETag cache entries. ## Data Types ### ConfigureOptions ```typescript interface ConfigureOptions { storage?: 'shared' | 'tiered'; ttlSeconds?: number; prefetchLeadMinutes?: number; enableETagSupport?: boolean; enableErrorHandling?: boolean; enablePerformanceOptimization?: boolean; maxRetries?: number; baseRetryDelay?: number; maxRetryDelay?: number; backoffMultiplier?: number; memoryWarningThreshold?: number; memoryCriticalThreshold?: number; objectPoolSize?: number; maxObjectPoolSize?: number; } ``` ### NotificationOptions ```typescript interface NotificationOptions { url: string; time: string; title: string; body: string; sound?: boolean; retryConfig?: RetryConfiguration; } ``` ### ExactAlarmStatus (Android) ```typescript interface ExactAlarmStatus { supported: boolean; enabled: boolean; canSchedule: boolean; fallbackWindow: string; } ``` ### PerformanceMetrics ```typescript interface PerformanceMetrics { overallScore: number; databasePerformance: number; memoryEfficiency: number; batteryEfficiency: number; objectPoolEfficiency: number; totalDatabaseQueries: number; averageMemoryUsage: number; objectPoolHits: number; backgroundCpuUsage: number; totalNetworkRequests: number; recommendations: string[]; } ``` ### ErrorMetrics ```typescript interface ErrorMetrics { totalErrors: number; networkErrors: number; storageErrors: number; schedulingErrors: number; permissionErrors: number; configurationErrors: number; systemErrors: number; unknownErrors: number; cacheHitRatio: number; } ``` ## Error Handling All methods return promises that reject with descriptive error messages. The plugin includes comprehensive error categorization and retry logic. ### Common Error Types - **Network Errors**: Connection timeouts, DNS failures - **Storage Errors**: Database corruption, disk full - **Permission Errors**: Missing exact alarm permission - **Configuration Errors**: Invalid parameters, unsupported settings - **System Errors**: Out of memory, platform limitations ## Platform Differences ### Android - Requires `SCHEDULE_EXACT_ALARM` permission for precise timing - Falls back to windowed alarms (±10m) if exact permission denied - Supports reboot recovery with broadcast receivers - Full performance optimization features ### iOS - Uses `BGTaskScheduler` for background prefetch - Limited to 64 pending notifications - Automatic background task management - Battery optimization built-in ### Web - Placeholder implementations for development - No actual notification scheduling - All methods return mock data - Used for testing and development