notification-kit
Version:
A unified notification library for React + Capacitor apps. One API for push notifications, in-app notifications, and local notifications across Web, iOS, and Android.
295 lines • 8.21 kB
TypeScript
export type Platform = 'web' | 'ios' | 'android' | 'electron' | 'unknown';
export interface PlatformCapabilities {
pushNotifications: boolean;
localNotifications: boolean;
inAppNotifications: boolean;
notificationChannels: boolean;
notificationActions: boolean;
notificationBadging: boolean;
notificationSound: boolean;
notificationVibration: boolean;
notificationLights: boolean;
notificationGrouping: boolean;
notificationImportance: boolean;
notificationVisibility: boolean;
notificationLockScreen: boolean;
notificationFullScreen: boolean;
notificationHeadsUp: boolean;
notificationOngoing: boolean;
notificationProgress: boolean;
notificationBigText: boolean;
notificationBigPicture: boolean;
notificationInbox: boolean;
notificationMedia: boolean;
notificationCustom: boolean;
notificationScheduling: boolean;
notificationGeofencing: boolean;
notificationTriggers: boolean;
serviceWorker: boolean;
webPushProtocol: boolean;
backgroundSync: boolean;
foregroundService: boolean;
criticalAlerts: boolean;
provisionalAuth: boolean;
appBadge: boolean;
quietHours: boolean;
doNotDisturb: boolean;
}
export interface PlatformConfig {
platform: Platform;
capabilities: PlatformCapabilities;
version?: string;
userAgent?: string;
isCapacitor?: boolean;
isHybrid?: boolean;
isNative?: boolean;
isWeb?: boolean;
supportedFormats?: NotificationFormat[];
maxPayloadSize?: number;
maxActions?: number;
maxBadgeCount?: number;
defaultSound?: string;
defaultVibration?: number[];
defaultLights?: string;
timeZone?: string;
locale?: string;
deviceId?: string;
appId?: string;
bundleId?: string;
packageName?: string;
}
export interface PlatformDetection {
platform: Platform;
isCapacitor: boolean;
isHybrid: boolean;
isNative: boolean;
isWeb: boolean;
isMobile: boolean;
isDesktop: boolean;
isTablet: boolean;
version: string;
userAgent: string;
supportedFeatures: string[];
limitations: string[];
warnings: string[];
}
export interface NotificationFormat {
id: string;
name: string;
description: string;
mimeType: string;
extensions: string[];
maxSize?: number;
dimensions?: {
width: number;
height: number;
};
supported: boolean;
fallback?: string;
}
export interface PlatformPermission {
type: string;
status: 'granted' | 'denied' | 'prompt' | 'unknown';
canRequest: boolean;
isRequired: boolean;
description: string;
systemSetting?: boolean;
appSetting?: boolean;
userAction?: boolean;
rationale?: string;
}
export interface PlatformStorage {
type: 'preferences' | 'localStorage' | 'sessionStorage' | 'indexedDB' | 'sqlite' | 'keychain' | 'shared';
maxSize?: number;
persistent: boolean;
encrypted: boolean;
synchronous: boolean;
crossApp: boolean;
backup: boolean;
cloudSync: boolean;
supported: boolean;
description: string;
}
export interface ServiceWorkerCapabilities {
supported: boolean;
registration: boolean;
messaging: boolean;
backgroundSync: boolean;
periodicSync: boolean;
push: boolean;
notifications: boolean;
installation: boolean;
activation: boolean;
update: boolean;
offline: boolean;
caching: boolean;
scope: string;
scriptURL: string;
state: 'installing' | 'installed' | 'activating' | 'activated' | 'redundant' | 'unknown';
}
export interface NetworkCapabilities {
online: boolean;
connection: 'wifi' | 'cellular' | 'ethernet' | 'bluetooth' | 'vpn' | 'unknown';
effectiveType: 'slow-2g' | '2g' | '3g' | '4g' | '5g' | 'unknown';
downlink: number;
rtt: number;
saveData: boolean;
metered: boolean;
unmetered: boolean;
background: boolean;
foreground: boolean;
}
export interface SecurityCapabilities {
https: boolean;
csp: boolean;
cors: boolean;
origin: string;
secure: boolean;
sameOrigin: boolean;
crossOrigin: boolean;
permissions: boolean;
featurePolicy: boolean;
sandbox: boolean;
integrity: boolean;
authentication: boolean;
authorization: boolean;
encryption: boolean;
signing: boolean;
verification: boolean;
}
export interface PlatformPerformance {
memory: {
used: number;
total: number;
available: number;
limit: number;
};
cpu: {
usage: number;
cores: number;
speed: number;
};
battery: {
level: number;
charging: boolean;
chargingTime: number;
dischargingTime: number;
};
network: {
bandwidth: number;
latency: number;
throughput: number;
};
storage: {
used: number;
available: number;
quota: number;
};
timing: {
start: number;
end: number;
duration: number;
fps: number;
};
}
export interface PlatformError {
code: string;
message: string;
platform: Platform;
feature: string;
severity: 'low' | 'medium' | 'high' | 'critical';
recoverable: boolean;
userAction: boolean;
systemAction: boolean;
workaround?: string;
documentation?: string;
support?: string;
}
export interface PlatformFeatureFlags {
experimental: boolean;
beta: boolean;
deprecated: boolean;
fallback: boolean;
polyfill: boolean;
workaround: boolean;
native: boolean;
hybrid: boolean;
progressive: boolean;
adaptive: boolean;
responsive: boolean;
accessible: boolean;
performant: boolean;
secure: boolean;
compliant: boolean;
tested: boolean;
documented: boolean;
supported: boolean;
}
export interface PlatformAPI {
name: string;
version: string;
available: boolean;
deprecated: boolean;
experimental: boolean;
prefix?: string;
polyfill?: string;
fallback?: string;
documentation?: string;
support?: string[];
limitations?: string[];
alternatives?: string[];
}
export interface PlatformEnvironment {
platform: Platform;
capabilities: PlatformCapabilities;
config: PlatformConfig;
detection: PlatformDetection;
permissions: PlatformPermission[];
storage: PlatformStorage[];
serviceWorker: ServiceWorkerCapabilities;
network: NetworkCapabilities;
security: SecurityCapabilities;
performance: PlatformPerformance;
errors: PlatformError[];
features: PlatformFeatureFlags;
apis: PlatformAPI[];
timestamp: number;
version: string;
}
export interface PlatformDefaults {
web: Partial<PlatformCapabilities>;
ios: Partial<PlatformCapabilities>;
android: Partial<PlatformCapabilities>;
electron: Partial<PlatformCapabilities>;
unknown: Partial<PlatformCapabilities>;
}
export interface PlatformCompatibility {
[feature: string]: {
web: boolean;
ios: boolean;
android: boolean;
electron: boolean;
notes?: string;
alternatives?: string[];
polyfills?: string[];
fallbacks?: string[];
};
}
export interface PlatformUtils {
detect: () => PlatformDetection;
getCapabilities: (platform: Platform) => PlatformCapabilities;
isSupported: (feature: string, platform?: Platform) => boolean;
getPermissions: (platform: Platform) => PlatformPermission[];
getStorage: (platform: Platform) => PlatformStorage[];
getAPIs: (platform: Platform) => PlatformAPI[];
getErrors: (platform: Platform) => PlatformError[];
getDefaults: (platform: Platform) => Partial<PlatformCapabilities>;
getCompatibility: () => PlatformCompatibility;
getEnvironment: () => PlatformEnvironment;
validate: (config: any, platform: Platform) => boolean;
optimize: (config: any, platform: Platform) => any;
fallback: (feature: string, platform: Platform) => any;
polyfill: (feature: string, platform: Platform) => any;
workaround: (issue: string, platform: Platform) => any;
}
//# sourceMappingURL=platform.d.ts.map