UNPKG

atozas-push-notification

Version:

Real-time push notifications across platforms using socket.io

82 lines (74 loc) 2.39 kB
export interface NotificationData { id: string; title: string; message: string; timestamp: number; data?: any; priority?: 'low' | 'normal' | 'high'; category?: string; } export interface UserInfo { userId: string; deviceId?: string; platform?: 'web' | 'mobile' | 'desktop'; metadata?: any; } export interface NotificationOptions { persist?: boolean; sound?: boolean; vibrate?: boolean; badge?: boolean; icon?: string; image?: string; actions?: NotificationAction[]; silent?: boolean; requireInteraction?: boolean; tag?: string; renotify?: boolean; dir?: 'auto' | 'ltr' | 'rtl'; lang?: string; timestamp?: number; showInUI?: boolean; // Show in custom UI if browser notifications not available autoClose?: number; // Auto close after milliseconds position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center'; } export interface NotificationAction { action: string; title: string; icon?: string; } export interface ClientConfig { url: string; autoConnect?: boolean; reconnection?: boolean; reconnectionAttempts?: number; reconnectionDelay?: number; reconnectionDelayMax?: number; timeout?: number; forceNew?: boolean; // Notification display settings requestPermission?: boolean; // Auto request notification permission fallbackToUI?: boolean; // Use custom UI if browser notifications not supported defaultNotificationIcon?: string; defaultNotificationSound?: string; enableVibration?: boolean; showNotifications?: boolean; // Enable/disable visual notifications } export interface ServerConfig { port?: number; cors?: any; allowEIO3?: boolean; transports?: string[]; } export interface SendNotificationParams { to: 'user' | 'group' | 'broadcast'; target?: string | string[]; notification: NotificationData; options?: NotificationOptions; } export type NotificationCallback = (notification: NotificationData, options?: NotificationOptions) => void; export type ConnectionCallback = (connected: boolean) => void; export type ErrorCallback = (error: Error) => void; export type UserStatusCallback = (userId: string, online: boolean) => void; // Browser notification permission type export type NotificationPermission = 'default' | 'granted' | 'denied';