You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
3.9 KiB
166 lines
3.9 KiB
/**
|
|
* Daily Notification Plugin Definitions
|
|
*
|
|
* TypeScript definitions for the Daily Notification Plugin
|
|
* Aligned with Android implementation and test requirements
|
|
*
|
|
* @author Matthew Raymer
|
|
* @version 2.0.0
|
|
*/
|
|
|
|
export interface NotificationResponse {
|
|
id: string;
|
|
title: string;
|
|
body: string;
|
|
timestamp: number;
|
|
url?: string;
|
|
}
|
|
|
|
export interface NotificationOptions {
|
|
url?: string;
|
|
time?: string;
|
|
title?: string;
|
|
body?: string;
|
|
sound?: boolean;
|
|
priority?: 'high' | 'default' | 'low' | 'min' | 'max' | 'normal';
|
|
timezone?: string;
|
|
retryCount?: number;
|
|
retryInterval?: number;
|
|
offlineFallback?: boolean;
|
|
contentHandler?: ContentHandler;
|
|
headers?: Record<string, string>;
|
|
}
|
|
|
|
export interface ContentHandler {
|
|
(response?: any): Promise<{ title: string; body: string; data?: any }>;
|
|
}
|
|
|
|
export interface DailyNotificationPlugin {
|
|
scheduleDailyNotification(options: NotificationOptions | ScheduleOptions): Promise<void>;
|
|
getLastNotification(): Promise<NotificationResponse | null>;
|
|
cancelAllNotifications(): Promise<void>;
|
|
getNotificationStatus(): Promise<NotificationStatus>;
|
|
updateSettings(settings: NotificationSettings): Promise<void>;
|
|
getBatteryStatus(): Promise<BatteryStatus>;
|
|
requestBatteryOptimizationExemption(): Promise<void>;
|
|
setAdaptiveScheduling(options: { enabled: boolean }): Promise<void>;
|
|
getPowerState(): Promise<PowerState>;
|
|
checkPermissions(): Promise<PermissionStatus>;
|
|
requestPermissions(): Promise<PermissionStatus>;
|
|
}
|
|
|
|
export interface ScheduleOptions {
|
|
url?: string;
|
|
time?: string;
|
|
sound?: boolean;
|
|
priority?: 'high' | 'default' | 'low' | 'min' | 'max' | 'normal';
|
|
timezone?: string;
|
|
retryCount?: number;
|
|
retryInterval?: number;
|
|
offlineFallback?: boolean;
|
|
contentHandler?: ContentHandler;
|
|
headers?: Record<string, string>;
|
|
}
|
|
|
|
export interface NotificationSettings {
|
|
url?: string;
|
|
time?: string;
|
|
sound?: boolean;
|
|
priority?: string;
|
|
timezone?: string;
|
|
retryCount?: number;
|
|
retryInterval?: number;
|
|
offlineFallback?: boolean;
|
|
}
|
|
|
|
export interface NotificationStatus {
|
|
isEnabled?: boolean;
|
|
isScheduled?: boolean;
|
|
lastNotificationTime: number | Promise<number>;
|
|
nextNotificationTime: number | Promise<number>;
|
|
pending?: number;
|
|
settings: NotificationSettings;
|
|
error?: string;
|
|
}
|
|
|
|
export interface BatteryStatus {
|
|
level: number;
|
|
isCharging: boolean;
|
|
powerState: number;
|
|
isOptimizationExempt: boolean;
|
|
}
|
|
|
|
export interface PowerState {
|
|
powerState: number;
|
|
isOptimizationExempt: boolean;
|
|
}
|
|
|
|
export interface NotificationEvent extends Event {
|
|
detail: {
|
|
id: string;
|
|
action: string;
|
|
data?: any;
|
|
};
|
|
}
|
|
|
|
export interface PermissionStatus {
|
|
status?: string;
|
|
granted?: boolean;
|
|
notifications: PermissionState;
|
|
backgroundRefresh?: PermissionState; // iOS only
|
|
alert?: boolean;
|
|
badge?: boolean;
|
|
sound?: boolean;
|
|
lockScreen?: boolean;
|
|
carPlay?: boolean;
|
|
}
|
|
|
|
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied' | 'provisional' | 'ephemeral' | 'unknown';
|
|
|
|
// Additional interfaces for enhanced functionality
|
|
export interface NotificationMetrics {
|
|
scheduledTime: number;
|
|
actualDeliveryTime?: number;
|
|
contentAge: number;
|
|
engagement?: 'TAPPED' | 'DISMISSED' | 'IGNORED';
|
|
failureReason?: string;
|
|
platformInfo: PlatformInfo;
|
|
}
|
|
|
|
export interface PlatformInfo {
|
|
oem?: string;
|
|
osVersion: string;
|
|
appState: string;
|
|
}
|
|
|
|
export interface FallbackContent {
|
|
title: string;
|
|
body: string;
|
|
isEmergency: boolean;
|
|
age?: string;
|
|
}
|
|
|
|
export interface CachePolicy {
|
|
maxSize: number;
|
|
evictionPolicy: 'LRU' | 'FIFO' | 'TTL';
|
|
ttl?: number;
|
|
cleanupInterval: number;
|
|
}
|
|
|
|
export interface NetworkConfig {
|
|
timeout: number;
|
|
retryAttempts: number;
|
|
retryDelay: number;
|
|
offlineFallback: boolean;
|
|
}
|
|
|
|
export interface SchedulingConfig {
|
|
exactAlarms: boolean;
|
|
adaptiveScheduling: boolean;
|
|
quietHours?: {
|
|
start: string;
|
|
end: string;
|
|
enabled: boolean;
|
|
};
|
|
timezone: string;
|
|
}
|