feat: add minimal Capacitor test apps for all platforms
- Add Android test app with exact alarm permission testing - Add iOS test app with rolling window and BGTaskScheduler testing - Add Electron test app with mock implementations and IPC - Include automated setup scripts for each platform - Provide comprehensive testing checklist and troubleshooting guide - Follow best practices for Capacitor plugin testing Test apps include: - Plugin configuration and scheduling validation - Platform-specific feature testing (Android exact alarms, iOS rolling window) - Performance monitoring and debug information - Error handling and edge case testing - Cross-platform API consistency validation Setup: Run ./setup-*.sh scripts for automated platform setup Testing: Each app provides interactive UI for comprehensive plugin validation Files: 25+ new files across test-apps/ directory
This commit is contained in:
208
API.md
Normal file
208
API.md
Normal file
@@ -0,0 +1,208 @@
|
||||
# API Reference
|
||||
|
||||
## DailyNotificationPlugin Interface
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `configure(options: ConfigureOptions): Promise<void>`
|
||||
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<void>`
|
||||
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<NotificationResponse | null>`
|
||||
Get the last scheduled notification.
|
||||
|
||||
#### `cancelAllNotifications(): Promise<void>`
|
||||
Cancel all scheduled notifications.
|
||||
|
||||
### Platform-Specific Methods
|
||||
|
||||
#### Android Only
|
||||
|
||||
##### `getExactAlarmStatus(): Promise<ExactAlarmStatus>`
|
||||
Get exact alarm permission and capability status.
|
||||
|
||||
##### `requestExactAlarmPermission(): Promise<void>`
|
||||
Request exact alarm permission from user.
|
||||
|
||||
##### `openExactAlarmSettings(): Promise<void>`
|
||||
Open exact alarm settings in system preferences.
|
||||
|
||||
##### `getRebootRecoveryStatus(): Promise<RecoveryStatus>`
|
||||
Get reboot recovery status and statistics.
|
||||
|
||||
### Management Methods
|
||||
|
||||
#### `maintainRollingWindow(): Promise<void>`
|
||||
Manually trigger rolling window maintenance.
|
||||
|
||||
#### `getRollingWindowStats(): Promise<RollingWindowStats>`
|
||||
Get rolling window statistics and status.
|
||||
|
||||
### Optimization Methods
|
||||
|
||||
#### `optimizeDatabase(): Promise<void>`
|
||||
Optimize database performance with indexes and settings.
|
||||
|
||||
#### `optimizeMemory(): Promise<void>`
|
||||
Optimize memory usage and perform cleanup.
|
||||
|
||||
#### `optimizeBattery(): Promise<void>`
|
||||
Optimize battery usage and background CPU.
|
||||
|
||||
### Metrics and Monitoring
|
||||
|
||||
#### `getPerformanceMetrics(): Promise<PerformanceMetrics>`
|
||||
Get comprehensive performance metrics.
|
||||
|
||||
#### `getErrorMetrics(): Promise<ErrorMetrics>`
|
||||
Get error handling metrics and statistics.
|
||||
|
||||
#### `getNetworkMetrics(): Promise<NetworkMetrics>`
|
||||
Get network efficiency metrics (ETag support).
|
||||
|
||||
#### `getMemoryMetrics(): Promise<MemoryMetrics>`
|
||||
Get memory usage metrics and statistics.
|
||||
|
||||
#### `getObjectPoolMetrics(): Promise<ObjectPoolMetrics>`
|
||||
Get object pooling efficiency metrics.
|
||||
|
||||
### Utility Methods
|
||||
|
||||
#### `resetPerformanceMetrics(): Promise<void>`
|
||||
Reset all performance metrics to zero.
|
||||
|
||||
#### `resetErrorMetrics(): Promise<void>`
|
||||
Reset error handling metrics.
|
||||
|
||||
#### `clearRetryStates(): Promise<void>`
|
||||
Clear all retry states and operations.
|
||||
|
||||
#### `cleanExpiredETags(): Promise<void>`
|
||||
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
|
||||
Reference in New Issue
Block a user